asaporta commited on
Commit
83a2d2d
·
verified ·
1 Parent(s): 1f1ce03

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -26
app.py CHANGED
@@ -11,36 +11,26 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
11
 
12
  # --- Basic Agent Definition ---
13
 
14
-
15
- model = HfApiModel(
16
- max_tokens=2096,
17
- temperature=0.5,
18
- model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud',# it is possible that this model may be overloaded
19
- custom_role_conversions=None,
20
- )
21
  class BasicAgent:
22
- def __init__(self):
 
23
  print("BasicAgent initialized.")
24
- self.agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=model)
25
-
26
- SYSTEM_PROMPT = """You are a general AI assistant. I will ask you a question. Report your thoughts, and
27
- finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
28
- YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated
29
- list of numbers and/or strings.
30
- If you are asked for a number, don't use comma to write your number neither use units such as $ or
31
- percent sign unless specified otherwise.
32
- If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the
33
- digits in plain text unless specified otherwise.
34
- If you are asked for a comma separated list, apply the above rules depending of whether the element
35
- to be put in the list is a number or a string.
36
- """
37
- self.agent.prompt_templates["system_prompt"] = self.agent.prompt_templates["system_prompt"] + SYSTEM_PROMPT
38
-
39
  def __call__(self, question: str) -> str:
40
  print(f"Agent received question (first 50 chars): {question[:50]}...")
41
- final_answer = self.agent.run(question)
42
- print(f"Agent returning final answer: {final_answer}")
43
- return final_answer
44
 
45
  def run_and_submit_all( profile: gr.OAuthProfile | None):
46
  """
 
11
 
12
  # --- Basic Agent Definition ---
13
 
14
+ # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
 
 
 
 
 
 
15
  class BasicAgent:
16
+ def __init__(self, openai_key):
17
+ self.openai_key = openai_key
18
  print("BasicAgent initialized.")
19
+ # Initialize the model
20
+ #model = HfApiModel()
21
+ model = OpenAIServerModel(model_id="gpt-4.1", api_key=self.openai_key)
22
+ # Initialize the search tool
23
+ search_tool = DuckDuckGoSearchTool()
24
+ # Initialize Agent
25
+ self.agent = CodeAgent(
26
+ model = model,
27
+ tools=[search_tool]
28
+ )
 
 
 
 
 
29
  def __call__(self, question: str) -> str:
30
  print(f"Agent received question (first 50 chars): {question[:50]}...")
31
+ fixed_answer =self.agent.run(question)
32
+ print(f"Agent returning fixed answer: {fixed_answer}")
33
+ return fixed_answer
34
 
35
  def run_and_submit_all( profile: gr.OAuthProfile | None):
36
  """