spiceai / spiceai

A self-hostable CDN for databases. Spice provides a unified SQL query interface and portable runtime to locally materialize, accelerate, and query datasets across databases, data warehouses, and data lakes.
https://docs.spiceai.org
Apache License 2.0
1.85k stars 72 forks source link

Test external tools being returned for toolusing models #2818

Open Jeadie opened 2 hours ago

Jeadie commented 2 hours ago

Reported issue with users passing tools into LLMs and not getting used.

Jeadie commented 2 hours ago

With spicepod

models:
  - name: openai-with-spice
    from: openai:gpt-4o-2024-08-06
    params:
      spice_tools: auto
      openai_api_key: ${ secrets:SPICE_OPENAI_API_KEY }
      system_prompt:  Write a good response

And request

curlie "http://127.0.0.1:8090/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai-with-spice",
    "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"
}'

Get response

{
    "id": "chatcmpl-AB7v8NWg9pGWxP9wlo9j0XkkSWvCl",
    "choices": [
        {
            "index": 0,
            "message": {
                "content": null,
                "tool_calls": [
                    {
                        "id": "call_NmCeH0ANhHuLsWOPukaV8yD7",
                        "type": "function",
                        "function": {
                            "name": "get_current_weather",
                            "arguments": "{\"location\":\"Boston\",\"unit\":\"celsius\"}"
                        }
                    }
                ],
                "role": "assistant",
                "function_call": null
            },
            "finish_reason": "tool_calls",
            "logprobs": null
        }
    ],
    "created": 1727215418,
    "model": "gpt-4o-2024-08-06",
    "system_fingerprint": "fp_5050236cbd",
    "object": "chat.completion",
    "usage": {
        "prompt_tokens": 508,
        "completion_tokens": 20,
        "total_tokens": 528
    }
}