Update app.py
Browse files
app.py
CHANGED
|
@@ -12,16 +12,16 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 12 |
# --- Basic Agent Definition ---
|
| 13 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 14 |
class BasicAgent:
|
| 15 |
-
|
| 16 |
print("Loading Hugging Face model...")
|
| 17 |
self.pipeline = pipeline(
|
| 18 |
"text-generation",
|
| 19 |
-
model="HuggingFaceH4/zephyr-7b-beta",
|
| 20 |
max_new_tokens=256
|
| 21 |
)
|
| 22 |
print("Model loaded.")
|
| 23 |
|
| 24 |
-
def __call__(self, question):
|
| 25 |
print(f"Received question: {question[:60]}...")
|
| 26 |
prompt = f"Answer the question clearly and concisely:\n{question.strip()}\nAnswer:"
|
| 27 |
response = self.pipeline(prompt)[0]["generated_text"]
|
|
@@ -32,6 +32,7 @@ class BasicAgent:
|
|
| 32 |
|
| 33 |
|
| 34 |
|
|
|
|
| 35 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 36 |
"""
|
| 37 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
|
|
|
| 12 |
# --- Basic Agent Definition ---
|
| 13 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 14 |
class BasicAgent:
|
| 15 |
+
def __init__(self):
|
| 16 |
print("Loading Hugging Face model...")
|
| 17 |
self.pipeline = pipeline(
|
| 18 |
"text-generation",
|
| 19 |
+
model="HuggingFaceH4/zephyr-7b-beta",
|
| 20 |
max_new_tokens=256
|
| 21 |
)
|
| 22 |
print("Model loaded.")
|
| 23 |
|
| 24 |
+
def __call__(self, question: str) -> str:
|
| 25 |
print(f"Received question: {question[:60]}...")
|
| 26 |
prompt = f"Answer the question clearly and concisely:\n{question.strip()}\nAnswer:"
|
| 27 |
response = self.pipeline(prompt)[0]["generated_text"]
|
|
|
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
+
|
| 36 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 37 |
"""
|
| 38 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|