Skip to content

Commit

Permalink
Merge pull request #3 from ptptiwari/main
Browse files Browse the repository at this point in the history
Few minor fixes and more debugging log for testing purpose
  • Loading branch information
paulparkinson authored Aug 8, 2024
2 parents 60ebf62 + 2f942f6 commit 3851c88
Show file tree
Hide file tree
Showing 2 changed files with 314 additions and 19 deletions.
51 changes: 32 additions & 19 deletions python-rag-chatbot/oracle_bot_exp.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
#
# Streamlit App to demo OCI AI GenAI
# this is the main code, with the UI
#
import streamlit as st
import time
import traceback
import sys

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

#
# Configs
#
from streamlit_feedback import streamlit_feedback

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

def reset_conversation():
st.session_state.messages = []
st.session_state.feedback_rendered = False
st.session_state.feedback_key = 0


#
# Main
#
st.title("Oracle Database AI Bot powered by RAG")
st.title("Developing an AI bot powered by RAG and Oracle Database")

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

# here we call OCI genai...

try:
print("...")
response = get_answer(rag_chain, question)

# Display assistant response in chat message container
with st.chat_message("assistant"):
st.markdown(response)

# Add assistant response to chat history
with st.container():
st.markdown("How was my response?")

if not st.session_state.feedback_rendered:
def _submit_feedback(feedback_value, *args, **kwargs):
print("Feedback submitted:", feedback_value, file=sys.stderr) # Redirect to stderr
process_feedback(feedback_value)
st.session_state.feedback_rendered = False

feedback_component = streamlit_feedback(
feedback_type="faces",
on_submit=_submit_feedback,
key=f"feedback_{st.session_state.feedback_key}",
optional_text_label="Please provide some more information",
args=["✅"]
)
st.session_state.feedback_key += 1
st.session_state.feedback_rendered = True

st.session_state.messages.append({"role": "assistant", "content": response})

