Vani7065 commited on
Commit
d6ff28d
·
verified ·
1 Parent(s): 82e4f38

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -12
app.py CHANGED
@@ -11,25 +11,19 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
11
  # --- Basic Agent Definition ---
12
  class BasicAgent:
13
  def __init__(self):
14
- print("Loading FLAN-T5 XL...")
15
  self.assistant_model = pipeline(
16
  "text2text-generation",
17
- model="google/flan-t5-xl",
18
- tokenizer="google/flan-t5-xl"
19
  )
20
 
21
  def __call__(self, question: str) -> str:
22
- print(f"Answering: {question}")
23
  try:
24
- # Format the prompt clearly
25
- prompt = f"Answer the following question concisely:\n{question}"
26
- response = self.assistant_model(prompt, max_length=150, do_sample=False)
27
- answer = response[0]["generated_text"]
28
- print(f"Answer: {answer}")
29
- return answer.strip()
30
  except Exception as e:
31
- print(f"Error: {e}")
32
- return f"Error generating answer: {e}"
33
 
34
 
35
  def run_and_submit_all(profile: gr.OAuthProfile | None):
 
11
  # --- Basic Agent Definition ---
12
  class BasicAgent:
13
  def __init__(self):
14
+ print("Loading model...")
15
  self.assistant_model = pipeline(
16
  "text2text-generation",
17
+ model="google/flan-t5-base",
18
+ tokenizer="google/flan-t5-base"
19
  )
20
 
21
  def __call__(self, question: str) -> str:
 
22
  try:
23
+ response = self.assistant_model(f"Answer this:\n{question}", max_length=100)
24
+ return response[0]["generated_text"].strip()
 
 
 
 
25
  except Exception as e:
26
+ return f"Error: {e}"
 
27
 
28
 
29
  def run_and_submit_all(profile: gr.OAuthProfile | None):