Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue #1367: Update unpacking logic to handle 13 values returned by _get_protocol_params #45

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
9 changes: 9 additions & 0 deletions metagpt/provider/openai_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,16 @@ async def _achat_completion_stream(self, messages: list[dict], timeout=USE_CONFI
)
usage = None
collected_messages = []
usage = None
collected_messages = []
async for chunk in response:
if chunk.usage is not None:
usage = CompletionUsage(**chunk.usage)
chunk_message = chunk.choices[0].delta.content or '' if chunk.choices else '' # extract the message
finish_reason = (
chunk.choices[0].finish_reason if chunk.choices and hasattr(chunk.choices[0], 'finish_reason') else None
)
log_llm_stream(chunk_message)
chunk_message = chunk.choices[0].delta.content or "" if chunk.choices else "" # extract the message
finish_reason = (
chunk.choices[0].finish_reason if chunk.choices and hasattr(chunk.choices[0], "finish_reason") else None
Expand Down