Open2

Agent Development Kit を触ってみる

薬缶薬缶

とりあえず、LiteLLMが使えるって事なので、いつもの環境に繋ぎ込む

  • .env file
ANTHROPIC_API_KEY=XXXXXXX
ANTHROPIC_API_BASE="http://0.0.0.0:4000/anthropic"

Cline の時の経験上、Anthropic API だと認識して貰えないとPromptCacheのパラメーターを渡して貰えない可能性を考慮して、EndPoint をLiteLLMのPass-through endpoints for Anthropic を利用する

  • agent.py
root_agent = Agent(
    name="weather_time_agent",
    model=LiteLlm(model='anthropic/claude-3-haiku-20240307'),
    description=(
        "Agent to answer questions about the time and weather in a city."
    ),
    instruction=(
        "I can answer your questions about the time and weather in a city."
    ),
    tools=[get_weather, get_current_time],
)
薬缶薬缶

ちゃんとパススルーとして受け取れている。

Request
{
    "model": "claude-3-haiku-20240307",
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "Hello"
                }
            ]
        }
    ],
    "tools": [
        {
            "name": "get_weather",
            "input_schema": {
                "type": "object",
                "properties": {
                    "city": {
                        "type": "string"
                    }
                }
            },
            "description": "Retrieves the current weather report for a specified city.\n\nArgs:\n    city (str): The name of the city for which to retrieve the weather report.\n\nReturns:\n    dict: status and result or error msg.\n"
        },
        {
            "name": "get_current_time",
            "input_schema": {
                "type": "object",
                "properties": {
                    "city": {
                        "type": "string"
                    }
                }
            },
            "description": "Returns the current time in a specified city.\n\nArgs:\n    city (str): The name of the city for which to retrieve the current time.\n\nReturns:\n    dict: status and result or error msg.\n"
        }
    ],
    "system": [
        {
            "type": "text",
            "text": "I can answer your questions about the time and weather in a city.\n\nYou are an agent. Your internal name is \"weather_time_agent\".\n\n The description about you is \"Agent to answer questions about the time and weather in a city.\""
        }
    ],
    "max_tokens": 4096
}

tools  と system, user をちゃんと使い分けてくれているけど、キャッシュコントロールは付与されていない。

セッションとか使わないとダメか?