zasharepw77
Tool calling 7
d56d7b0
raw
history blame
1.19 kB
from smolagents import ToolCallingAgent, CodeAgent, DuckDuckGoSearchTool, LiteLLMModel
import os
#import litellm
#litellm._turn_on_debug() # Enable debugging for litellm
# Set the API key for Sambanova
os.environ['SAMBANOVA_API_KEY'] = os.getenv('sambanova_token')
# Create the model with explicit provider specification
model = LiteLLMModel(
model_id="sambanova/Meta-Llama-3.1-405B-Instruct", # Explicitly specify the sambanova provider
max_tokens=2096,
temperature=0.5,
api_base="https://api.sambanova.ai/v1", # Specify the base URL for Sambanova, as in your working requests example
)
# Create the agent
agent = ToolCallingAgent(
tools=[DuckDuckGoSearchTool()],
model=model
)
# Когда запуск идет через streamlingt то ответы переводятс в json автоматом
#agent = CodeAgent(
# tools=[DuckDuckGoSearchTool()],
# model=model
#)
# Run the agent with error handling
try:
result = agent.run("Search for the best music recommendations for a party at the Wayne's mansion.")
print("\n++++\nResult:\n")
print(result)
except Exception as e:
print(f"\n++++\nError occurred:\n")
print(f"{e}")