hertogateis commited on
Commit
4b3d161
·
verified ·
1 Parent(s): c693557

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -9
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
- # Main loop for the chatbot
42
- print("Nietzsche Bot: I am Friedrich Nietzsche. Ask me anything, and I will respond from my perspective.")
43
- while True:
44
- user_input = input("You: ")
45
- if user_input.lower() in ["exit", "quit", "bye"]:
46
- print("Nietzsche Bot: Farewell! Remember, create your own meaning.")
47
- break
48
- bot_response = chat_with_nietzsche(user_input)
49
- print(f"Nietzsche Bot: {bot_response}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()