Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -18,18 +18,18 @@ def get_chatbot_response(user_input):
|
|
18 |
try:
|
19 |
# Prepare the conversation history for the model
|
20 |
conversation_history = ""
|
21 |
-
for user_input, response in st.session_state["history"]:
|
22 |
conversation_history += f"User: {user_input}\nBot: {response}\n"
|
23 |
|
24 |
# Add the current user input to the conversation
|
25 |
conversation_history += f"User: {user_input}\n"
|
26 |
|
27 |
# Debug: Print the conversation history
|
28 |
-
print("Conversation History:")
|
29 |
print(conversation_history)
|
30 |
|
31 |
# Generate response from the model
|
32 |
-
response = chatbot(conversation_history, max_length=1000, pad_token_id=50256)[0]["generated_text"]
|
33 |
|
34 |
# Debug: Print the full response generated by the model
|
35 |
print("Generated Response (Before Stripping User Input):")
|
|
|
18 |
try:
|
19 |
# Prepare the conversation history for the model
|
20 |
conversation_history = ""
|
21 |
+
for user_input, response in st.session_state["history"][-5:]: # Limit history to last 5 exchanges
|
22 |
conversation_history += f"User: {user_input}\nBot: {response}\n"
|
23 |
|
24 |
# Add the current user input to the conversation
|
25 |
conversation_history += f"User: {user_input}\n"
|
26 |
|
27 |
# Debug: Print the conversation history
|
28 |
+
print("Conversation History (Trimmed if Necessary):")
|
29 |
print(conversation_history)
|
30 |
|
31 |
# Generate response from the model
|
32 |
+
response = chatbot(conversation_history, max_length=1000, pad_token_id=50256, num_return_sequences=1)[0]["generated_text"]
|
33 |
|
34 |
# Debug: Print the full response generated by the model
|
35 |
print("Generated Response (Before Stripping User Input):")
|