Bhagyajoshi commited on
Commit
5a9a157
·
verified ·
1 Parent(s): 327b50d

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +31 -0
  2. keyfile.py +1 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import keyfile
2
+ import streamlit as st
3
+ import google.generativeai as genai
4
+
5
+ genai.configure(api_key=keyfile.GEMINI_API_KEY)
6
+
7
+ if "history" not in st.session_state:
8
+ st.session_state["history"] = []
9
+
10
+ def get_response(question):
11
+ model = genai.GenerativeModel("gemini-1.5-flash")
12
+ response = model.generate_content(question)
13
+ return response.text
14
+
15
+ st.set_page_config(page_title="ASK GPT / GEMINI", page_icon=":robot:")
16
+ st.header("ASK GPT / GEMINI Application")
17
+
18
+ user_input = st.text_input("Enter your question:")
19
+
20
+ if st.button("Ask!"):
21
+ if user_input:
22
+ response = get_response(user_input)
23
+
24
+ st.session_state["history"].append({"user": user_input, "bot": response})
25
+
26
+ st.session_state["user_input"] = ""
27
+
28
+ st.write("### Chat History:")
29
+ for chat in st.session_state["history"]:
30
+ st.write(f"You: {chat['user']}")
31
+ st.write(f"Answer: {chat['bot']}")
keyfile.py ADDED
@@ -0,0 +1 @@
 
 
1
+ GEMINI_API_KEY = "AIzaSyCYGj5e2eAQbUi9HtuMaW0LDSnDuxLG54U"