Spaces:
Runtime error
Runtime error
Update api/common.go
Browse files- api/common.go +14 -9
api/common.go
CHANGED
@@ -143,15 +143,20 @@ func HandleConversationResponse(c *gin.Context, resp *http.Response) (bool, stri
|
|
143 |
if status == "finished_successfully" {
|
144 |
logger.Info(fmt.Sprintf("HandleConversationResponse: %s", line))
|
145 |
logger.Info(fmt.Sprintf("status的值: %s", status))
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
155 |
}
|
156 |
}
|
157 |
}
|
|
|
143 |
if status == "finished_successfully" {
|
144 |
logger.Info(fmt.Sprintf("HandleConversationResponse: %s", line))
|
145 |
logger.Info(fmt.Sprintf("status的值: %s", status))
|
146 |
+
if message["metadata"] != nil {
|
147 |
+
metadata := message["metadata"].(map[string]interface{})
|
148 |
+
if metadata["finish_details"] != nil {
|
149 |
+
finishDetails := metadata["finish_details"].(map[string]interface{})
|
150 |
+
finishType := finishDetails["type"].(string)
|
151 |
+
if finishType == "max_tokens" {
|
152 |
+
content := message["content"].(map[string]interface{})
|
153 |
+
parts := content["parts"].([]interface{})
|
154 |
+
part = parts[0].(string)
|
155 |
+
logger.Info(fmt.Sprintf("finish_details中type的值: %s", finishType))
|
156 |
+
Status = true
|
157 |
+
ConversationID = result["conversation_id"].(string)
|
158 |
+
}
|
159 |
+
}
|
160 |
}
|
161 |
}
|
162 |
}
|