Back to Icho Home Icho v0.8.0

Tool Calling & Function Calling

Icho captures tool call definitions (tools, tool_choice), tool call outputs (tool_calls, function_call), and complete tool interaction histories across OpenAI, Anthropic, and LangChain models.

OpenAI Tool Calling Example:

from openai import OpenAI
from icho import cassette
from icho.llm.adapters import OpenAIAdapter

client = OpenAI()
adapter = OpenAIAdapter()

tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Get location weather",
        "parameters": { "type": "object", "properties": {"city": {"type": "string"}} }
    }
}]

# 1. Record tool call interaction
with cassette("tests/cassettes/tools_flow", mode="record", adapter=adapter):
    response = client.chat.completions.create( 
        model="gpt-4o",
        messages=[{"role": "user", "content": "What's the weather in Tokyo?"}],
        tools=tools
    )

# 2. Replay instantly from cassette
with cassette("tests/cassettes/tools_flow", mode="replay", adapter=adapter):
    replayed = client.chat.completions.create(model="gpt-4o", messages=[...], tools=tools)
    print(replayed.choices[0].message.tool_calls[0].function.arguments)