Skip to content

OpenAI returns null stream #2143

@GalDayan

Description

@GalDayan

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

Hi - we have this code below (Using Azure Open AI)
I didn't find any documentation or open bugs about it.
When chunks_stream is None? in what situation?
How can we avoid it?

NOTE: We are not near the rate limitations

chunks_stream = await self._client.chat.completions.create(
                model=self._model_name,
                messages=typing.cast(
                    typing.Iterable[ChatCompletionMessageParam], messages
                ),
                stream=True,
                **completion_config,
            )

            if chunks_stream is None:
                raise Exception(
                    f"OpenAI returned a null stream. Model: {self._model_name}"
                )

To Reproduce

chunks_stream = await self._client.chat.completions.create(
                model=self._model_name,
                messages=typing.cast(
                    typing.Iterable[ChatCompletionMessageParam], messages
                ),
                stream=True,
                **completion_config,
            )

            if chunks_stream is None:
                raise Exception(
                    f"OpenAI returned a null stream. Model: {self._model_name}"
                )

Code snippets

chunks_stream = await self._client.chat.completions.create(
                model=self._model_name,
                messages=typing.cast(
                    typing.Iterable[ChatCompletionMessageParam], messages
                ),
                stream=True,
                **completion_config,
            )

            if chunks_stream is None:
                raise Exception(
                    f"OpenAI returned a null stream. Model: {self._model_name}"
                )

OS

macOS

Python version

Python v3.11.5

Library version

openai v1.62

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions