-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
31 lines (22 loc) · 763 Bytes
/
app.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
28
29
30
31
# Text Generation Model
from dotenv import load_dotenv
load_dotenv() # loading all the environment variables
import streamlit as st
import os
import google.generativeai as genai
genai.configure(api_key=os.getenv("GOOGLE_AP_KEY"))
# Function to get Gemini Response
model = genai.GenerativeModel("gemini-pro")
def get_gemini_response(question):
response = model.generate_content(question)
return response.text
# Initialoze the Streamlit App
st.set_page_config(page_title="QnA Demo")
st.header("Gemini Application")
input = st.text_input("Enter your Query: ", key = "input")
submit = st.button("Ask your Question")
# When Submitted...
if submit:
response = get_gemini_response(input)
st.subheader("The Response is: ")
st.write(response)