Skip to content

Commit ccfdb87

Browse files
committed
More improvements in the chatbot
1 parent bf6dbbb commit ccfdb87

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

python-rag-chatbot/init_rag.py

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

5050
# private configs
5151
CONFIG_PROFILE = "DEFAULT"
52-
COMPARTMENT_OCID = "ocid1.compartment.oc1..yourcompartmentid"
52+
COMPARTMENT_OCID = "ocid1.compartment.oc1..aaaaaaaajdyhd7dqnix2avhlckbhhkkcl3cujzyuz6jzyzonadca3i66pqjq"
5353
oci_config = oci.config.from_file("~/.oci/config", CONFIG_PROFILE)
5454
COHERE_API_KEY = oci_config['security_token_file']
5555
DEBUG = True
@@ -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..yourcompartmentid",
158+
compartment_id="ocid1.compartment.oc1..aaaaaaaajdyhd7dqnix2avhlckbhhkkcl3cujzyuz6jzyzonadca3i66pqjq",
159159
model_kwargs={"max_tokens": 1000},
160160
auth_type='SECURITY_TOKEN',
161161
)

python-rag-chatbot/init_rag_streamlit_exp.py

Lines changed: 5 additions & 3 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..yourcompartmentid"
66+
COMPARTMENT_OCID = "ocid1.compartment.oc1..aaaaaaaajdyhd7dqnix2avhlckbhhkkcl3cujzyuz6jzyzonadca3i66pqjq"
6767
oci_config = oci.config.from_file("~/.oci/config", CONFIG_PROFILE)
6868
COHERE_API_KEY = oci_config['security_token_file']
6969

@@ -134,6 +134,7 @@ def split_in_chunks(all_pages):
134134
splits = post_process(splits)
135135

136136
print(f"Splitted the pdf in {len(splits)} chunks...")
137+
print("Size of splits: " + str(text_splitter.__sizeof__()) + "bytes")
137138

138139
return splits
139140

@@ -252,7 +253,7 @@ def build_llm(llm_type):
252253
llm = OCIGenAI(
253254
model_id="cohere.command",
254255
service_endpoint="https://inference.generativeai.us-chicago-1.oci.oraclecloud.com",
255-
compartment_id="ocid1.compartment.oc1..yourcompartmentid",
256+
compartment_id="ocid1.compartment.oc1..aaaaaaaajdyhd7dqnix2avhlckbhhkkcl3cujzyuz6jzyzonadca3i66pqjq",
256257
model_kwargs={"max_tokens": 200},
257258
auth_type='SECURITY_TOKEN',
258259
)
@@ -284,13 +285,14 @@ def initialize_rag_chain():
284285

285286
# 3. Load embeddings model
286287
embedder = create_cached_embedder()
287-
288+
print("Size of splits---: " + str(document_splits.__sizeof__()) + "bytes")
288289
# 4. Create a Vectore Store and store embeddings
289290
vectorstore = create_vector_store(VECTOR_STORE_NAME, document_splits, embedder)
290291

291292
# 5. Create a retriever
292293
# increased num. of docs to 5 (default to 4)
293294
# added optionally a reranker
295+
294296
retriever = create_retriever(vectorstore)
295297

296298
# 6. Build the LLM

python-rag-chatbot/oracle_bot_exp.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
import streamlit as st
2-
import time
2+
33
import traceback
44
import sys
55

66
from init_rag_streamlit_exp import initialize_rag_chain, get_answer
77

88
from streamlit_feedback import streamlit_feedback
99

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

16+
1517
def reset_conversation():
1618
st.session_state.messages = []
1719
st.session_state.feedback_rendered = False
1820
st.session_state.feedback_key = 0
1921

22+
2023
st.title("Developing an AI bot powered by RAG and Oracle Database")
2124

2225
# Added reset button
@@ -56,6 +59,7 @@ def _submit_feedback(feedback_value, *args, **kwargs):
5659
process_feedback(feedback_value)
5760
st.session_state.feedback_rendered = False
5861

62+
5963
feedback_component = streamlit_feedback(
6064
feedback_type="faces",
6165
on_submit=_submit_feedback,

0 commit comments

Comments
 (0)