Spaces:
Sleeping
Sleeping
Commit
·
c63aa8f
1
Parent(s):
281ff1a
Upload 2 files
Browse files- app.py +35 -0
- requirements.txt +3 -0
app.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from dotenv import load_dotenv
|
| 2 |
+
|
| 3 |
+
load_dotenv()
|
| 4 |
+
|
| 5 |
+
import streamlit as st
|
| 6 |
+
import os
|
| 7 |
+
import pathlib
|
| 8 |
+
import textwrap
|
| 9 |
+
|
| 10 |
+
import google.generativeai as genai
|
| 11 |
+
|
| 12 |
+
os.getenv("GOOGLE_API_KEY")
|
| 13 |
+
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 14 |
+
|
| 15 |
+
# function to los the genini api model and get responses
|
| 16 |
+
|
| 17 |
+
def get_gemini_response(question):
|
| 18 |
+
model =genai.GenerativeModel('gemini-pro')
|
| 19 |
+
response = model.generate_content(question)
|
| 20 |
+
return response.text
|
| 21 |
+
|
| 22 |
+
#intizlize the streamlitapp
|
| 23 |
+
|
| 24 |
+
st.set_page_config(page_title= "DDS Q & A Demo")
|
| 25 |
+
|
| 26 |
+
st.header("DDS Q & A Demo using Gemini")
|
| 27 |
+
|
| 28 |
+
input = st.text_input("Input:", key="input")
|
| 29 |
+
|
| 30 |
+
submit = st.button("Ask your Question")
|
| 31 |
+
|
| 32 |
+
if submit:
|
| 33 |
+
response = get_gemini_response(input)
|
| 34 |
+
st.subheader("The Answer is")
|
| 35 |
+
st.write(response)
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
google-generativeai
|
| 3 |
+
python-dotenv
|