Annessha18 commited on
Commit
80a17a9
·
verified ·
1 Parent(s): bc85200

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -10,16 +10,25 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
10
 
11
  # --- Basic Agent Definition ---
12
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
 
 
13
  class BasicAgent:
14
  def __init__(self):
15
  print("BasicAgent initialized.")
 
 
 
 
 
 
16
  def __call__(self, question: str) -> str:
17
  print(f"Agent received question (first 50 chars): {question[:50]}...")
18
- fixed_answer = "This is a default answer."
19
- print(f"Agent returning fixed answer: {fixed_answer}")
20
- return fixed_answer
 
 
21
 
22
- return fixed_answer
23
 
24
  def run_and_submit_all( profile: gr.OAuthProfile | None):
25
  """
 
10
 
11
  # --- Basic Agent Definition ---
12
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
13
+ from transformers import pipeline
14
+
15
  class BasicAgent:
16
  def __init__(self):
17
  print("BasicAgent initialized.")
18
+ self.generator = pipeline(
19
+ "text2text-generation",
20
+ model="google/flan-t5-base",
21
+ max_new_tokens=64
22
+ )
23
+
24
  def __call__(self, question: str) -> str:
25
  print(f"Agent received question (first 50 chars): {question[:50]}...")
26
+ prompt = f"Answer briefly and directly:\n{question}"
27
+ result = self.generator(prompt)[0]["generated_text"]
28
+ answer = result.strip()
29
+ print(f"Agent returning answer: {answer}")
30
+ return answer
31
 
 
32
 
33
  def run_and_submit_all( profile: gr.OAuthProfile | None):
34
  """