Skip to content

Commit 3851c88

Browse files
Merge pull request #3 from ptptiwari/main
Few minor fixes and more debugging log for testing purpose
2 parents 60ebf62 + 2f942f6 commit 3851c88

File tree

2 files changed

+314
-19
lines changed

2 files changed

+314
-19
lines changed

python-rag-chatbot/oracle_bot_exp.py

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1-
#
2-
# Streamlit App to demo OCI AI GenAI
3-
# this is the main code, with the UI
4-
#
51
import streamlit as st
2+
import time
3+
import traceback
4+
import sys
65

7-
# this function initialise the rag chain, creating retriever, llm and chain
86
from init_rag_streamlit_exp import initialize_rag_chain, get_answer
97

10-
#
11-
# Configs
12-
#
8+
from streamlit_feedback import streamlit_feedback
139

10+
def process_feedback(feedback_value):
11+
st.write("Feedback value:", feedback_value)
12+
with open("feedback.txt", "a", encoding="utf-8") as f:
13+
f.write(f"{feedback_value}\n")
1414

1515
def reset_conversation():
1616
st.session_state.messages = []
17+
st.session_state.feedback_rendered = False
18+
st.session_state.feedback_key = 0
1719

18-
19-
#
20-
# Main
21-
#
22-
st.title("Oracle Database AI Bot powered by RAG")
20+
st.title("Developing an AI bot powered by RAG and Oracle Database")
2321

2422
# Added reset button
2523
st.button("Clear Chat History", on_click=reset_conversation)
@@ -43,18 +41,33 @@ def reset_conversation():
4341
# Add user message to chat history
4442
st.session_state.messages.append({"role": "user", "content": question})
4543

46-
# here we call OCI genai...
47-
4844
try:
49-
print("...")
5045
response = get_answer(rag_chain, question)
5146

52-
# Display assistant response in chat message container
5347
with st.chat_message("assistant"):
5448
st.markdown(response)
5549

56-
# Add assistant response to chat history
50+
with st.container():
51+
st.markdown("How was my response?")
52+
53+
if not st.session_state.feedback_rendered:
54+
def _submit_feedback(feedback_value, *args, **kwargs):
55+
print("Feedback submitted:", feedback_value, file=sys.stderr) # Redirect to stderr
56+
process_feedback(feedback_value)
57+
st.session_state.feedback_rendered = False
58+
59+
feedback_component = streamlit_feedback(
60+
feedback_type="faces",
61+
on_submit=_submit_feedback,
62+
key=f"feedback_{st.session_state.feedback_key}",
63+
optional_text_label="Please provide some more information",
64+
args=["✅"]
65+
)
66+
st.session_state.feedback_key += 1
67+
st.session_state.feedback_rendered = True
68+
5769
st.session_state.messages.append({"role": "assistant", "content": response})
5870

5971
except Exception as e:
60-
st.error("An error occurred: " + str(e))
72+
st.error(f"An error occurred: {e}")
73+
traceback.print_exc()

python-rag-chatbot/requirements.txt

