Spaces:
Sleeping
Sleeping
Update app.py
Browse files6 unmodified lines78910111213141 unmodified line16171819202122232425262728298 unmodified lines383940414243446 unmodified lines5152535455565758596061626364656667686970716 unmodified linesgenai.configure(api_key=GOOGLE_API_KEY)# Initialize the Generative Model# model = genai.GenerativeModel('gemini-pro')model = genai.GenerativeModel('gemini-2.5-flash')# Function to get response from the modeldef get_chatbot_response(user_input):response = model.generate_content(user_input)1 unmodified line# Streamlit interfacest.set_page_config(page_title="Simple ChatBot", layout="centered")st.title("✨ Simple ChatBot ✨")st.write("Powered by Google Generative AI")if "history" not in st.session_state:st.session_state["history"] = []# Display chat historyfor user_message, bot_message in st.session_state.history:st.markdown(f"""<div style="8 unmodified lines<p style="margin: 0; font-size: 16px; line-height: 1.5;"><b>You:</b> {user_message} 😊</p></div>""", unsafe_allow_html=True)st.markdown(f"""<div style="background-color: #e1ffc7;6 unmodified lines"><p style="margin: 0; font-size: 16px; line-height: 1.5;"><b>Bot:</b> {bot_message} 🤖</p></div>""", unsafe_allow_html=True)# user_input = input("Enter your Prompt = ")# output = get_chatbot_response(user_input)# print(output)with st.form(key="chat_form", clear_on_submit=True):user_input = st.text_input("", max_chars=2000)submit_button = st.form_submit_button("Send")if submit_button:if user_input:response = get_chatbot_response(user_input)st.session_state.history.append((user_input, response))st.rerun()else:st.warning("Please Enter A Prompt")6 unmodified lines78910111213141 unmodified line161718192021222324252627282930313233343536378 unmodified lines464748495051526 unmodified lines596061626 unmodified linesgenai.configure(api_key=GOOGLE_API_KEY)# Initialize the Generative Modelmodel = genai.GenerativeModel('gemini-2.5-flash')# Function to get response from the modeldef get_chatbot_response(user_input):response = model.generate_content(user_input)1 unmodified line# Streamlit interfacest.set_page_config(page_title="Simple ChatBot", layout="centered")st.title("✨ Simple ChatBot ✨")st.write("Powered by Google Generative AI")if "history" not in st.session_state:st.session_state["history"] = []# Form at the topwith st.form(key="chat_form", clear_on_submit=True):user_input = st.text_input("", max_chars=2000, placeholder="Type your message here...")submit_button = st.form_submit_button("Send")if submit_button and user_input:response = get_chatbot_response(user_input)st.session_state.history.append((user_input, response))# Display chat history AFTER form processingfor user_message, bot_message in st.session_state.history:st.markdown(f"""<div style="8 unmodified lines<p style="margin: 0; font-size: 16px; line-height: 1.5;"><b>You:</b> {user_message} 😊</p></div>""", unsafe_allow_html=True)st.markdown(f"""<div style="background-color: #e1ffc7;6 unmodified lines"><p style="margin: 0; font-size: 16px; line-height: 1.5;"><b>Bot:</b> {bot_message} 🤖</p></div>""", unsafe_allow_html=True)
app.py+13-22