Open krrishdholakia opened 4 months ago
Just tested this curl and it works for anthropic
curl --location 'https://api.anthropic.com/v1/messages' \
--header 'x-api-key: sk-hello-world' \
--header 'anthropic-version: 2023-06-01' \
--header 'content-type: application/json' \
--data '{
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What'\''s the weather in fahrenheit like in San Francisco?"
}
]
},
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "Certainly! I can help you get the current weather information for San Francisco in Fahrenheit. To do this, I'\''ll use the get_current_weather function. Let me fetch that information for you."
},
{
"type": "tool_use",
"id": "toolu_01EKkUnbSLJ11eCfBHPGeSkq",
"name": "get_current_weather",
"input": {
"location": "San Francisco, CA",
"unit": "fahrenheit"
}
}
]
},
{
"role": "user",
"content": [
{
"type": "tool_result",
"tool_use_id": "toolu_01EKkUnbSLJ11eCfBHPGeSkq",
"content": "{\"location\": \"San Francisco\", \"temperature\": \"72\", \"unit\": \"fahrenheit\"}"
}
]
}
],
"max_tokens": 4096,
"model": "claude-3-5-sonnet-20240620",
"tools": [
{
"name": "get_stock_price",
"description": "Get the current stock price for a given ticker symbol.",
"input_schema": {
"type": "object",
"properties": {
"ticker": {
"type": "string",
"description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
}
},
"required": ["ticker"]
}
}
]
}
'
The Feature
Allow user to configure a dummy tool call. Use this if provider requires
tools
to be passed in, if any of the blocks contains a tool_use object (e.g. Anthropic).Motivation, pitch
Motivation, pitch
Anthropic requires the tools to be passed in, on subsequent calls, otherwise it'll raise an error:
This causes issues when using the basic openai tool calling example -
Twitter / LinkedIn details
cc: @brian-tecton-ai