Spaces:
Runtime error
Runtime error
Update api/chatgpt/api.go
Browse files- api/chatgpt/api.go +9 -3
api/chatgpt/api.go
CHANGED
|
@@ -73,17 +73,20 @@ func CreateConversation(c *gin.Context) {
|
|
| 73 |
return
|
| 74 |
}
|
| 75 |
|
| 76 |
-
defer resp.Body.Close()
|
| 77 |
if resp.StatusCode != http.StatusOK {
|
| 78 |
responseMap := make(map[string]interface{})
|
| 79 |
json.NewDecoder(resp.Body).Decode(&responseMap)
|
| 80 |
c.AbortWithStatusJSON(resp.StatusCode, responseMap)
|
|
|
|
| 81 |
return
|
| 82 |
}
|
| 83 |
c.Set("oldpart", "")
|
| 84 |
Status, ConversationID, part := api.HandleConversationResponse(c, resp)
|
| 85 |
if Status {
|
|
|
|
| 86 |
ContinueConversation(c, ConversationID, request.ParentMessageID, request.Model, part)
|
|
|
|
|
|
|
| 87 |
}
|
| 88 |
}
|
| 89 |
|
|
@@ -126,20 +129,23 @@ func ContinueConversation(c *gin.Context, conversationID string, parentMessageID
|
|
| 126 |
return
|
| 127 |
}
|
| 128 |
|
| 129 |
-
defer resp.Body.Close()
|
| 130 |
if resp.StatusCode != http.StatusOK {
|
| 131 |
-
logger.Info(
|
| 132 |
responseMap := make(map[string]interface{})
|
| 133 |
json.NewDecoder(resp.Body).Decode(&responseMap)
|
| 134 |
c.AbortWithStatusJSON(resp.StatusCode, responseMap)
|
|
|
|
| 135 |
return
|
| 136 |
}
|
| 137 |
|
| 138 |
c.Set("oldpart", oldpart)
|
| 139 |
Status, ConversationID, part := api.HandleConversationResponse(c, resp)
|
| 140 |
if Status {
|
|
|
|
| 141 |
logger.Info(fmt.Sprintf("part的值: %s", part))
|
| 142 |
ContinueConversation(c, ConversationID, request.ParentMessageID, request.Model, part)
|
|
|
|
|
|
|
| 143 |
}
|
| 144 |
}
|
| 145 |
|
|
|
|
| 73 |
return
|
| 74 |
}
|
| 75 |
|
|
|
|
| 76 |
if resp.StatusCode != http.StatusOK {
|
| 77 |
responseMap := make(map[string]interface{})
|
| 78 |
json.NewDecoder(resp.Body).Decode(&responseMap)
|
| 79 |
c.AbortWithStatusJSON(resp.StatusCode, responseMap)
|
| 80 |
+
resp.Body.Close()
|
| 81 |
return
|
| 82 |
}
|
| 83 |
c.Set("oldpart", "")
|
| 84 |
Status, ConversationID, part := api.HandleConversationResponse(c, resp)
|
| 85 |
if Status {
|
| 86 |
+
resp.Body.Close()
|
| 87 |
ContinueConversation(c, ConversationID, request.ParentMessageID, request.Model, part)
|
| 88 |
+
} else {
|
| 89 |
+
resp.Body.Close()
|
| 90 |
}
|
| 91 |
}
|
| 92 |
|
|
|
|
| 129 |
return
|
| 130 |
}
|
| 131 |
|
|
|
|
| 132 |
if resp.StatusCode != http.StatusOK {
|
| 133 |
+
logger.Info("ContinueConversationRequestStatusCode != http.StatusOK " + string(rune(resp.StatusCode)))
|
| 134 |
responseMap := make(map[string]interface{})
|
| 135 |
json.NewDecoder(resp.Body).Decode(&responseMap)
|
| 136 |
c.AbortWithStatusJSON(resp.StatusCode, responseMap)
|
| 137 |
+
resp.Body.Close()
|
| 138 |
return
|
| 139 |
}
|
| 140 |
|
| 141 |
c.Set("oldpart", oldpart)
|
| 142 |
Status, ConversationID, part := api.HandleConversationResponse(c, resp)
|
| 143 |
if Status {
|
| 144 |
+
resp.Body.Close()
|
| 145 |
logger.Info(fmt.Sprintf("part的值: %s", part))
|
| 146 |
ContinueConversation(c, ConversationID, request.ParentMessageID, request.Model, part)
|
| 147 |
+
} else {
|
| 148 |
+
resp.Body.Close()
|
| 149 |
}
|
| 150 |
}
|
| 151 |
|