Spaces:
Running
Running
adding gemini model in this project
Browse files
.env
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
GOOGLE_API_KEY="AIzaSyBmA0xOT18Z2Ov2I7Tu-P1BaDV0I2NEXFk"
|
app.py
CHANGED
@@ -1,17 +1,49 @@
|
|
1 |
|
2 |
import pandas as pd
|
3 |
import warnings
|
4 |
-
import streamlit as
|
5 |
-
|
6 |
from classification import ClassificationModels
|
7 |
from regression import RegressionModels
|
8 |
-
|
9 |
warnings.filterwarnings("ignore")
|
10 |
import uuid
|
11 |
import time
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
# data cleaning: https://bank-performance.streamlit.app/
|
16 |
# https://docs.streamlit.io/library/api-reference/layout
|
17 |
|
@@ -107,8 +139,17 @@ def regressor():
|
|
107 |
st.write(f"R-squared: {r2}")
|
108 |
|
109 |
def NLP():
|
110 |
-
st.
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
|
113 |
def Image():
|
114 |
st.title("Home Page")
|
|
|
1 |
|
2 |
import pandas as pd
|
3 |
import warnings
|
4 |
+
import streamlit as s
|
|
|
5 |
from classification import ClassificationModels
|
6 |
from regression import RegressionModels
|
|
|
7 |
warnings.filterwarnings("ignore")
|
8 |
import uuid
|
9 |
import time
|
10 |
+
import os
|
11 |
+
import pathlib
|
12 |
+
import textwrap
|
13 |
+
import google.generativeai as genai
|
14 |
+
from dotenv import load_dotenv
|
15 |
+
|
16 |
+
|
17 |
+
load_dotenv() # take environment variables from .env.
|
18 |
+
|
19 |
+
|
20 |
+
os.getenv("GOOGLE_API_KEY")
|
21 |
+
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
22 |
+
|
23 |
+
|
24 |
+
## Function to load OpenAI model and get respones
|
25 |
+
model = genai.GenerativeModel('gemini-pro')
|
26 |
+
chat = model.start_chat(history=[])
|
27 |
+
|
28 |
+
def get_gemini_response(question):
|
29 |
+
response =chat.send_message(question,stream=True)
|
30 |
+
return response
|
31 |
+
|
32 |
+
def gemini_model():
|
33 |
+
##initialize our streamlit app
|
34 |
+
# st.set_page_config(page_title="Q&A Demo")
|
35 |
+
st.header("Gemini Application")
|
36 |
+
input=st.text_input("Input: ",key="input")
|
37 |
+
submit=st.button("Ask the question")
|
38 |
+
## If ask button is clicked
|
39 |
+
if submit:
|
40 |
+
response=get_gemini_response(input)
|
41 |
+
st.subheader("The Response is")
|
42 |
+
for chunk in response:
|
43 |
+
print(st.write(chunk.text))
|
44 |
+
print("_"*80)
|
45 |
+
|
46 |
+
# st.write(chat.history)
|
47 |
# data cleaning: https://bank-performance.streamlit.app/
|
48 |
# https://docs.streamlit.io/library/api-reference/layout
|
49 |
|
|
|
139 |
st.write(f"R-squared: {r2}")
|
140 |
|
141 |
def NLP():
|
142 |
+
Gemini, Bert, = st.tabs(['Gemini','Bert'])
|
143 |
+
|
144 |
+
with Gemini:
|
145 |
+
st.title("Chat with Gemini Pro")
|
146 |
+
gemini_model()
|
147 |
+
|
148 |
+
|
149 |
+
with Bert:
|
150 |
+
st.title("Question answering module using Bert model,will add this module soon")
|
151 |
+
|
152 |
+
|
153 |
|
154 |
def Image():
|
155 |
st.title("Home Page")
|