Skip to content

Commit

Permalink
Catch exception when RAG not set. (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
gotsysdba authored Nov 21, 2024
1 parent 61b5702 commit 50fb031
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
35 changes: 20 additions & 15 deletions app/src/modules/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,19 +235,24 @@ def init_vs(db_conn, embedding_function, store_table, distance_metric):

def get_vs_table(model, chunk_size, chunk_overlap, distance_metric, embed_alias=None):
"""Return the concatenated VS Table name and comment"""
chunk_overlap_ceil = math.ceil(chunk_overlap)
table_string = f"{model}_{chunk_size}_{chunk_overlap_ceil}_{distance_metric}"
if embed_alias:
table_string = f"{embed_alias}_{table_string}"
store_table = re.sub(r"\W", "_", table_string.upper())
store_comment = (
f'{{"alias": "{embed_alias}",'
f'"model": "{model}",'
f'"chunk_size": {chunk_size},'
f'"chunk_overlap": {chunk_overlap_ceil},'
f'"distance_metric": "{distance_metric}"}}'
)
logger.info("Vector Store Table: %s; Comment: %s", store_table, store_comment)
store_table = None
store_comment = None
try:
chunk_overlap_ceil = math.ceil(chunk_overlap)
table_string = f"{model}_{chunk_size}_{chunk_overlap_ceil}_{distance_metric}"
if embed_alias:
table_string = f"{embed_alias}_{table_string}"
store_table = re.sub(r"\W", "_", table_string.upper())
store_comment = (
f'{{"alias": "{embed_alias}",'
f'"model": "{model}",'
f'"chunk_size": {chunk_size},'
f'"chunk_overlap": {chunk_overlap_ceil},'
f'"distance_metric": "{distance_metric}"}}'
)
logger.info("Vector Store Table: %s; Comment: %s", store_table, store_comment)
except TypeError:
logger.fatal("Not all required values provided to get Vector Store Table name.")
return store_table, store_comment


Expand Down Expand Up @@ -332,7 +337,8 @@ def json_to_doc(file: str):
# Build the Index
logger.info("Creating index on: %s", store_table)
try:
LangchainVS.create_index(db_conn, vectorstore)
params = {"idx_name": f"{store_table}_HNSW_IDX", "idx_type": "HNSW"}
LangchainVS.create_index(db_conn, vectorstore, params)
except Exception as ex:
logger.error("Unable to create vector index: %s", ex)

Expand Down Expand Up @@ -370,7 +376,6 @@ def get_vs_tables(conn, enabled_embed):

return json.dumps(output, indent=4)


###############################################################################
# Oracle Cloud Infrastructure
###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion docs/content/walkthrough/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ To start Oracle Database 23ai Free:

alter session set container=FREEPDB1;

CREATE USER "WALKTHROUGH" IDENTIFIED BY ORA_41_M_SANDBOX
CREATE USER "WALKTHROUGH" IDENTIFIED BY OrA_41_M_SANDBOX
DEFAULT TABLESPACE "USERS"
TEMPORARY TABLESPACE "TEMP";
GRANT "DB_DEVELOPER_ROLE" TO "WALKTHROUGH";
Expand Down

0 comments on commit 50fb031

Please sign in to comment.