except Exception as e:
st.error("An error occurred: " + str(e))
st.error(f"An error occurred: {e}")
traceback.print_exc()
282 changes: 282 additions & 0 deletions python-rag-chatbot/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
aiohttp==3.9.5
aiosignal==1.3.1
altair==5.1.2
annotated-types==0.6.0
anyio==3.7.1
appnope==0.1.3
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.3.0
asgiref==3.8.1
asttokens==2.4.0
astunparse==1.6.3
async-lru==2.0.4
async-timeout==4.0.3
attrs==23.1.0
Babel==2.13.0
backcall==0.2.0
backoff==2.2.1
bcrypt==4.0.1
beautifulsoup4==4.12.2
black==23.9.1
bleach==6.1.0
blinker==1.6.3
boto3==1.34.115
botocore==1.34.115
build==1.2.1
cachetools==5.3.1
certifi==2023.7.22
cffi==1.16.0
chardet==5.2.0
charset-normalizer==3.3.0
Chroma==0.2.0
chroma-hnswlib==0.7.3
chromadb==0.4.14
circuitbreaker==1.4.0
click==8.1.7
cohere==4.27
colorama==0.4.6
coloredlogs==15.0.1
comm==0.1.4
contourpy==1.2.1
cryptography==42.0.4
cycler==0.12.1
dataclasses-json==0.6.1
debugpy==1.8.0
decorator==5.1.1
defusedxml==0.7.1
Deprecated==1.2.14
dnspython== 2.6.1
docutils == 0.21.2
email_validator== 2.1.1
emoji== 2.8.0
exceptiongroup== 1.1.3
executing== 2.0.0
fastavro== 1.8.2
fastjsonschema== 2.18.1
filelock== 3.12.4
filetype== 1.2.0
flatbuffers== 23.5.26
fonttools== 4.52.4
fqdn== 1.5.1
frozenlist== 1.4.0
fsspec== 2023.9.2
gitdb== 4.0.11
GitPython== 3.1.41
google-auth== 2.29.0
googleapis-common-protos== 1.63.0
greenlet== 3.0.3
grpcio== 1.59.0
h11== 0.14.0
halo== 0.0.31
httpcore== 1.0.5
httptools== 0.6.0
httpx== 0.27.0
httpx-sse== 0.4.0
huggingface-hub== 0.23.2
humanfriendly== 10.0
idna== 3.4
importlib-metadata== 6.8.0
importlib-resources== 6.1.0
inference-tools== 0.13.0
install== 1.3.5
IProgress== 0.4
ipykernel== 6.25.2
ipython== 8.16.1
ipywidgets== 8.1.1
isoduration== 20.11.0
jedi== 0.19.1
Jinja2== 3.1.3
jmespath== 1.0.1
joblib== 1.3.2
json5== 0.9.14
jsonpatch== 1.33
jsonpointer== 2.4
jsonschema== 4.19.1
jsonschema-specifications== 2023.7.1
jupyter_client== 8.4.0
jupyter_core== 5.4.0
jupyter-events== 0.7.0
jupyter-lsp== 2.2.2
jupyter_server== 2.7.3
jupyter_server_terminals== 0.4.4
jupyterlab== 4.1.0b2
jupyterlab-pygments== 0.2.2
jupyterlab_server== 2.25.0
jupyterlab-widgets== 3.0.9
kiwisolver== 1.4.5
kubernetes== 29.0.0
langchain== 0.2.1
langchain-cli== 0.0.24
langchain-cohere== 0.1.5
langchain-community== 0.2.1
langchain-core== 0.2.2
langchain-text-splitters== 0.2.0
langchainhub== 0.1.13
langdetect== 1.0.9
langserve== 0.2.1
langsmith== 0.1.67
libcst== 1.4.0
log-symbols== 0.0.14
loguru== 0.7.2
lxml== 4.9.3
markdown-it-py== 3.0.0
MarkupSafe== 2.1.3
marshmallow== 3.20.1
matplotlib== 3.9.0
matplotlib-inline== 0.1.6
mdurl== 0.1.2
mention== 0.1
mistune== 3.0.2
mmh3== 4.1.0
modules== 1.0.0
monotonic== 1.6
mpmath== 1.3.0
multidict== 6.0.4
mypy-extensions== 1.0.0
nbclient== 0.8.0
nbconvert== 7.9.2
nbformat== 5.9.2
nest-asyncio== 1.5.8
networkx== 3.1
nltk== 3.8.1
notebook_shim== 0.2.3
numpy== 1.26.1
oauthlib== 3.2.2
oci== 2.126.4
onnxruntime== 1.18.0
openai== 0.28.1
opentelemetry-api== 1.24.0
opentelemetry-exporter-otlp-proto-common== 1.24.0
opentelemetry-exporter-otlp-proto-grpc== 1.24.0
opentelemetry-instrumentation== 0.45b0
opentelemetry-instrumentation-asgi== 0.45b0
opentelemetry-instrumentation-fastapi== 0.45b0
opentelemetry-proto== 1.24.0
opentelemetry-sdk== 1.24.0
opentelemetry-semantic-conventions== 0.45b0
opentelemetry-util-http== 0.45b0
oracledb== 2.2.1
orjson== 3.10.3
overrides== 7.4.0
packaging== 23.2
page== 0.2
pages== 0.3
pandas== 2.1.1
pandocfilters== 1.5.0
parso== 0.8.3
path== 16.14.0
pathspec== 0.11.2
pexpect== 4.8.0
pickleshare== 0.7.5
piglet-templates== 1.3.1
Pillow== 10.1.0
pip== 24.1.1
platformdirs== 3.11.0
posthog== 3.0.2
prometheus-client== 0.17.1
prompt-toolkit== 3.0.39
protobuf== 4.24.4
psutil== 5.9.6
ptyprocess== 0.7.0
pulsar-client== 3.5.0
pure-eval== 0.2.2
pyarrow== 16.1.0
pyasn1== 0.6.0
pyasn1_modules== 0.4.0
pycparser== 2.21
pydantic== 2.4.2
pydantic_core== 2.10.1
pydeck== 0.8.1b0
Pygments== 2.16.1
pyOpenSSL== 23.2.0
pyparsing== 3.1.2
pypdf== 3.17.0
PyPika== 0.48.9
pyproject_hooks== 1.1.0
pyproject-toml== 0.0.10
python-dateutil== 2.8.2
python-dotenv== 1.0.0
python-iso639== 2023.6.15
python-json-logger== 2.0.7
python-magic== 0.4.27
python-multipart== 0.0.9
pytz== 2023.3.post1
PyYAML== 6.0.1
pyzmq== 25.1.1
rapidfuzz== 3.4.0
referencing== 0.30.2
regex==2023.10.3
requests==2.31.0
requests-oauth2==0.3.0
requests-oauthlib==2.0.0
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rich==13.6.0
rpds-py==0.10.6
rsa==4.9
s3transfer==0.10.1
safetensors==0.4.3
scikit-learn==1.3.1
scipy==1.11.3
section==2.0
Send2Trash==1.8.2
sentence-transformers==2.2.2
sentencepiece==0.2.0
setuptools==70.0.0
shellingham==1.5.4
six==1.16.0
smmap==5.0.1
sniffio==1.3.0
soupsieve==2.5
spinners==0.0.24
SQLAlchemy==2.0.22
streamlit==1.30.0
streamlit-feedback==0.1.3
sympy==1.12
tabulate==0.9.0
tenacity==8.2.3
termcolor==2.3.0
terminado==0.17.1
threadpoolctl==3.2.0
tinycss2==1.2.1
tokenize-rt==5.2.0
tokenizers==0.19.1
toml==0.10.2
tomli==2.0.1
tomlkit==0.12.5
toolz==0.12.0
torch==2.2.2
torchvision==0.17.2
tornado==6.3.3
tqdm==4.66.1
traitlets==5.11.2
transformers==4.41.2
trubrics==1.6.2
typer==0.9.0
types-python-dateutil==2.8.19.14
types-requests==2.31.0.9
typing_extensions==4.8.0
typing-inspect==0.9.0
tzdata==2023.3
tzlocal==5.2
ujson==5.10.0
unstructured==0.10.23
uri-template==1.3.0
urllib3==2.0.7
uvicorn==0.23.2
uvloop==0.18.0
validators==0.22.0
watchdog==3.0.0
watchfiles==0.21.0
wcwidth==0.2.8
webcolors==1.13
webencodings==0.5.1
websocket-client==1.6.4
websockets==11.0.3
wheel==0.43.0
widgetsnbextension==4.0.9
wrapt==1.16.0
xmltodict==0.13.0
yarl==1.9.2
zipp==3.17.0

0 comments on commit 3851c88

Please sign in to comment.