Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +43 -0
- requirements.txt +199 -0
app.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from dotenv import load_dotenv
|
2 |
+
import streamlit as st
|
3 |
+
import os
|
4 |
+
import google.generativeai as genai
|
5 |
+
|
6 |
+
# Load the environment variables
|
7 |
+
load_dotenv()
|
8 |
+
|
9 |
+
# Configure the API key
|
10 |
+
genai.configure(api_key=os.getenv("Google_api_key"))
|
11 |
+
|
12 |
+
# Initialize the model
|
13 |
+
model = genai.GenerativeModel('gemini-pro')
|
14 |
+
|
15 |
+
# Function to load gemini model and response
|
16 |
+
def load_gemini_model(question):
|
17 |
+
response = model.generate_content(question)
|
18 |
+
return response.text
|
19 |
+
|
20 |
+
# Set up the Streamlit application
|
21 |
+
st.set_page_config(page_title="Question Answering Bot with Gemini model", page_icon="🤖", layout="centered", initial_sidebar_state="auto")
|
22 |
+
|
23 |
+
# Set the header as Gemini pro application
|
24 |
+
st.header("Gemini pro application")
|
25 |
+
|
26 |
+
# Initialize the chat history
|
27 |
+
chat_history = []
|
28 |
+
|
29 |
+
# Set the input field
|
30 |
+
input = st.text_input("input:", key="input")
|
31 |
+
submit = st.button("ASK a QUESTION")
|
32 |
+
|
33 |
+
# When the submit button is clicked
|
34 |
+
if submit:
|
35 |
+
response = load_gemini_model(input)
|
36 |
+
# Append the question and answer to the chat history
|
37 |
+
chat_history.append({"user": input, "bot": response})
|
38 |
+
# Display the chat history
|
39 |
+
for chat in chat_history:
|
40 |
+
st.subheader("User:")
|
41 |
+
st.write(chat["user"])
|
42 |
+
st.subheader("Bot:")
|
43 |
+
st.write(ch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|
11 |
+
bcrypt==4.1.2
|
12 |
+
blinker==1.7.0
|
13 |
+
cachetools==5.3.2
|
14 |
+
certifi==2023.11.17
|
15 |
+
charset-normalizer==3.3.2
|
16 |
+
chroma-hnswlib==0.7.3
|
17 |
+
chromadb==0.4.21
|
18 |
+
click==8.1.7
|
19 |
+
coloredlogs==15.0.1
|
20 |
+
comm==0.2.1
|
21 |
+
ctransformers==0.2.27
|
22 |
+
dataclasses-json==0.6.3
|
23 |
+
datasets==2.16.1
|
24 |
+
debugpy==1.8.0
|
25 |
+
decorator==5.1.1
|
26 |
+
Deprecated==1.2.14
|
27 |
+
dill==0.3.7
|
28 |
+
distro==1.9.0
|
29 |
+
docx2txt==0.8
|
30 |
+
executing==2.0.1
|
31 |
+
faiss-cpu==1.7.4
|
32 |
+
fastapi==0.108.0
|
33 |
+
filelock==3.13.1
|
34 |
+
flatbuffers==23.5.26
|
35 |
+
frozenlist==1.4.1
|
36 |
+
fsspec==2023.10.0
|
37 |
+
gitdb==4.0.11
|
38 |
+
GitPython==3.1.40
|
39 |
+
google-ai-generativelanguage==0.4.0
|
40 |
+
google-api-core==2.15.0
|
41 |
+
google-auth==2.25.2
|
42 |
+
google-generativeai==0.3.2
|
43 |
+
googleapis-common-protos==1.62.0
|
44 |
+
gradientai==1.4.0
|
45 |
+
greenlet==3.0.3
|
46 |
+
grpcio==1.60.0
|
47 |
+
grpcio-status==1.60.0
|
48 |
+
h11==0.14.0
|
49 |
+
httpcore==1.0.2
|
50 |
+
httptools==0.6.1
|
51 |
+
httpx==0.26.0
|
52 |
+
huggingface==0.0.1
|
53 |
+
huggingface-hub==0.20.1
|
54 |
+
humanfriendly==10.0
|
55 |
+
idna==3.6
|
56 |
+
importlib-metadata==6.11.0
|
57 |
+
importlib-resources==6.1.1
|
58 |
+
ipykernel==6.28.0
|
59 |
+
ipython==8.19.0
|
60 |
+
jedi==0.19.1
|
61 |
+
Jinja2==3.1.2
|
62 |
+
joblib==1.3.2
|
63 |
+
jsonpatch==1.33
|
64 |
+
jsonpointer==2.4
|
65 |
+
jsonschema==4.20.0
|
66 |
+
jsonschema-specifications==2023.11.2
|
67 |
+
jupyter_client==8.6.0
|
68 |
+
jupyter_core==5.6.1
|
69 |
+
kubernetes==28.1.0
|
70 |
+
langchain==0.0.353
|
71 |
+
langchain-community==0.0.7
|
72 |
+
langchain-core==0.1.4
|
73 |
+
langchain-google-genai==0.0.5
|
74 |
+
langsmith==0.0.77
|
75 |
+
lxml==5.1.0
|
76 |
+
markdown-it-py==3.0.0
|
77 |
+
MarkupSafe==2.1.3
|
78 |
+
marshmallow==3.20.1
|
79 |
+
matplotlib-inline==0.1.6
|
80 |
+
mdurl==0.1.2
|
81 |
+
mmh3==4.0.1
|
82 |
+
monotonic==1.6
|
83 |
+
mpmath==1.3.0
|
84 |
+
multidict==6.0.4
|
85 |
+
multiprocess==0.70.15
|
86 |
+
mypy-extensions==1.0.0
|
87 |
+
nest-asyncio==1.5.8
|
88 |
+
networkx==3.2.1
|
89 |
+
nltk==3.8.1
|
90 |
+
numpy==1.26.2
|
91 |
+
nvidia-cublas-cu12==12.1.3.1
|
92 |
+
nvidia-cuda-cupti-cu12==12.1.105
|
93 |
+
nvidia-cuda-nvrtc-cu12==12.1.105
|
94 |
+
nvidia-cuda-runtime-cu12==12.1.105
|
95 |
+
nvidia-cudnn-cu12==8.9.2.26
|
96 |
+
nvidia-cufft-cu12==11.0.2.54
|
97 |
+
nvidia-curand-cu12==10.3.2.106
|
98 |
+
nvidia-cusolver-cu12==11.4.5.107
|
99 |
+
nvidia-cusparse-cu12==12.1.0.106
|
100 |
+
nvidia-nccl-cu12==2.18.1
|
101 |
+
nvidia-nvjitlink-cu12==12.3.101
|
102 |
+
nvidia-nvtx-cu12==12.1.105
|
103 |
+
oauthlib==3.2.2
|
104 |
+
onnxruntime==1.16.3
|
105 |
+
openai==1.6.1
|
106 |
+
opentelemetry-api==1.22.0
|
107 |
+
opentelemetry-exporter-otlp-proto-common==1.22.0
|
108 |
+
opentelemetry-exporter-otlp-proto-grpc==1.22.0
|
109 |
+
opentelemetry-instrumentation==0.43b0
|
110 |
+
opentelemetry-instrumentation-asgi==0.43b0
|
111 |
+
opentelemetry-instrumentation-fastapi==0.43b0
|
112 |
+
opentelemetry-proto==1.22.0
|
113 |
+
opentelemetry-sdk==1.22.0
|
114 |
+
opentelemetry-semantic-conventions==0.43b0
|
115 |
+
opentelemetry-util-http==0.43b0
|
116 |
+
overrides==7.4.0
|
117 |
+
packaging==23.2
|
118 |
+
pandas==2.1.4
|
119 |
+
parso==0.8.3
|
120 |
+
pexpect==4.9.0
|
121 |
+
pillow==10.2.0
|
122 |
+
platformdirs==4.1.0
|
123 |
+
posthog==3.1.0
|
124 |
+
prompt-toolkit==3.0.43
|
125 |
+
proto-plus==1.23.0
|
126 |
+
protobuf==4.25.1
|
127 |
+
psutil==5.9.7
|
128 |
+
ptyprocess==0.7.0
|
129 |
+
pulsar-client==3.3.0
|
130 |
+
pure-eval==0.2.2
|
131 |
+
py-cpuinfo==9.0.0
|
132 |
+
pyarrow==14.0.2
|
133 |
+
pyarrow-hotfix==0.6
|
134 |
+
pyasn1==0.5.1
|
135 |
+
pyasn1-modules==0.3.0
|
136 |
+
pydantic==1.10.13
|
137 |
+
pydantic_core==2.14.6
|
138 |
+
pydeck==0.8.1b0
|
139 |
+
Pygments==2.17.2
|
140 |
+
PyPDF2==3.0.1
|
141 |
+
PyPika==0.48.9
|
142 |
+
python-dateutil==2.8.2
|
143 |
+
python-docx==1.1.0
|
144 |
+
python-dotenv==1.0.0
|
145 |
+
pytz==2023.3.post1
|
146 |
+
PyYAML==6.0.1
|
147 |
+
pyzmq==25.1.2
|
148 |
+
referencing==0.32.0
|
149 |
+
regex==2023.12.25
|
150 |
+
requests==2.31.0
|
151 |
+
requests-oauthlib==1.3.1
|
152 |
+
rich==13.7.0
|
153 |
+
rpds-py==0.15.2
|
154 |
+
rsa==4.9
|
155 |
+
safetensors==0.4.1
|
156 |
+
scikit-learn==1.3.2
|
157 |
+
scipy==1.11.4
|
158 |
+
sentence-transformers==2.2.2
|
159 |
+
sentencepiece==0.1.99
|
160 |
+
six==1.16.0
|
161 |
+
smmap==5.0.1
|
162 |
+
sniffio==1.3.0
|
163 |
+
SQLAlchemy==2.0.25
|
164 |
+
stack-data==0.6.3
|
165 |
+
starlette==0.32.0.post1
|
166 |
+
streamlit==1.29.0
|
167 |
+
streamlit-chat==0.1.1
|
168 |
+
sympy==1.12
|
169 |
+
tenacity==8.2.3
|
170 |
+
text-generation==0.6.1
|
171 |
+
threadpoolctl==3.2.0
|
172 |
+
tokenizers==0.15.0
|
173 |
+
toml==0.10.2
|
174 |
+
toolz==0.12.0
|
175 |
+
torch==2.1.2
|
176 |
+
torchvision==0.16.2
|
177 |
+
tornado==6.4
|
178 |
+
tqdm==4.66.1
|
179 |
+
traitlets==5.14.1
|
180 |
+
transformers==4.36.2
|
181 |
+
triton==2.1.0
|
182 |
+
typer==0.9.0
|
183 |
+
typing-inspect==0.9.0
|
184 |
+
typing_extensions==4.9.0
|
185 |
+
tzdata==2023.3
|
186 |
+
tzlocal==5.2
|
187 |
+
urllib3==1.26.18
|
188 |
+
uvicorn==0.25.0
|
189 |
+
uvloop==0.19.0
|
190 |
+
validators==0.22.0
|
191 |
+
watchdog==3.0.0
|
192 |
+
watchfiles==0.21.0
|
193 |
+
wcwidth==0.2.12
|
194 |
+
websocket-client==1.7.0
|
195 |
+
websockets==12.0
|
196 |
+
wrapt==1.16.0
|
197 |
+
xxhash==3.4.1
|
198 |
+
yarl==1.9.4
|
199 |
+
zipp==3.17.0
|