SolshineMisfit commited on
Commit
d139b43
·
verified ·
1 Parent(s): d6af4dd

Various little fixes

Browse files

Fixed:
Missing import os and from openai import OpenAI for the Perplexity API calls
Missing Perplex_Assistant_Prompt variable
Syntax error in the tools parameter of CodeAgent (incorrect list format)
Improper formatting of tool arguments in the agent tools list

Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -1,12 +1,17 @@
1
- from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
  import datetime
3
  import requests
4
  import pytz
5
  import yaml
 
 
6
  from tools.final_answer import FinalAnswerTool
7
 
8
  from Gradio_UI import GradioUI
9
 
 
 
 
10
  #@weave.op()
11
  def tracked_perplexity_call(prompt: str, system_messages: str, model_name: str = "sonar-pro", assistant_meta: bool = False):
12
  """Enhanced Perplexity API call with explicit model tracking."""
@@ -27,8 +32,7 @@ def tracked_perplexity_call(prompt: str, system_messages: str, model_name: str =
27
 
28
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
29
  @tool
30
- def Sonar_Web_Search_Tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
31
- #Keep this format for the description / args / args description but feel free to modify the tool
32
  """A tool that accesses Perplexity Sonar to search the web when the answer requires or would benefit from a real world web reference.
33
  Args:
34
  arg1: User Prompt
@@ -63,10 +67,10 @@ final_answer = FinalAnswerTool()
63
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
64
 
65
  model = HfApiModel(
66
- max_tokens=2096,
67
- temperature=0.5,
68
- model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
69
- custom_role_conversions=None,
70
  )
71
 
72
 
@@ -78,7 +82,7 @@ with open("prompts.yaml", 'r') as stream:
78
 
79
  agent = CodeAgent(
80
  model=model,
81
- tools=[final_answer], [Sonar_Web_Search_Tool], ## add your tools here (don't remove final answer)
82
  max_steps=6,
83
  verbosity_level=1,
84
  grammar=None,
@@ -88,5 +92,4 @@ agent = CodeAgent(
88
  prompt_templates=prompt_templates
89
  )
90
 
91
-
92
  GradioUI(agent).launch()
 
1
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
2
  import datetime
3
  import requests
4
  import pytz
5
  import yaml
6
+ import os
7
+ from openai import OpenAI
8
  from tools.final_answer import FinalAnswerTool
9
 
10
  from Gradio_UI import GradioUI
11
 
12
+ # Define the Perplexity system prompt
13
+ Perplex_Assistant_Prompt = """You are a helpful AI assistant that searches the web for accurate information."""
14
+
15
  #@weave.op()
16
  def tracked_perplexity_call(prompt: str, system_messages: str, model_name: str = "sonar-pro", assistant_meta: bool = False):
17
  """Enhanced Perplexity API call with explicit model tracking."""
 
32
 
33
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
34
  @tool
35
+ def Sonar_Web_Search_Tool(arg1: str, arg2: str) -> str:
 
36
  """A tool that accesses Perplexity Sonar to search the web when the answer requires or would benefit from a real world web reference.
37
  Args:
38
  arg1: User Prompt
 
67
  # model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
68
 
69
  model = HfApiModel(
70
+ max_tokens=2096,
71
+ temperature=0.5,
72
+ model_id='Qwen/Qwen2.5-Coder-32B-Instruct', # it is possible that this model may be overloaded
73
+ custom_role_conversions=None,
74
  )
75
 
76
 
 
82
 
83
  agent = CodeAgent(
84
  model=model,
85
+ tools=[final_answer, Sonar_Web_Search_Tool, get_current_time_in_timezone, image_generation_tool], # Fixed list formatting
86
  max_steps=6,
87
  verbosity_level=1,
88
  grammar=None,
 
92
  prompt_templates=prompt_templates
93
  )
94
 
 
95
  GradioUI(agent).launch()