-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
30 lines (25 loc) · 910 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
from dotenv import load_dotenv
load_dotenv() # Loading all variables
import streamlit as st
import os
import google.generativeai as genai
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
# function load geminiai pro model and get responses
model = genai.GenerativeModel("gemini-pro")
def get_gemini_response(question):
if not question:
return "Please enter a question"
response = model.generate_content(question)
return response.text
# initialize streamlit app
st.set_page_config(page_title="Q&A Demo")
# st.header("Gemini Speak LLM")
st.markdown('<h2 style="color: skyblue;">Gemini Speak LLM</h2>', unsafe_allow_html=True)
st.subheader("Ask Your Question")
input = st.text_input("Input: ",key="input")
submit = st.button("Ask the question")
# when submit is clicked
if submit:
response = get_gemini_response(input)
st.subheader("The Response is")
st.write(response)