Skip to content

Commit

Permalink
fixup! fix message merging strategy to prevent error when multi-turn …
Browse files Browse the repository at this point in the history
…tool calling.
  • Loading branch information
root committed Jan 25, 2025
1 parent 7a75fe0 commit d682b63
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/llm/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ def _infer_model(pt_engine, system=None, messages=None):

class TestTemplate(unittest.TestCase):

def test_template(self):
pt_engine = PtEngine('Qwen/Qwen2.5-3B-Instruct-GPTQ-Int4')
response = _infer_model(pt_engine)
pt_engine.default_template.template_backend = 'jinja'
response2 = _infer_model(pt_engine)
assert response == response2

def test_tool_message_join(self):
from copy import deepcopy
Expand Down Expand Up @@ -72,7 +78,7 @@ def test_tool_message_join(self):
for tool_prompt in ('react_en', 'qwen'):
tool_prompt = 'react_en'
test_messages = deepcopy(messages)
obs_word = get_tools_keyword(tool_prompt).get("observation")
obs_word = get_tools_keyword(tool_prompt).get('observation')
test_messages[1]['content'] = f'{obs_word}'
test_messages[2]['content'] = 'first_round_result\n'
test_messages[3]['content'] = f'{obs_word}'
Expand Down

0 comments on commit d682b63

Please sign in to comment.