Skip to content

Commit

Permalink
add stashed reversion for tool call chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
pablonyx committed Sep 2, 2024
1 parent 009a8e7 commit ba8eb6f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions backend/danswer/llm/answering/answer.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,24 @@ def _raw_output_for_explicit_tool_calling_llms(
self.tools, self.force_use_tool
)
]
yield from self._process_llm_stream(

for message in self.llm.stream(
prompt=prompt,
tools=final_tool_definitions if final_tool_definitions else None,
tool_choice="required" if self.force_use_tool.force_use else None,
)
):
if isinstance(message, AIMessageChunk) and (
message.tool_call_chunks or message.tool_calls
):
if tool_call_chunk is None:
tool_call_chunk = message
else:
tool_call_chunk += message # type: ignore
else:
if message.content:
if self.is_cancelled:
return
yield cast(str, message.content)

if not tool_call_chunk:
return # no tool call needed
Expand Down

0 comments on commit ba8eb6f

Please sign in to comment.