Skip to content

Commit

Permalink
fix: some '\n' error
Browse files Browse the repository at this point in the history
  • Loading branch information
gaozixiang committed Nov 14, 2024
1 parent 5deb75a commit da94e56
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lmdeploy/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1010,19 +1010,19 @@ def messages2prompt(self,
and message.get('tool_calls') is None)):
ret += f"{box_map[message['role']]}{message['content']}{self.eoh}"
elif message['role'] == 'assistant':
ret += f'{self.assistant}'
ret += f'<|im_start|>assistant'
if message.get('content') is not None:
ret += f"\n{message['content']}"
if message.get('tool_calls') is not None:
tool_calls = message['tool_calls']
for tool_call in tool_calls:
if tool_call.get('function') is not None:
tool_call = tool_call['function']
ret += f'\n<tool_call>\n{{"name": "{tool_call["name"]}, "arguments": {json.dumps(tool_call["arguments"], ensure_ascii=False)}"\n</tool_call>}}'
ret += f'<tool_call>\n{{"name": "{tool_call["name"]}, "arguments": {json.dumps(tool_call["arguments"], ensure_ascii=False)}}}"\n</tool_call>\n'
if message['role'] == 'tool':
if index == 0 or messages[index - 1]['role'] != 'tool':
ret += f'{self.user}'
ret += f"\n<tool_response>\n{message['name']}:{message['content']}\n</tool_response>"
ret += f"<tool_response>\n{message['name']}:{message['content']}\n</tool_response>\n"
if index == len(messages) - 1 or messages[index +
1]['role'] != 'tool':
ret += f'{self.eoh}'
Expand Down

0 comments on commit da94e56

Please sign in to comment.