Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,7 +14,7 @@ class SystemMessage:
|
|
| 14 |
|
| 15 |
|
| 16 |
# Choose your desired free model from the Hugging Face Hub
|
| 17 |
-
model_name = "
|
| 18 |
|
| 19 |
# Load the model and tokenizer
|
| 20 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
|
@@ -41,17 +41,13 @@ class AIMessage:
|
|
| 41 |
|
| 42 |
def load_answer(question):
|
| 43 |
|
| 44 |
-
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
assistant_answer = AIMessage(content=response_text)
|
| 52 |
-
st.session_state.sessionMessages.append(assistant_answer)
|
| 53 |
-
|
| 54 |
-
return response_text
|
| 55 |
|
| 56 |
|
| 57 |
|
|
|
|
| 14 |
|
| 15 |
|
| 16 |
# Choose your desired free model from the Hugging Face Hub
|
| 17 |
+
model_name = "facebook/bart-base" # Replace with your choice (e.g.,t5-small or facebook/bart-base or EleutherAI/gpt-neo-125M)
|
| 18 |
|
| 19 |
# Load the model and tokenizer
|
| 20 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
|
|
|
| 41 |
|
| 42 |
def load_answer(question):
|
| 43 |
|
| 44 |
+
st.session_state.sessionMessages.append(HumanMessage(content=question))
|
| 45 |
|
| 46 |
+
inputs = tokenizer(question, return_tensors="pt")
|
| 47 |
+
outputs = model.generate(**inputs)
|
| 48 |
+
response_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 49 |
+
st.session_state.sessionMessages.append(AIMessage(content=assistant_answer.content))
|
| 50 |
+
return assistant_answer.content
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
|
| 53 |
|