Skip to content

chore: export more types#2176

Merged
stainless-app[bot] merged 1 commit into
generatedfrom
chore-export-more-types
Mar 11, 2025
Merged

chore: export more types#2176
stainless-app[bot] merged 1 commit into
generatedfrom
chore-export-more-types

Conversation

@stainless-app

@stainless-app stainless-app Bot commented Mar 11, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@stainless-app stainless-app Bot requested a review from a team as a code owner March 11, 2025 13:17
@stainless-app stainless-app Bot merged commit 44b61bd into generated Mar 11, 2025
@stainless-app stainless-app Bot deleted the chore-export-more-types branch March 11, 2025 13:17
stainless-app Bot added a commit that referenced this pull request Mar 11, 2025
@stainless-app stainless-app Bot mentioned this pull request Mar 11, 2025
stainless-app Bot added a commit that referenced this pull request Mar 11, 2025
@PHclaw

PHclaw commented Apr 29, 2026

Copy link
Copy Markdown

For the streaming response type inconsistency:

When using stream=True, the choices[0].delta.content can be None on the first and last chunks. Fix:

async def stream_chat(client, messages):
    response = await client.chat.completions.create(
        model='gpt-4',
        messages=messages,
        stream=True
    )
    collected = []
    async for chunk in response:
        delta = chunk.choices[0].delta
        if delta.content is not None:
            collected.append(delta.content)
            yield delta.content
    return ''.join(collected)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants