dlaima commited on
Commit
0868219
·
verified ·
1 Parent(s): 7cfb3a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -19,10 +19,10 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
19
 
20
  class MyAgent:
21
  def __init__(self):
22
- # Initialize model with system prompt
23
  self.model = OpenAIServerModel(
24
  model_id="gpt-4",
25
- system_message=SYSTEM_PROMPT
26
  )
27
  self.agent = CodeAgent(
28
  tools=[DuckDuckGoSearchTool()],
@@ -30,8 +30,12 @@ class MyAgent:
30
  )
31
 
32
  def __call__(self, question: str) -> str:
33
- # Run agent on the question
34
- return self.agent.run(question)
 
 
 
 
35
 
36
  def run_and_submit_all(profile: gr.OAuthProfile | None):
37
  """
 
19
 
20
  class MyAgent:
21
  def __init__(self):
22
+ # Fix: use system_prompt instead of system_message
23
  self.model = OpenAIServerModel(
24
  model_id="gpt-4",
25
+ system_prompt=SYSTEM_PROMPT
26
  )
27
  self.agent = CodeAgent(
28
  tools=[DuckDuckGoSearchTool()],
 
30
  )
31
 
32
  def __call__(self, question: str) -> str:
33
+ try:
34
+ return self.agent.run(question)
35
+ except Exception as e:
36
+ import traceback
37
+ traceback.print_exc()
38
+ return f"AGENT ERROR: {e}"
39
 
40
  def run_and_submit_all(profile: gr.OAuthProfile | None):
41
  """