Skip to content

Regression: ChatCompletionToolParam no longer a valid type in 1.99.2 #2525

@markbackman

Description

@markbackman

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

This bug fix commit introduces a breaking change in 1.99.2:
657f551

Use of the previous type ChatCompletionToolParam emits an error:

error processing frame: Cannot instantiate typing.Union

Rather than break, can their be a migration path to the new ChatCompletionFunctionToolParam type?

To Reproduce

Define a tool as:

    tools = [
        ChatCompletionToolParam(
            type="function",
            function={
                "name": "switch_voice",
                "description": "Switch your voice only when the user asks you to",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "voice": {
                            "type": "string",
                            "description": "The voice the user wants you to use",
                        },
                    },
                    "required": ["voice"],
                },
            },
        )
    ]

Run application using this tool definition.

Code snippets

OS

macOS

Python version

Python 3.12.8

Library version

1.99.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions