Weave は関数およびモデルの各 invocation をログし、Weave の Web インターフェースで確認できるようにします。
import weavefrom smolagents import DuckDuckGoSearchTool, OpenAIServerModel, ToolCallingAgent# Weave を初期化しますweave.init(project_name="smolagents")# Smolagents がサポートする LLM プロバイダを定義しますmodel = OpenAIServerModel(model_id="gpt-4o")# クエリに基づいて検索を行う DuckDuckGo の Web 検索ツールを定義しますsearch_tool = DuckDuckGoSearchTool()# ツール呼び出しエージェントを定義しますagent = ToolCallingAgent(tools=[search_tool], model=model)answer = agent.run( "Get me just the title of the page at url 'https://forge.coreweave.com/wandb/geekyrakshit/story-illustration/reports/Building-a-GenAI-assisted-automatic-story-illustrator--Vmlldzo5MTYxNTkw'?")
from typing import Optionalimport weavefrom smolagents import OpenAIServerModel, ToolCallingAgent, toolweave.init(project_name="smolagents")@tooldef get_weather(location: str, celsius: Optional[bool] = False) -> str: """ Get the weather in the next few days for a given location. Args: location: The location. celsius: Whether to use Celsius for temperature. """ return f"The weather in {location} is sunny with temperatures around 7°C."model = OpenAIServerModel(model_id="gpt-4o")agent = ToolCallingAgent(tools=[get_weather], model=model)answer = agent.run("What is the weather in Tokyo?")