mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-28 00:14:21 +00:00
修改对话拼接逻辑
This commit is contained in:
@@ -94,10 +94,10 @@ class CompletionModel(ModelRequest):
|
|||||||
def msg_handle(self, msgs):
|
def msg_handle(self, msgs):
|
||||||
prompt = ''
|
prompt = ''
|
||||||
for msg in msgs:
|
for msg in msgs:
|
||||||
if msg['role'] == '':
|
if msg['role'] == 'assistant':
|
||||||
prompt = prompt + "{}\n".format(msg['content'])
|
prompt = prompt + "{}\n".format(msg['content'])
|
||||||
else:
|
else:
|
||||||
prompt = prompt + "{}:{}\n".format(msg['role'] if msg['role']!='system' else '你的回答要遵守此规则', msg['content'])
|
prompt = prompt + "{}:{}\n".format(msg['role'] , msg['content'])
|
||||||
return prompt
|
return prompt
|
||||||
|
|
||||||
def get_text(self):
|
def get_text(self):
|
||||||
|
|||||||
@@ -210,10 +210,7 @@ class Session:
|
|||||||
del (res_ans_spt[0])
|
del (res_ans_spt[0])
|
||||||
res_ans = '\n\n'.join(res_ans_spt)
|
res_ans = '\n\n'.join(res_ans_spt)
|
||||||
|
|
||||||
if config.completion_api_params['model'] in pkg.openai.modelmgr.CHAT_COMPLETION_MODELS:
|
self.prompt.append({'role':'assistant', 'content':res_ans})
|
||||||
self.prompt.append({'role':'assistant', 'content':res_ans})
|
|
||||||
elif config.completion_api_params['model'] in pkg.openai.modelmgr.COMPLETION_MODELS:
|
|
||||||
self.prompt.append({'role':'', 'content':res_ans})
|
|
||||||
|
|
||||||
if self.just_switched_to_exist_session:
|
if self.just_switched_to_exist_session:
|
||||||
self.just_switched_to_exist_session = False
|
self.just_switched_to_exist_session = False
|
||||||
|
|||||||
Reference in New Issue
Block a user