8000 OpenAI Integration: TypeError: object of type 'NotGiven' has no len() · Issue #4646 · getsentry/sentry-python · GitHub
[go: up one dir, main page]

Skip to content

OpenAI Integration: TypeError: object of type 'NotGiven' has no len() #4646

@divyanshu-shortloop

Description

@divyanshu-shortloop

How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.34.0

Steps to Reproduce

My code

stream = await self._client.chat.completions.create(
            messages=messages,
            model="gpt-4.1",
            tools = openai.NOT_GIVEN,
            stream_options = {"include_usage": True},
            stream = True,
            timeout = httpx.Timeout(self._conn_options.timeout),
            ** self._extra_kwargs
        )

Expected Result

OpenAI completion request call should work.

Actual Result

TypeError: object of type 'NotGiven' has no len()

Culprit:

if tools is not None and len(tools) > 0:

Default value of tools is also NotGiven in OpenAI SDK which is not None and doesn't have any len()

https://github.com/openai/openai-python/blob/48188cc8d5af8c8c4359f84848ea9e436739819f/src/openai/resources/chat/completions/completions.py#L147

Metadata

Metadata

Assignees

Labels

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0