Lines changed: 282 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
aiohttp==3.9.5
2+
aiosignal==1.3.1
3+
altair==5.1.2
4+
annotated-types==0.6.0
5+
anyio==3.7.1
6+
appnope==0.1.3
7+
argon2-cffi==23.1.0
8+
argon2-cffi-bindings==21.2.0
9+
arrow==1.3.0
10+
asgiref==3.8.1
11+
asttokens==2.4.0
12+
astunparse==1.6.3
13+
async-lru==2.0.4
14+
async-timeout==4.0.3
15+
attrs==23.1.0
16+
Babel==2.13.0
17+
backcall==0.2.0
18+
backoff==2.2.1
19+
bcrypt==4.0.1
20+
beautifulsoup4==4.12.2
21+
black==23.9.1
22+
bleach==6.1.0
23+
blinker==1.6.3
24+
boto3==1.34.115
25+
botocore==1.34.115
26+
build==1.2.1
27+
cachetools==5.3.1
28+
certifi==2023.7.22
29+
cffi==1.16.0
30+
chardet==5.2.0
31+
charset-normalizer==3.3.0
32+
Chroma==0.2.0
33+
chroma-hnswlib==0.7.3
34+
chromadb==0.4.14
35+
circuitbreaker==1.4.0
36+
click==8.1.7
37+
cohere==4.27
38+
colorama==0.4.6
39+
coloredlogs==15.0.1
40+
comm==0.1.4
41+
contourpy==1.2.1
42+
cryptography==42.0.4
43+
cycler==0.12.1
44+
dataclasses-json==0.6.1
45+
debugpy==1.8.0
46+
decorator==5.1.1
47+
defusedxml==0.7.1
48+
Deprecated==1.2.14
49+
dnspython== 2.6.1
50+
docutils == 0.21.2
51+
email_validator== 2.1.1
52+
emoji== 2.8.0
53+
exceptiongroup== 1.1.3
54+
executing== 2.0.0
55+
fastavro== 1.8.2
56+
fastjsonschema== 2.18.1
57+
filelock== 3.12.4
58+
filetype== 1.2.0
59+
flatbuffers== 23.5.26
60+
fonttools== 4.52.4
61+
fqdn== 1.5.1
62+
frozenlist== 1.4.0
63+
fsspec== 2023.9.2
64+
gitdb== 4.0.11
65+
GitPython== 3.1.41
66+
google-auth== 2.29.0
67+
googleapis-common-protos== 1.63.0
68+
greenlet== 3.0.3
69+
grpcio== 1.59.0
70+
h11== 0.14.0
71+
halo== 0.0.31
72+
httpcore== 1.0.5
73+
httptools== 0.6.0
74+
httpx== 0.27.0
75+
httpx-sse== 0.4.0
76+
huggingface-hub== 0.23.2
77+
humanfriendly== 10.0
78+
idna== 3.4
79+
importlib-metadata== 6.8.0
80+
importlib-resources== 6.1.0
81+
inference-tools== 0.13.0
82+
install== 1.3.5
83+
IProgress== 0.4
84+
ipykernel== 6.25.2
85+
ipython== 8.16.1
86+
ipywidgets== 8.1.1
87+
isoduration== 20.11.0
88+
jedi== 0.19.1
89+
Jinja2== 3.1.3
90+
jmespath== 1.0.1
91+
joblib== 1.3.2
92+
json5== 0.9.14
93+
jsonpatch== 1.33
94+
jsonpointer== 2.4
95+
jsonschema== 4.19.1
96+
jsonschema-specifications== 2023.7.1
97+
jupyter_client== 8.4.0
98+
jupyter_core== 5.4.0
99+
jupyter-events== 0.7.0
100+
jupyter-lsp== 2.2.2
101+
jupyter_server== 2.7.3
102+
jupyter_server_terminals== 0.4.4
103+
jupyterlab== 4.1.0b2
104+
jupyterlab-pygments== 0.2.2
105+
jupyterlab_server== 2.25.0
106+
jupyterlab-widgets== 3.0.9
107+
kiwisolver== 1.4.5
108+
kubernetes== 29.0.0
109+
langchain== 0.2.1
110+
langchain-cli== 0.0.24
111+
langchain-cohere== 0.1.5
112+
langchain-community== 0.2.1
113+
langchain-core== 0.2.2
114+
langchain-text-splitters== 0.2.0
115+
langchainhub== 0.1.13
116+
langdetect== 1.0.9
117+
langserve== 0.2.1
118+
langsmith== 0.1.67
119+
libcst== 1.4.0
120+
log-symbols== 0.0.14
121+
loguru== 0.7.2
122+
lxml== 4.9.3
123+
markdown-it-py== 3.0.0
124+
MarkupSafe== 2.1.3
125+
marshmallow== 3.20.1
126+
matplotlib== 3.9.0
127+
matplotlib-inline== 0.1.6
128+
mdurl== 0.1.2
129+
mention== 0.1
130+
mistune== 3.0.2
131+
mmh3== 4.1.0
132+
modules== 1.0.0
133+
monotonic== 1.6
134+
mpmath== 1.3.0
135+
multidict== 6.0.4
136+
mypy-extensions== 1.0.0
137+
nbclient== 0.8.0
138+
nbconvert== 7.9.2
139+
nbformat== 5.9.2
140+
nest-asyncio== 1.5.8
141+
networkx== 3.1
142+
nltk== 3.8.1
143+
notebook_shim== 0.2.3
144+
numpy== 1.26.1
145+
oauthlib== 3.2.2
146+
oci== 2.126.4
147+
onnxruntime== 1.18.0
148+
openai== 0.28.1
149+
opentelemetry-api== 1.24.0
150+
opentelemetry-exporter-otlp-proto-common== 1.24.0
151+
opentelemetry-exporter-otlp-proto-grpc== 1.24.0
152+
opentelemetry-instrumentation== 0.45b0
153+
opentelemetry-instrumentation-asgi== 0.45b0
154+
opentelemetry-instrumentation-fastapi== 0.45b0
155+
opentelemetry-proto== 1.24.0
156+
opentelemetry-sdk== 1.24.0
157+
opentelemetry-semantic-conventions== 0.45b0
158+
opentelemetry-util-http== 0.45b0
159+
oracledb== 2.2.1
160+
orjson== 3.10.3
161+
overrides== 7.4.0
162+
packaging== 23.2
163+
page== 0.2
164+
pages== 0.3
165+
pandas== 2.1.1
166+
pandocfilters== 1.5.0
167+
parso== 0.8.3
168+
path== 16.14.0
169+
pathspec== 0.11.2
170+
pexpect== 4.8.0
171+
pickleshare== 0.7.5
172+
piglet-templates== 1.3.1
173+
Pillow== 10.1.0
174+
pip== 24.1.1
175+
platformdirs== 3.11.0
176+
posthog== 3.0.2
177+
prometheus-client== 0.17.1
178+
prompt-toolkit== 3.0.39
179+
protobuf== 4.24.4
180+
psutil== 5.9.6
181+
ptyprocess== 0.7.0
182+
pulsar-client== 3.5.0
183+
pure-eval== 0.2.2
184+
pyarrow== 16.1.0
185+
pyasn1== 0.6.0
186+
pyasn1_modules== 0.4.0
187+
pycparser== 2.21
188+
pydantic== 2.4.2
189+
pydantic_core== 2.10.1
190+
pydeck== 0.8.1b0
191+
Pygments== 2.16.1
192+
pyOpenSSL== 23.2.0
193+
pyparsing== 3.1.2
194+
pypdf== 3.17.0
195+
PyPika== 0.48.9
196+
pyproject_hooks== 1.1.0
197+
pyproject-toml== 0.0.10
198+
python-dateutil== 2.8.2
199+
python-dotenv== 1.0.0
200+
python-iso639== 2023.6.15
201+
python-json-logger== 2.0.7
202+
python-magic== 0.4.27
203+
python-multipart== 0.0.9
204+
pytz== 2023.3.post1
205+
PyYAML== 6.0.1
206+
pyzmq== 25.1.1
207+
rapidfuzz== 3.4.0
208+
referencing== 0.30.2
209+
regex==2023.10.3
210+
requests==2.31.0
211+
requests-oauth2==0.3.0
212+
requests-oauthlib==2.0.0
213+
rfc3339-validator==0.1.4
214+
rfc3986-validator==0.1.1
215+
rich==13.6.0
216+
rpds-py==0.10.6
217+
rsa==4.9
218+
s3transfer==0.10.1
219+
safetensors==0.4.3
220+
scikit-learn==1.3.1
221+
scipy==1.11.3
222+
section==2.0
223+
Send2Trash==1.8.2
224+
sentence-transformers==2.2.2
225+
sentencepiece==0.2.0
226+
setuptools==70.0.0
227+
shellingham==1.5.4
228+
six==1.16.0
229+
smmap==5.0.1
230+
sniffio==1.3.0
231+
soupsieve==2.5
232+
spinners==0.0.24
233+
SQLAlchemy==2.0.22
234+
streamlit==1.30.0
235+
streamlit-feedback==0.1.3
236+
sympy==1.12
237+
tabulate==0.9.0
238+
tenacity==8.2.3
239+
termcolor==2.3.0
240+
terminado==0.17.1
241+
threadpoolctl==3.2.0
242+
tinycss2==1.2.1
243+
tokenize-rt==5.2.0
244+
tokenizers==0.19.1
245+
toml==0.10.2
246+
tomli==2.0.1
247+
tomlkit==0.12.5
248+
toolz==0.12.0
249+
torch==2.2.2
250+
torchvision==0.17.2
251+
tornado==6.3.3
252+
tqdm==4.66.1
253+
traitlets==5.11.2
254+
transformers==4.41.2
255+
trubrics==1.6.2
256+
typer==0.9.0
257+
types-python-dateutil==2.8.19.14
258+
types-requests==2.31.0.9
259+
typing_extensions==4.8.0
260+
typing-inspect==0.9.0
261+
tzdata==2023.3
262+
tzlocal==5.2
263+
ujson==5.10.0
264+
unstructured==0.10.23
265+
uri-template==1.3.0
266+
urllib3==2.0.7
267+
uvicorn==0.23.2
268+
uvloop==0.18.0
269+
validators==0.22.0
270+
watchdog==3.0.0
271+
watchfiles==0.21.0
272+
wcwidth==0.2.8
273+
webcolors==1.13
274+
webencodings==0.5.1
275+
websocket-client==1.6.4
276+
websockets==11.0.3
277+
wheel==0.43.0
278+
widgetsnbextension==4.0.9
279+
wrapt==1.16.0
280+
xmltodict==0.13.0
281+
yarl==1.9.2
282+
zipp==3.17.0

0 commit comments

Comments
 (0)