feat: 世界上最先进的调用流程

This commit is contained in:
RockChinQ
2023-08-04 18:41:04 +08:00
parent ec23bb5268
commit dd75f98d85
2 changed files with 23 additions and 15 deletions
+12 -8
View File
@@ -259,17 +259,21 @@ class Session:
finish_reason = resp['choices'][0]['finish_reason']
if resp['choices'][0]['message']['type'] == 'text': # 普通回复
res_text += resp['choices'][0]['message']['content']
if resp['choices'][0]['message']['role'] == "assistant" and resp['choices'][0]['message']['content'] != None: # 包含纯文本响应
res_text += resp['choices'][0]['message']['content'] + "\n"
total_tokens += resp['usage']['total_tokens']
pending_msgs.append(
{
"role": "assistant",
"content": resp['choices'][0]['message']['content']
}
)
msg = {
"role": "assistant",
"content": resp['choices'][0]['message']['content']
}
if 'function_call' in resp['choices'][0]['message']:
msg['function_call'] = resp['choices'][0]['message']['function_call']
pending_msgs.append(msg)
elif resp['choices'][0]['message']['type'] == 'function_call':
# self.prompt.append(