Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import requests
|
2 |
|
3 |
# Replace with your DeepSeek API key and endpoint
|
@@ -38,12 +39,30 @@ def chat_with_nietzsche(user_input):
|
|
38 |
else:
|
39 |
return "Error: Unable to get a response from the bot."
|
40 |
|
41 |
-
#
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
import requests
|
3 |
|
4 |
# Replace with your DeepSeek API key and endpoint
|
|
|
39 |
else:
|
40 |
return "Error: Unable to get a response from the bot."
|
41 |
|
42 |
+
# Streamlit app
|
43 |
+
def main():
|
44 |
+
st.title("Nietzsche Chatbot")
|
45 |
+
st.markdown("Ask Friedrich Nietzsche anything, and he will respond from his philosophical perspective.")
|
46 |
+
|
47 |
+
# Initialize session state for conversation history
|
48 |
+
if "history" not in st.session_state:
|
49 |
+
st.session_state.history = []
|
50 |
+
|
51 |
+
# Display conversation history
|
52 |
+
for user_input, bot_response in st.session_state.history:
|
53 |
+
st.text_area("You", value=user_input, height=50, disabled=True)
|
54 |
+
st.text_area("Nietzsche", value=bot_response, height=100, disabled=True)
|
55 |
+
|
56 |
+
# User input
|
57 |
+
user_input = st.text_input("Your Question", placeholder="Ask Nietzsche...")
|
58 |
+
|
59 |
+
# Submit button
|
60 |
+
if st.button("Submit"):
|
61 |
+
if user_input.strip(): # Check if input is not empty
|
62 |
+
bot_response = chat_with_nietzsche(user_input)
|
63 |
+
st.session_state.history.append((user_input, bot_response))
|
64 |
+
st.experimental_rerun() # Refresh the app to display the new response
|
65 |
+
|
66 |
+
# Run the Streamlit app
|
67 |
+
if __name__ == "__main__":
|
68 |
+
main()
|