Skip to content

Commit

Permalink
fix streaming with groq
Browse files Browse the repository at this point in the history
  • Loading branch information
elisalimli committed Apr 30, 2024
1 parent f1a46d5 commit 192f730
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions libs/superagent/app/agents/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,19 +266,16 @@ async def _process_acompletion_response(self, res):
async def _process_completion_response(self, res):
tool_calls = []
new_messages = self.messages
output = ""

new_message = res.choices[0].message.dict()
if new_message.get("tool_calls"):
new_tool_calls = self._process_tool_calls(new_message)
tool_calls.extend(new_tool_calls)

new_messages.append(new_message)
content = new_message.get("content", "")
if content:
output += content
if self._stream_directly:
await self.streaming_callback.on_llm_new_token(content)
output = new_message.get("content", "")
if output and self._stream_directly:
await self._stream_by_lines(output)

return (tool_calls, new_messages, output)

Expand Down

0 comments on commit 192f730

Please sign in to comment.