Skip to content

Commit

Permalink
dev: update qwen fc
Browse files Browse the repository at this point in the history
  • Loading branch information
zhudotexe committed Nov 14, 2024
1 parent 2342107 commit 42d5244
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sandbox/qwen-fc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 42d5244

Please sign in to comment.