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

[Bug]: function_to_dict() fails enums #8539

Open
vlerenc opened this issue Feb 14, 2025 · 0 comments
Open

[Bug]: function_to_dict() fails enums #8539

vlerenc opened this issue Feb 14, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@vlerenc
Copy link

vlerenc commented Feb 14, 2025

What happened?

While trying out https://docs.litellm.ai/docs/completion/function_call#using-function_to_dict, i.e. the original example, I noticed that the enum is not rendered as such:

    unit : str {'celsius', 'fahrenheit'}
        Temperature unit

Yields:

            "unit": {
                "type": "string",
                "description": "Temperature unit"
            }

When I remove the str, it is rendered as enum, but weirdly as an array in a string (and OpenAI complains):

    unit : {'celsius', 'fahrenheit'}
        Temperature unit

Yields:

            "unit": {
                "type": "string",
                "description": "Temperature unit",
                "enum": "['celsius', 'fahrenheit']"
            }

Notice the " around the [], i.e. the array/list is constructed correctly, but instead of remaining an array/list, it became a string in the map/dict.

I need to manually "fix" the enum like this to finally succeed:

            "unit": {
                "type": "string",
                "description": "Temperature unit",
                "enum": ["celsius", "fahrenheit"]
            }

If I don't do this, OpenAI complains with is not of type 'array' and the only reason the example works is because it never really rendered the unit as enum.

Relevant log output

Are you a ML Ops Team?

No

What LiteLLM version are you on ?

v1.61.3

Twitter / LinkedIn details

No response

@vlerenc vlerenc added the bug Something isn't working label Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant