-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathQandA.py
27 lines (20 loc) · 858 Bytes
/
QandA.py
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
from dotenv import load_dotenv
load_dotenv() #loading all the environment variable
import streamlit as st
import os
import google.generativeai as genai
genai.configure(api_key = os.getenv("GOOGLE_API_KEY"))
#function to load Gemini Pro model and get responses
model = genai.GenerativeModel("gemini-pro")
def get_gemini_response(question):
response=model.generate_content(question)
return response.text
#initialize our streamlit app
st.set_page_config(page_title="Question and Answer Demo") #title of the streamlit app
st.header("Gemini LLM Application") #header of app
input=st.text_input('Enter your question: ',key='input') #taking input from user
submit = st.button("Ask the question") #submit button
if submit:
response = get_gemini_response(input)
st.subheader("The response is ")
st.write(response)