BerriAI / litellm

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

[Feature]: Proxy OpenAI functions to Claude tools #4544

Closed delfer closed 3 weeks ago

delfer commented 3 weeks ago

The Feature

OpenAI support functions. Claude support the same feature - tools. LiteLLM also supports using tools. It would be nice to to proxy Functions into Tool. Now it's drops by "LITELLM_DROP_PARAMS=True"

Motivation, pitch

I'am using telegram bot https://github.com/n3d1117/chatgpt-telegram-bot . It's very nice and have a lot of functions, but works only with OpenAI API. Proxy can help.

Twitter / LinkedIn details

No response

krrishdholakia commented 3 weeks ago

do you mean claude?

We already support tool calling for claude @delfer https://docs.litellm.ai/docs/providers/anthropic#usage---function-calling

delfer commented 3 weeks ago

@krrishdholakia Claude, sure) LiteLLM supports tool calling, but does not support Proxy functions calls to tools calls.

krrishdholakia commented 3 weeks ago

What do you mean? @delfer

Here's a curl for tool calling with litellm

curl -X POST 'http://0.0.0.0:4000/chat/completions' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk-Ot5iy8bg8bzuUrLkvURLiA' \
-D '{
  "model": "anthropic-claude-3",
  "messages": [
    {
      "role": "user",
      "content": "What'\''s the weather like in Boston today?"
    }
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_current_weather",
        "description": "Get the current weather in a given location",
        "parameters": {
          "type": "object",
          "properties": {
            "location": {
              "type": "string",
              "description": "The city and state, e.g. San Francisco, CA"
            },
            "unit": {
              "type": "string",
              "enum": ["celsius", "fahrenheit"]
            }
          },
          "required": ["location"]
        }
      }
    }
  ],
  "tool_choice": "auto",
}'

Where would it have been helpful to see this?