Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,18 +9,16 @@ model = AutoModelForSeq2SeqLM.from_pretrained("mrSoul7766/AgriQBot")
|
|
| 9 |
|
| 10 |
def respond(
|
| 11 |
message,
|
| 12 |
-
history
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
top_p,
|
| 17 |
):
|
| 18 |
"""
|
| 19 |
Respond to user queries using the AgriQBot model.
|
| 20 |
Args:
|
| 21 |
- message: User query (string).
|
| 22 |
-
- history: List of previous (user, assistant) message pairs.
|
| 23 |
-
- system_message: System-level instructions for the assistant.
|
| 24 |
- max_tokens: Maximum number of tokens in the response.
|
| 25 |
- temperature: Controls randomness in response.
|
| 26 |
- top_p: Controls diversity of the response.
|
|
@@ -28,7 +26,10 @@ def respond(
|
|
| 28 |
Returns:
|
| 29 |
- Response string as the chatbot's answer.
|
| 30 |
"""
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
# Construct the conversation history
|
| 34 |
for val in history:
|
|
|
|
| 9 |
|
| 10 |
def respond(
|
| 11 |
message,
|
| 12 |
+
history=None, # Set history default to None
|
| 13 |
+
max_tokens=512,
|
| 14 |
+
temperature=0.7,
|
| 15 |
+
top_p=0.95,
|
|
|
|
| 16 |
):
|
| 17 |
"""
|
| 18 |
Respond to user queries using the AgriQBot model.
|
| 19 |
Args:
|
| 20 |
- message: User query (string).
|
| 21 |
+
- history: List of previous (user, assistant) message pairs (default is None).
|
|
|
|
| 22 |
- max_tokens: Maximum number of tokens in the response.
|
| 23 |
- temperature: Controls randomness in response.
|
| 24 |
- top_p: Controls diversity of the response.
|
|
|
|
| 26 |
Returns:
|
| 27 |
- Response string as the chatbot's answer.
|
| 28 |
"""
|
| 29 |
+
if history is None:
|
| 30 |
+
history = [] # Initialize history to an empty list if None
|
| 31 |
+
|
| 32 |
+
messages = [{"role": "system", "content": "You are a friendly farming assistant. Answer the user's questions related to farming."}]
|
| 33 |
|
| 34 |
# Construct the conversation history
|
| 35 |
for val in history:
|