Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -24,12 +24,24 @@ def get_chatbot_response(user_input):
|
|
24 |
# Add the current user input to the conversation
|
25 |
conversation_history += f"User: {user_input}\n"
|
26 |
|
|
|
|
|
|
|
|
|
27 |
# Generate response from the model
|
28 |
response = chatbot(conversation_history, max_length=1000, pad_token_id=50256)[0]["generated_text"]
|
29 |
|
|
|
|
|
|
|
|
|
30 |
# Remove the user input from the generated response (optional)
|
31 |
response = response[len(conversation_history):].strip()
|
32 |
|
|
|
|
|
|
|
|
|
33 |
return response
|
34 |
except Exception as e:
|
35 |
return f"Error: {str(e)}"
|
@@ -89,7 +101,10 @@ with st.form(key="chat_form", clear_on_submit=True):
|
|
89 |
if submit_button:
|
90 |
if user_input:
|
91 |
response = get_chatbot_response(user_input)
|
92 |
-
|
|
|
|
|
|
|
93 |
else:
|
94 |
st.warning("Please Enter A Prompt 😅")
|
95 |
|
|
|
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):")
|
36 |
+
print(response)
|
37 |
+
|
38 |
# Remove the user input from the generated response (optional)
|
39 |
response = response[len(conversation_history):].strip()
|
40 |
|
41 |
+
# Debug: Print the final response
|
42 |
+
print("Final Response (After Stripping User Input):")
|
43 |
+
print(response)
|
44 |
+
|
45 |
return response
|
46 |
except Exception as e:
|
47 |
return f"Error: {str(e)}"
|
|
|
101 |
if submit_button:
|
102 |
if user_input:
|
103 |
response = get_chatbot_response(user_input)
|
104 |
+
if response:
|
105 |
+
st.session_state.history.append((user_input, response))
|
106 |
+
else:
|
107 |
+
st.warning("Bot returned an empty response.")
|
108 |
else:
|
109 |
st.warning("Please Enter A Prompt 😅")
|
110 |
|