Spaces:
Sleeping
Sleeping
File size: 833 Bytes
5a9a157 0772d65 5a9a157 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import keyfile
import streamlit as st
import google.generativeai as genai
genai.configure(api_key=keyfile.GEMINI_API_KEY)
if "history" not in st.session_state:
st.session_state["history"] = []
def get_response(question):
model = genai.GenerativeModel("gemini-1.5-flash")
response = model.generate_content(question)
return response.text
st.set_page_config(page_title="Chat Bot", page_icon=":robot:")
st.header("Chat Application")
user_input = st.text_input("Enter your question:")
if st.button("Ask!"):
if user_input:
response = get_response(user_input)
st.session_state["history"].append({"user": user_input, "bot": response})
st.session_state["user_input"] = ""
for chat in st.session_state["history"]:
st.write(f"You: {chat['user']}")
st.write(f"Answer: {chat['bot']}")
|