Spaces:
Runtime error
Runtime error
Update api/common.go
Browse files- api/common.go +6 -7
api/common.go
CHANGED
|
@@ -10,7 +10,6 @@ import (
|
|
| 10 |
"encoding/json"
|
| 11 |
"github.com/linweiyuan/go-chatgpt-api/util/logger"
|
| 12 |
"github.com/gin-gonic/gin"
|
| 13 |
-
"github.com/linweiyuan/go-chatgpt-api/api"
|
| 14 |
_ "github.com/linweiyuan/go-chatgpt-api/env"
|
| 15 |
|
| 16 |
http "github.com/bogdanfinn/fhttp"
|
|
@@ -72,9 +71,9 @@ func GetAccessToken(accessToken string) string {
|
|
| 72 |
}
|
| 73 |
|
| 74 |
//goland:noinspection GoUnhandledErrorResult
|
| 75 |
-
func HandleConversationResponse(c *gin.Context, resp *http.Response)
|
| 76 |
-
|
| 77 |
-
|
| 78 |
c.Writer.Header().Set("Content-Type", "text/event-stream; charset=utf-8")
|
| 79 |
|
| 80 |
reader := bufio.NewReader(resp.Body)
|
|
@@ -122,12 +121,12 @@ func HandleConversationResponse(c *gin.Context, resp *http.Response) Conversatio
|
|
| 122 |
finishType := finishDetails["type"].(string)
|
| 123 |
if(finishType == "max_tokens") {
|
| 124 |
logger.Info(fmt.Sprintf("finish_details中type的值: %s", finishType))
|
| 125 |
-
|
| 126 |
-
|
| 127 |
}
|
| 128 |
}
|
| 129 |
}
|
| 130 |
-
return
|
| 131 |
}
|
| 132 |
|
| 133 |
//goland:noinspection GoUnhandledErrorResult,SpellCheckingInspection
|
|
|
|
| 10 |
"encoding/json"
|
| 11 |
"github.com/linweiyuan/go-chatgpt-api/util/logger"
|
| 12 |
"github.com/gin-gonic/gin"
|
|
|
|
| 13 |
_ "github.com/linweiyuan/go-chatgpt-api/env"
|
| 14 |
|
| 15 |
http "github.com/bogdanfinn/fhttp"
|
|
|
|
| 71 |
}
|
| 72 |
|
| 73 |
//goland:noinspection GoUnhandledErrorResult
|
| 74 |
+
func HandleConversationResponse(c *gin.Context, resp *http.Response) (bool, string) {
|
| 75 |
+
Status := false
|
| 76 |
+
conversationID := ""
|
| 77 |
c.Writer.Header().Set("Content-Type", "text/event-stream; charset=utf-8")
|
| 78 |
|
| 79 |
reader := bufio.NewReader(resp.Body)
|
|
|
|
| 121 |
finishType := finishDetails["type"].(string)
|
| 122 |
if(finishType == "max_tokens") {
|
| 123 |
logger.Info(fmt.Sprintf("finish_details中type的值: %s", finishType))
|
| 124 |
+
Status = true
|
| 125 |
+
ConversationID = result["conversation_id"].(string)
|
| 126 |
}
|
| 127 |
}
|
| 128 |
}
|
| 129 |
+
return (Status, ConversationID)
|
| 130 |
}
|
| 131 |
|
| 132 |
//goland:noinspection GoUnhandledErrorResult,SpellCheckingInspection
|