| import streamlit as st |
| from langchain import LLMChain |
|
|
| st.title("ChefMate") |
|
|
| |
| if "chat_history" not in st.session_state: |
| st.session_state.chat_history = [] |
|
|
| if "quiz_state" not in st.session_state: |
| st.session_state.quiz_state = { |
| "question_index": 0, |
| "score": [], |
| "in_progress": False |
| } |
|
|
| if "current_page" not in st.session_state: |
| st.session_state.current_page = 0 |
|
|
| |
| def get_data_response(question): |
| prompt = f"Provide information on the following topic for 'The Chef Story': {question}" |
| llm_chain = LLMChain(prompt) |
| response = llm_chain.run() |
| return response |
|
|
| |
| def handle_quiz(): |
| |
|
|
| |
| display_menu() |
|
|
| |
| user_input = st.text_input("Ask about our menu, offers, events, or anything else:") |
| if user_input: |
| response = get_data_response(user_input) |
| st.session_state.chat_history.append({"role": "user", "content": user_input}) |
| st.session_state.chat_history.append({"role": "bot", "content": response}) |
|
|
| |
| if st.session_state.chat_history: |
| for message in st.session_state.chat_history: |
| st.markdown(f"**{message['role'].capitalize()}:** {message['content']}") |
|
|
| |
| st.subheader("Fun Quiz") |
| handle_quiz() |
|
|