Smolagentsは、強力なエージェントアプリケーションを構築するための最小限の抽象化を提供するシンプルなフレームワークです。OpenAI、Hugging Face Transformers、Anthropicなど、複数のLLMプロバイダーをサポートしています。Weaveは自動的にトレースをキャプチャします Smolagents。追跡を開始するには、weave.init()を呼び出し、通常通りライブラリを使用します。
import weavefrom smolagents import DuckDuckGoSearchTool, OpenAIServerModel, ToolCallingAgent# Initialize Weaveweave.init(project_name="smolagents")# Define your LLM provider supported by Smolagentsmodel = OpenAIServerModel(model_id="gpt-4o")# Define a DuckDuckGo web search tool based on your querysearch_tool = DuckDuckGoSearchTool()# Define a tool-calling agentagent = ToolCallingAgent(tools=[search_tool], model=model)answer = agent.run( "Get me just the title of the page at url 'https://wandb.ai/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?")
コードサンプルを実行したら、Weaveプロジェクトダッシュボードに移動してトレースを表示します。
このページは役に立ちましたか?
Assistant
Responses are generated using AI and may contain mistakes.