import streamlit as st from utils.ai_functions import generate_historical_dialogue def show_historical_personalities(): st.title("Interact with Historical Personalities") st.write("Engage in dynamic, educational dialogues with AI-generated historical figures.") # Initialize the conversation history in session state if 'conversation_history' not in st.session_state: st.session_state.conversation_history = [] # User selects a personality and enters a question personality = st.selectbox("Choose a historical personality", ["Albert Einstein", "William Shakespeare", "Cleopatra", "Leonardo da Vinci", "Marie Curie"]) user_input = st.text_input("Ask a question or start a conversation:") if st.button("Generate Response"): if user_input: with st.spinner(f"Generating response from {personality}..."): response = generate_historical_dialogue(personality, user_input) # Update conversation history st.session_state.conversation_history.append(f"You: {user_input}") st.session_state.conversation_history.append(f"{personality}: {response}") # Display the response st.write(f"{personality}: {response}") else: st.warning("Please enter a question or statement to start the conversation.") # Display the conversation history if len(st.session_state.conversation_history) > 0: st.subheader("Conversation History") for entry in st.session_state.conversation_history: st.text(entry) # Run the function to start the Streamlit app if __name__ == "__main__": show_historical_personalities()