Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions aidial_assistant/model/model_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,22 @@ async def agenerate(
else discarded_messages
)

choice = chunk.choices[0]
delta = choice.delta
if delta.content:
yield delta.content

if delta.tool_calls:
tool_calls_chunks.append(
[
tool_call_chunk.dict()
for tool_call_chunk in delta.tool_calls
]
)

if choice.finish_reason == "length":
finish_reason_length = True
if len(chunk.choices) > 0:
choice = chunk.choices[0]
delta = choice.delta
if delta.content:
yield delta.content

if delta.tool_calls:
tool_calls_chunks.append(
[
tool_call_chunk.dict()
for tool_call_chunk in delta.tool_calls
]
)

if choice.finish_reason == "length":
finish_reason_length = True

if finish_reason_length:
raise ReasonLengthException()
Expand Down