namann007 commited on
Commit
c305d19
1 Parent(s): ae73781

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from langchain_google_genai import ChatGoogleGenerativeAI
3
+
4
+ st.title("Naman's General Knowledge Q&A Bot")
5
+
6
+ def get_answer(question):
7
+ prompt = f"Answer the following general knowledge question: {question}"
8
+
9
+ llm = ChatGoogleGenerativeAI(model="gemini-pro", google_api_key=st.secrets["GOOGLE_API_KEY"])
10
+ response = llm.invoke(prompt)
11
+ answer = response.content
12
+ return answer
13
+
14
+ with st.form("question_form"):
15
+ question = st.text_area("What do you want to ask?")
16
+ submitted = st.form_submit_button("Get Answer")
17
+ if submitted and question:
18
+ answer = get_answer(question)
19
+ st.info(answer)
20
+ elif submitted and not question:
21
+ st.error("Please enter a question to get an answer.")