zasharepw77 commited on
Commit
9495824
·
1 Parent(s): e9b8947

тестпростого запуска 5

Browse files
Files changed (1) hide show
  1. app.py +19 -11
app.py CHANGED
@@ -1,22 +1,30 @@
1
- from smolagents import ToolCallingAgent, DuckDuckGoSearchTool, HfApiModel, LiteLLMModel
2
  import os
3
  import litellm
4
- litellm._turn_on_debug()
5
 
6
- #model=HfApiModel(token=os.getenv('hf_token'))
7
  os.environ['SAMBANOVA_API_KEY'] = os.getenv('sambanova_token')
 
 
8
  model = LiteLLMModel(
9
- model_id="sambanova/Qwen2.5-Coder-32B-Instruct",
10
  max_tokens=2096,
11
  temperature=0.1,
12
- # api_base="https://api.sambanova.ai/v1",
13
  )
14
 
 
15
  agent = ToolCallingAgent(
16
- tools=[DuckDuckGoSearchTool()],
17
- model=model)
18
-
19
- result = agent.run("Search for the best music recommendations for a party at the Wayne's mansion.")
20
 
21
- print("\n++++\nres:\n")
22
- print(result)
 
 
 
 
 
 
 
1
+ from smolagents import ToolCallingAgent, DuckDuckGoSearchTool, LiteLLMModel
2
  import os
3
  import litellm
4
+ litellm._turn_on_debug() # Enable debugging for litellm
5
 
6
+ # Set the API key for Sambanova
7
  os.environ['SAMBANOVA_API_KEY'] = os.getenv('sambanova_token')
8
+
9
+ # Create the model with explicit provider specification
10
  model = LiteLLMModel(
11
+ model_id="sambanova/Qwen2.5-Coder-32B-Instruct", # Explicitly specify the sambanova provider
12
  max_tokens=2096,
13
  temperature=0.1,
14
+ api_base="https://api.sambanova.ai/v1", # Specify the base URL for Sambanova, as in your working requests example
15
  )
16
 
17
+ # Create the agent
18
  agent = ToolCallingAgent(
19
+ tools=[DuckDuckGoSearchTool()],
20
+ model=model
21
+ )
 
22
 
23
+ # Run the agent with error handling
24
+ try:
25
+ result = agent.run("Search for the best music recommendations for a party at the Wayne's mansion.")
26
+ print("\n++++\nResult:\n")
27
+ print(result)
28
+ except Exception as e:
29
+ print(f"\n++++\nError occurred:\n")
30
+ print(f"{e}")