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