Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,20 +15,20 @@ from transformers import pipeline
|
|
| 15 |
|
| 16 |
class BasicAgent:
|
| 17 |
def __init__(self):
|
| 18 |
-
print("FLAN-
|
| 19 |
|
| 20 |
self.pipeline = pipeline(
|
| 21 |
"text2text-generation",
|
| 22 |
-
model="
|
| 23 |
-
tokenizer="
|
| 24 |
-
device=-1 #
|
| 25 |
)
|
| 26 |
|
| 27 |
def __call__(self, question: str) -> str:
|
| 28 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 29 |
|
| 30 |
try:
|
| 31 |
-
prompt = f"
|
| 32 |
result = self.pipeline(prompt, max_new_tokens=128, temperature=0.5)
|
| 33 |
answer = result[0]["generated_text"]
|
| 34 |
return answer.strip()
|
|
|
|
| 15 |
|
| 16 |
class BasicAgent:
|
| 17 |
def __init__(self):
|
| 18 |
+
print("FLAN-ALPACA-BASE Local Agent initialized.")
|
| 19 |
|
| 20 |
self.pipeline = pipeline(
|
| 21 |
"text2text-generation",
|
| 22 |
+
model="declare-lab/flan-alpaca-base",
|
| 23 |
+
tokenizer="declare-lab/flan-alpaca-base",
|
| 24 |
+
device=-1 # CPU
|
| 25 |
)
|
| 26 |
|
| 27 |
def __call__(self, question: str) -> str:
|
| 28 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 29 |
|
| 30 |
try:
|
| 31 |
+
prompt = f"### Instruction:\n{question.strip()}\n\n### Response:"
|
| 32 |
result = self.pipeline(prompt, max_new_tokens=128, temperature=0.5)
|
| 33 |
answer = result[0]["generated_text"]
|
| 34 |
return answer.strip()
|