Skip to content

Commit a87fcb2

Browse files
committed
More improvements in the chatbot
1 parent 4003cf0 commit a87fcb2

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

python-rag-chatbot/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@
1010
## TODO instructions
1111

1212
- setup ~/.oci/config
13-
- set yourcompartmentid
13+
- oci session authenticate and make sure authentication is successful
14+
- use region where the OCI gen AI is available. Currently we are using chicago region.
15+
- run pip install -r requirements.txt
16+
- check you config_rag.py file and make sure your api endpoint belong to chicago region and db which you want to use like chroma db or oracle db
17+
- set your compartment_id ocid inside the file i.e. init_rag_streamlit_exp.py and init_rag.py file
18+
- Changing the db type you need to modify at config file and you see the logic inside create_vector_store
1419
- podman run -d --name 23ai -p 1521:1521 -e ORACLE_PWD=<password> -v oracle-volume:/Users/pparkins/oradata container-registry.oracle.com/database/free:latest
1520
- create/config vector tablespace and user
1621
- add oracle database info for use in init_rag_streamlit.py / init_rag_streamlit_exp.py
17-
- run run_oracle_bot.sh /run_oracle_bot_exp.sh
22+
- run ./run_oracle_bot_exp.sh
1823

1924

2025
## Documentation

python-rag-chatbot/config_rag.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@
44
DEBUG = False
55

66
# book to use for augmentation
7-
# BOOK1 = "APISpec.pdf"
7+
88
BOOK1 = "pdfFiles/sharding-adg-addshard-cookbook-3610618.pdf"
99
BOOK2 = "pdfFiles/globally-distributed-autonomous-database.pdf"
10-
# BOOK4 = "OnBoardingGuide.pdf"
11-
# BOOK5 = "CreateWorkFlow.pdf"
12-
# BOOK6 = "Team Onboarding.pdf"
13-
# BOOK7 = "workflow.pdf"
1410
BOOK3 = "pdfFiles/oracle-database-23c.pdf"
1511
BOOK4 = "pdfFiles/oracle-globally-distributed-database-guide.pdf"
1612
BOOK5 = "pdfFiles/Oracle True cache.pdf"
1713
BOOK6 = "pdfFiles/Trobleshooting.pdf"
18-
# BOOK12 = "OsdCode.pdf"
14+
1915

2016
BOOK_LIST = [BOOK1, BOOK2, BOOK3, BOOK4, BOOK5, BOOK6]
2117

python-rag-chatbot/init_rag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def initialize_rag_chain():
155155

156156
llm = OCIGenAI(
157157
service_endpoint="https://inference.generativeai.us-chicago-1.oci.oraclecloud.com",
158-
compartment_id="ocid1.compartment.oc1..aaaaaaaajdyhd7dqnix2avhlckbhhkkcl3cujzyuz6jzyzonadca3i66pqjq",
158+
compartment_id="ocid1.compartment.oc1..yourcompartment",
159159
model_kwargs={"max_tokens": 1000},
160160
auth_type='SECURITY_TOKEN',
161161
)

python-rag-chatbot/init_rag_streamlit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262

6363
# private configs
6464
CONFIG_PROFILE = "DEFAULT"
65-
COMPARTMENT_OCID = "ocid1.compartment.oc1..aaaaaaaajdyhd7dqnix2avhlckbhhkkcl3cujzyuz6jzyzonadca3i66pqjq"
65+
COMPARTMENT_OCID = "ocid1.compartment.oc1..yourcompartment"
6666
oci_config = oci.config.from_file("~/.oci/config", CONFIG_PROFILE)
6767
COHERE_API_KEY = oci_config['key_file']
6868
#

python-rag-chatbot/init_rag_streamlit_exp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
# private configs
6565
CONFIG_PROFILE = "DEFAULT"
66-
COMPARTMENT_OCID = "ocid1.compartment.oc1..aaaaaaaajdyhd7dqnix2avhlckbhhkkcl3cujzyuz6jzyzonadca3i66pqjq"
66+
COMPARTMENT_OCID = "ocid1.compartment.oc1..yourcompartment"
6767
oci_config = oci.config.from_file("~/.oci/config", CONFIG_PROFILE)
6868
COHERE_API_KEY = oci_config['security_token_file']
6969

@@ -253,7 +253,7 @@ def build_llm(llm_type):
253253
llm = OCIGenAI(
254254
model_id="cohere.command",
255255
service_endpoint="https://inference.generativeai.us-chicago-1.oci.oraclecloud.com",
256-
compartment_id="ocid1.compartment.oc1..aaaaaaaajdyhd7dqnix2avhlckbhhkkcl3cujzyuz6jzyzonadca3i66pqjq",
256+
compartment_id="ocid1.compartment.oc1..yourCompartment",
257257
model_kwargs={"max_tokens": 200},
258258
auth_type='SECURITY_TOKEN',
259259
)

python-rag-chatbot/oracle_bot_exp.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
import streamlit as st
2-
32
import traceback
43
import sys
5-
64
from init_rag_streamlit_exp import initialize_rag_chain, get_answer
7-
85
from streamlit_feedback import streamlit_feedback
96

10-
117
def process_feedback(feedback_value):
12-
st.write("Feedback value:", feedback_value)
13-
with open("feedback.txt", "a", encoding="utf-8") as f:
14-
f.write(f"{feedback_value}\n")
15-
8+
st.write("Processing feedback value:", feedback_value) # Debugging output
9+
try:
10+
with open("feedback.txt", "a", encoding="utf-8") as f:
11+
f.write(f"{feedback_value}\n")
12+
st.write("Feedback successfully written to file.") # Debugging output
13+
except Exception as e:
14+
st.error(f"Error writing to file: {e}")
15+
traceback.print_exc()
1616

1717
def reset_conversation():
1818
st.session_state.messages = []
1919
st.session_state.feedback_rendered = False
2020
st.session_state.feedback_key = 0
2121

22-
2322
st.title("Developing an AI bot powered by RAG and Oracle Database")
2423

2524
# Added reset button
@@ -56,10 +55,10 @@ def reset_conversation():
5655
if not st.session_state.feedback_rendered:
5756
def _submit_feedback(feedback_value, *args, **kwargs):
5857
print("Feedback submitted:", feedback_value, file=sys.stderr) # Redirect to stderr
58+
st.write("Feedback value received for submission:", feedback_value) # Debugging output
5959
process_feedback(feedback_value)
6060
st.session_state.feedback_rendered = False
6161

62-
6362
feedback_component = streamlit_feedback(
6463
feedback_type="faces",
6564
on_submit=_submit_feedback,

0 commit comments

Comments
 (0)