-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
56 lines (43 loc) · 1.31 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Q&A Chatbot
# from langchain.llms import OpenAI
from dotenv import load_dotenv
import streamlit as st
import os
import textwrap
import google.generativeai as genai
# Load environment variables
load_dotenv()
# Configure Google API
os.getenv("GOOGLE_API_KEY")
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
def get_gemini_response(question):
model = genai.GenerativeModel('gemini-pro')
response = model.generate_content(question)
return response.text
# Initialize Streamlit app
st.set_page_config(page_title="Q&A Demo", layout="wide")
# Custom CSS to style the Streamlit app
st.markdown("""
<style>
.big-font {
font-size:20px !important;
}
</style>
""", unsafe_allow_html=True)
# Layout
st.title("Gemini Application Demo", anchor=None)
# Columns for input and button
col1, col2 = st.columns(2)
with col1:
input = st.text_area("Input your question here:", height=150, key="input")
with col2:
submit = st.button("Ask the Question")
# If ask button is clicked, show response
if submit:
with st.spinner('Waiting for response...'):
response = get_gemini_response(input)
st.subheader("Response")
st.write(response)
# Add some space and a footer note
st.write("---")
st.markdown("*Built with Google Gemini by Pavan Belagatti for the Tutorial Purpose Only*")