Vani7065 commited on
Commit
ac98948
·
verified ·
1 Parent(s): 82ead94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -11,18 +11,22 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
11
  # --- Basic Agent Definition ---
12
  class BasicAgent:
13
  def __init__(self):
14
- print("Initializing BasicAgent with a lightweight transformer model...")
15
- self.assistant_model = pipeline("text-generation", model="sshleifer/tiny-gpt2", device=-1)
 
 
 
 
16
 
17
  def __call__(self, question: str) -> str:
18
- print(f"Agent received question: {question}")
19
  try:
20
- response = self.assistant_model(question, max_length=40, do_sample=False, num_return_sequences=1)
21
  answer = response[0]["generated_text"]
22
- print(f"Generated answer: {answer}")
23
  return answer.strip()
24
  except Exception as e:
25
- print(f"Error during model generation: {e}")
26
  return f"Error generating answer: {e}"
27
 
28
 
 
11
  # --- Basic Agent Definition ---
12
  class BasicAgent:
13
  def __init__(self):
14
+ print("Loading FLAN-T5 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
+ print(f"Answering: {question}")
23
  try:
24
+ response = self.assistant_model(question, max_length=128, do_sample=False)
25
  answer = response[0]["generated_text"]
26
+ print(f"Answer: {answer}")
27
  return answer.strip()
28
  except Exception as e:
29
+ print(f"Error: {e}")
30
  return f"Error generating answer: {e}"
31
 
32