Tool Use
Give a function-calling Together model web search tools and run it sync, streaming, and async.
Together retired the source's meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo serverless model. Select a current chat model marked for function calling in the Together serverless catalog before running. See Together function calling.
"""Run `uv pip install ddgs` to install dependencies."""
import asyncio
from agno.agent import Agent
from agno.models.together import Together
from agno.tools.websearch import WebSearchTools
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
model=Together(id="meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo"),
tools=[WebSearchTools()],
markdown=True,
)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
# --- Sync ---
agent.print_response("Whats happening in France?")
# --- Sync + Streaming ---
agent.print_response("Whats happening in France?", stream=True)
# --- Async + Streaming ---
asyncio.run(agent.aprint_response("Whats happening in France?", stream=True))Run the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno ddgs openaiExport environment variables
export TOGETHER_API_KEY="your_together_api_key_here"
export TOGETHER_TOOL_MODEL_ID="your_current_together_tool_model_id_here"Use a function-calling model
Add import os, then replace Together(id="meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo") with Together(id=os.environ["TOGETHER_TOOL_MODEL_ID"]) in the saved file.
Run the example
Save the code above as tool_use.py, then run:
python tool_use.pyFull source: cookbook/90_models/together/tool_use.py