BerriAI / litellm

Call all LLM APIs using the OpenAI format. Use Bedrock, Azure, OpenAI, Cohere, Anthropic, Ollama, Sagemaker, HuggingFace, Replicate (100+ LLMs)
https://docs.litellm.ai/docs/
Other
10.05k stars 1.12k forks source link

[Bug]: Thread creation using the Assistants API is not working #4257

Closed amrecio closed 1 week ago

amrecio commented 1 week ago

What happened?

Thread creation using the Assistants API is not working in version 1.40.15 (the latest version as of this writing). The API returns a 500 error:

{
  "error": {
    "message": "litellm.APIConnectionError: Error code: 400 - {'error': {'message': \"Invalid 'metadata': too many properties. Expected an object with at most 16 properties, but got an object with 17 properties instead.\", 'type': 'invalid_request_error', 'param': 'metadata', 'code': 'object_above_max_properties'}}",
    "type": null,
    "param": null,
    "code": 500
  }
}

In version 1.39.6, the same request works fine.

After having a look at the code, I believe the issue could be in the add_litellm_data_to_request function in litellm/proxy/litellm_pre_call_utils.py. The function seems to be adding metadata to the OpenAI API request, which I'm not sure is the intended behavior.

Relevant log output

06:14:33 - LiteLLM Proxy:ERROR: proxy_server.py:4108 - litellm.proxy.proxy_server.create_threads(): Exception occured - litellm.APIConnectionError: Error code: 400 - {'error': {'message': "Invalid 'metadata': too many properties. Expected an object with at most 16 properties, but got an object with 17 properties instead.", 'type': 'invalid_request_error', 'param': 'metadata', 'code': 'object_above_max_properties'}}
Logging Details: logger_fn - None | callable(logger_fn) - False
INFO:     192.168.65.1:63946 - "POST /v1/threads HTTP/1.1" 500 Internal Server Error

Twitter / LinkedIn details

No response

ishaan-jaff commented 1 week ago

working on a fix

ishaan-jaff commented 1 week ago

Fixed + Added testing here @amrecio https://github.com/BerriAI/litellm/pull/4260

ishaan-jaff commented 1 week ago

@amrecio any chance we can hop on a call ? I'd love to learn how how we can improve litellm for you.

I reached out to you on Linkedin if DMs work. Sharing a link to my cal for your convenience: https://calendly.com/d/4mp-gd3-k5k/litellm-1-1-onboarding-chat