diff --git a/sandbox/qwen-fc.py b/sandbox/qwen-fc.py index dd3839e..e315012 100644 --- a/sandbox/qwen-fc.py +++ b/sandbox/qwen-fc.py @@ -88,13 +88,13 @@ async def stream(self, messages: list[ChatMessage], functions: list[AIFunction] yield elem[: elem.index(self.tool_call_start)] in_tool_call = True has_seen_tool_call = True - # if we see the end of a tool call, start yielding again - if self.tool_call_end in elem: - in_tool_call = False - yield elem[elem.index(self.tool_call_end) + len(self.tool_call_end) :] # otherwise yield the string if not in_tool_call: yield elem.removesuffix(self.eos) + # if we see the end of a tool call, start yielding again + if self.tool_call_end in elem: + in_tool_call = False + yield elem[elem.index(self.tool_call_end) + len(self.tool_call_end) :].removesuffix(self.eos) else: # save the inner completion inner_completion = elem @@ -122,6 +122,7 @@ async def stream(self, messages: list[ChatMessage], functions: list[AIFunction] completion_tokens=completion_tokens, ) + model = HuggingEngine(model_id="Qwen/Qwen2.5-72B-Instruct") engine = QwenFunctionCallingAdapter(model) ai = MyKani(engine)