Update app.py
Browse files
app.py
CHANGED
|
@@ -73,8 +73,8 @@ def load_model():
|
|
| 73 |
raise
|
| 74 |
|
| 75 |
# Load the model and tokenizer locally
|
| 76 |
-
model, tokenizer = load_model()
|
| 77 |
-
|
| 78 |
|
| 79 |
|
| 80 |
class BasicAgent:
|
|
@@ -89,22 +89,11 @@ class BasicAgent:
|
|
| 89 |
planning_interval=3,
|
| 90 |
|
| 91 |
)
|
| 92 |
-
|
| 93 |
-
def __call__(self, question: str) -> str:
|
| 94 |
-
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 95 |
-
|
| 96 |
-
encoded_input = tokenizer(question, return_tensors="pt", padding=True, truncation=True, max_length=512)
|
| 97 |
|
| 98 |
-
# Generate text using the model
|
| 99 |
-
output = model.generate(
|
| 100 |
-
encoded_input['input_ids'],
|
| 101 |
-
attention_mask=encoded_input['attention_mask'], # Pass attention mask
|
| 102 |
-
max_length=100,
|
| 103 |
-
pad_token_id=tokenizer.pad_token_id,
|
| 104 |
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
answer =
|
| 108 |
return answer
|
| 109 |
|
| 110 |
|
|
|
|
| 73 |
raise
|
| 74 |
|
| 75 |
# Load the model and tokenizer locally
|
| 76 |
+
#model, tokenizer = load_model()
|
| 77 |
+
model = HfApiModel(model_id='mistralai/Mistral-7B-Instruct-v0.2', max_tokens=512)
|
| 78 |
|
| 79 |
|
| 80 |
class BasicAgent:
|
|
|
|
| 89 |
planning_interval=3,
|
| 90 |
|
| 91 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
+
def __call__(self, question: str) -> str:
|
| 95 |
+
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 96 |
+
answer = self.agent.run(question)
|
| 97 |
return answer
|
| 98 |
|
| 99 |
|