Create components/historical_personalities.py
Browse files
components/historical_personalities.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from utils.ai_functions import generate_historical_dialogue
|
| 3 |
+
|
| 4 |
+
def show_historical_personalities():
|
| 5 |
+
st.title("Interact with Historical Personalities")
|
| 6 |
+
st.write("Engage in dynamic, educational dialogues with AI-generated historical figures.")
|
| 7 |
+
|
| 8 |
+
personality = st.selectbox("Choose a historical personality", ["Albert Einstein", "William Shakespeare", "Cleopatra", "Leonardo da Vinci", "Marie Curie"])
|
| 9 |
+
user_input = st.text_input("Ask a question or start a conversation:")
|
| 10 |
+
|
| 11 |
+
if st.button("Generate Response"):
|
| 12 |
+
if user_input:
|
| 13 |
+
with st.spinner(f"Generating response from {personality}..."):
|
| 14 |
+
response = generate_historical_dialogue(personality, user_input)
|
| 15 |
+
st.write(f"{personality}: {response}")
|
| 16 |
+
else:
|
| 17 |
+
st.warning("Please enter a question or statement to start the conversation.")
|
| 18 |
+
|
| 19 |
+
if 'conversation_history' not in st.session_state:
|
| 20 |
+
st.session_state.conversation_history = []
|
| 21 |
+
|
| 22 |
+
if len(st.session_state.conversation_history) > 0:
|
| 23 |
+
st.subheader("Conversation History")
|
| 24 |
+
for entry in st.session_state.conversation_history:
|
| 25 |
+
st.text(entry)
|