1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AntropicのFunction Callingを試してみた(まだ繋がらない。。)

Last updated at Posted at 2024-04-05

AnthropicがFunctionCallingをBeta版として公開したので試してみた
https://docs.anthropic.com/claude/docs/tool-use

import anthropic

client = anthropic.Anthropic()

response = client.beta.tools.messages.create(
    model="claude-3-opus-20240229",
    max_tokens=1024,
    tools=[
        {
            "name": "get_location",
            "description": "Get the current user location based on their IP address. This tool has no parameters or arguments.",
            "input_schema": {
                "type": "object",
                "properties": {}
            }
        },
        {
            "name": "get_weather",
            "description": "Get the current weather in a given location",
            "input_schema": {
                "type": "object",
                "properties": {
                    "location": {
                        "type": "string",
                        "description": "The city and state, e.g. San Francisco, CA"
                    },
                    "unit": {
                        "type": "string",
                        "enum": ["celsius", "fahrenheit"],
                        "description": "The unit of temperature, either 'celsius' or 'fahrenheit'"
                    }
                },
                "required": ["location"]
            }
        }
    ],
    messages=[{
   		  "role": "user",
    	  "content": "What's the weather like where I am?"
    }]
)

print(response)

API_KEYを環境変数に設定しておく(ご自身のKEYをおつかいください)

export ANTHROPIC_API_KEY=sk-ant-api03-XXXXXX

が、結果。。

anthropic.InternalServerError: Error code: 529 - 
{'type': 'error', 'error': {'type': 'overloaded_error', 'message': 'Overloaded'}}

みんな使いまくっているの繋がらないー

繋がったら続きを書く。。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?