zasharepw77 commited on
Commit
8464f47
·
1 Parent(s): 6e437ce

Step call func

Browse files
Files changed (1) hide show
  1. app.py +6 -30
app.py CHANGED
@@ -1,6 +1,5 @@
1
  from smolagents import ToolCallingAgent, CodeAgent, DuckDuckGoSearchTool, LiteLLMModel
2
  import os
3
- import requests
4
  #import litellm
5
  #litellm._turn_on_debug() # Enable debugging for litellm
6
 
@@ -14,40 +13,17 @@ model = LiteLLMModel(
14
  temperature=0.5,
15
  api_base="https://api.sambanova.ai/v1", # Specify the base URL for Sambanova, as in your working requests example
16
  )
17
- print(dir(model))
18
 
19
- # Создание модели с обработкой лимитов
20
- def model_call(query, tools_to_call_from=None, stop_sequences=None):
21
- print(query)
22
- print(tools_to_call_from)
23
- print(stop_sequences)
24
- try:
25
- url = "https://api.sambanova.ai/v1/chat/completions" # Проверьте, что это правильная конечная точка
26
- headers = {
27
- "Authorization": f"Bearer {os.getenv('sambanova_token')}",
28
- "Content-Type": "application/json"
29
- }
30
- data = {
31
- "model": "Qwen2.5-Coder-32B-Instruct",
32
- "messages": query,
33
- "tools": tools_to_call_from,
34
- "max_tokens": 2096
35
- }
36
-
37
- response = requests.post(url, headers=headers, json=data)
38
- print(response.status_code)
39
- print(response.text)
40
- return response.choices[0].message.content
41
- except openai.RateLimitError:
42
- time.sleep(60) # Ждем 60 секунд перед повторной попыткой
43
- return model_call(query) # Рекурсивный вызов
44
- except Exception as e:
45
- return f"An unexpected error occurred: {str(e)}"
46
 
47
  # Create the agent
48
  agent = ToolCallingAgent(
49
  tools=[DuckDuckGoSearchTool()],
50
- model=model_call
 
51
  )
52
 
53
  # Когда запуск идет через streamlingt то ответы переводятс в json автоматом
 
1
  from smolagents import ToolCallingAgent, CodeAgent, DuckDuckGoSearchTool, LiteLLMModel
2
  import os
 
3
  #import litellm
4
  #litellm._turn_on_debug() # Enable debugging for litellm
5
 
 
13
  temperature=0.5,
14
  api_base="https://api.sambanova.ai/v1", # Specify the base URL for Sambanova, as in your working requests example
15
  )
 
16
 
17
+ my_paused =
18
+ def my_paused(step_log: ActionStep, agent: CodeAgent) -> None:
19
+ sleep(5.0)
20
+ return
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  # Create the agent
23
  agent = ToolCallingAgent(
24
  tools=[DuckDuckGoSearchTool()],
25
+ model=model,
26
+ step_callbacks=[my_paused],
27
  )
28
 
29
  # Когда запуск идет через streamlingt то ответы переводятс в json автоматом