lam-ho commited on
Commit
6906d29
·
verified ·
1 Parent(s): 74cc1b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -0
app.py CHANGED
@@ -14,10 +14,14 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
14
  class BasicAgent:
15
  def __init__(self):
16
  self.agent = create_agent()
 
17
  print("BasicAgent initialized.")
18
  def __call__(self, question: str) -> str:
19
  print(f"Agent received question (first 50 chars): {question[:50]}...")
 
 
20
  fixed_answer = self.agent.run(question)
 
21
  print(f"Agent returning fixed answer: {fixed_answer}")
22
  return fixed_answer
23
 
 
14
  class BasicAgent:
15
  def __init__(self):
16
  self.agent = create_agent()
17
+ self.question_dict = dict()
18
  print("BasicAgent initialized.")
19
  def __call__(self, question: str) -> str:
20
  print(f"Agent received question (first 50 chars): {question[:50]}...")
21
+ if question_dict[question]:
22
+ return question_dict[question]
23
  fixed_answer = self.agent.run(question)
24
+ question_dict[question] = fixed_answer
25
  print(f"Agent returning fixed answer: {fixed_answer}")
26
  return fixed_answer
27