Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files- api/chatgpt/api.go +4 -4
- api/common.go +4 -5
api/chatgpt/api.go
CHANGED
@@ -81,10 +81,10 @@ func CreateConversation(c *gin.Context) {
|
|
81 |
return
|
82 |
}
|
83 |
c.Set("oldpart", "")
|
84 |
-
Status,
|
85 |
if Status {
|
86 |
resp.Body.Close()
|
87 |
-
ContinueConversation(c, ConversationID,
|
88 |
} else {
|
89 |
resp.Body.Close()
|
90 |
}
|
@@ -139,11 +139,11 @@ func ContinueConversation(c *gin.Context, conversationID string, parentMessageID
|
|
139 |
}
|
140 |
|
141 |
c.Set("oldpart", oldpart)
|
142 |
-
Status,
|
143 |
if Status {
|
144 |
resp.Body.Close()
|
145 |
logger.Info(fmt.Sprintf("part的值: %s", part))
|
146 |
-
ContinueConversation(c, ConversationID,
|
147 |
} else {
|
148 |
resp.Body.Close()
|
149 |
}
|
|
|
81 |
return
|
82 |
}
|
83 |
c.Set("oldpart", "")
|
84 |
+
Status, ParentMessageID, part := api.HandleConversationResponse(c, resp)
|
85 |
if Status {
|
86 |
resp.Body.Close()
|
87 |
+
ContinueConversation(c, *request.ConversationID, ParentMessageID, request.Model, part)
|
88 |
} else {
|
89 |
resp.Body.Close()
|
90 |
}
|
|
|
139 |
}
|
140 |
|
141 |
c.Set("oldpart", oldpart)
|
142 |
+
Status, ParentMessageID, part := api.HandleConversationResponse(c, resp)
|
143 |
if Status {
|
144 |
resp.Body.Close()
|
145 |
logger.Info(fmt.Sprintf("part的值: %s", part))
|
146 |
+
ContinueConversation(c, *request.ConversationID, ParentMessageID, request.Model, part)
|
147 |
} else {
|
148 |
resp.Body.Close()
|
149 |
}
|
api/common.go
CHANGED
@@ -74,7 +74,7 @@ func GetAccessToken(accessToken string) string {
|
|
74 |
//goland:noinspection GoUnhandledErrorResult
|
75 |
func HandleConversationResponse(c *gin.Context, resp *http.Response) (bool, string, string) {
|
76 |
Status := false
|
77 |
-
|
78 |
oldpart := c.GetString("oldpart")
|
79 |
part := ""
|
80 |
|
@@ -168,18 +168,17 @@ func HandleConversationResponse(c *gin.Context, resp *http.Response) (bool, stri
|
|
168 |
parts := content["parts"].([]interface{})
|
169 |
part = parts[0].(string)
|
170 |
Status = true
|
171 |
-
|
172 |
|
173 |
if len(oldpart) == 0 {
|
174 |
-
msg_id
|
175 |
-
c.Set("msg_id", msg_id)
|
176 |
}
|
177 |
}
|
178 |
}
|
179 |
}
|
180 |
}
|
181 |
}
|
182 |
-
return Status,
|
183 |
}
|
184 |
|
185 |
//goland:noinspection GoUnhandledErrorResult,SpellCheckingInspection
|
|
|
74 |
//goland:noinspection GoUnhandledErrorResult
|
75 |
func HandleConversationResponse(c *gin.Context, resp *http.Response) (bool, string, string) {
|
76 |
Status := false
|
77 |
+
ParentMessageID := ""
|
78 |
oldpart := c.GetString("oldpart")
|
79 |
part := ""
|
80 |
|
|
|
168 |
parts := content["parts"].([]interface{})
|
169 |
part = parts[0].(string)
|
170 |
Status = true
|
171 |
+
ParentMessageID = message["id"].(string)
|
172 |
|
173 |
if len(oldpart) == 0 {
|
174 |
+
c.Set("msg_id", ParentMessageID)
|
|
|
175 |
}
|
176 |
}
|
177 |
}
|
178 |
}
|
179 |
}
|
180 |
}
|
181 |
+
return Status, ParentMessageID, part
|
182 |
}
|
183 |
|
184 |
//goland:noinspection GoUnhandledErrorResult,SpellCheckingInspection
|