-
Notifications
You must be signed in to change notification settings - Fork 0
/
geminiAi.py
35 lines (28 loc) · 976 Bytes
/
geminiAi.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
# api = "AIzaSyDoR5Qf0_LjHKzn-cdThi42DLpn7s47BJc"
import pathlib
import textwrap
import streamlit as st
import google.generativeai as genai
import os
from dotenv import load_dotenv
load_dotenv()
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
# The below command is used to see the list of gemini models
# for m in genai.list_models():
# if 'generateContent' in m.supported_generation_methods:
# print(m.name)
# We are using gemini-1.5-flash for text ony prompts
model = genai.GenerativeModel('gemini-1.5-flash')
def get_gemini_response(question):
response = model.generate_content(question)
return response.text
# Let's create our streamlit application
st.set_page_config(page_title="Q&A Demo")
st.header("Gemini LLM Application")
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)