Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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("
|
| 15 |
-
self.assistant_model = pipeline(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
def __call__(self, question: str) -> str:
|
| 18 |
-
print(f"
|
| 19 |
try:
|
| 20 |
-
response = self.assistant_model(question, max_length=
|
| 21 |
answer = response[0]["generated_text"]
|
| 22 |
-
print(f"
|
| 23 |
return answer.strip()
|
| 24 |
except Exception as e:
|
| 25 |
-
print(f"Error
|
| 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 |
|