dvc890 commited on
Commit
4cd993e
·
1 Parent(s): 33372c8

Upload 2 files

Browse files
Files changed (2) hide show
  1. api/chatgpt/api.go +4 -4
  2. 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, 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
  }
@@ -139,11 +139,11 @@ func ContinueConversation(c *gin.Context, conversationID string, parentMessageID
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
  }
 
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
- ConversationID := ""
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
- ConversationID = result["conversation_id"].(string)
172
 
173
  if len(oldpart) == 0 {
174
- msg_id := message["id"].(string)
175
- c.Set("msg_id", msg_id)
176
  }
177
  }
178
  }
179
  }
180
  }
181
  }
182
- return Status, ConversationID, part
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