Skip to content

Commit 50fb031

Browse files
authored
Catch exception when RAG not set. (#50)
1 parent 61b5702 commit 50fb031

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

app/src/modules/utilities.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -235,19 +235,24 @@ def init_vs(db_conn, embedding_function, store_table, distance_metric):
235235

236236
def get_vs_table(model, chunk_size, chunk_overlap, distance_metric, embed_alias=None):
237237
"""Return the concatenated VS Table name and comment"""
238-
chunk_overlap_ceil = math.ceil(chunk_overlap)
239-
table_string = f"{model}_{chunk_size}_{chunk_overlap_ceil}_{distance_metric}"
240-
if embed_alias:
241-
table_string = f"{embed_alias}_{table_string}"
242-
store_table = re.sub(r"\W", "_", table_string.upper())
243-
store_comment = (
244-
f'{{"alias": "{embed_alias}",'
245-
f'"model": "{model}",'
246-
f'"chunk_size": {chunk_size},'
247-
f'"chunk_overlap": {chunk_overlap_ceil},'
248-
f'"distance_metric": "{distance_metric}"}}'
249-
)
250-
logger.info("Vector Store Table: %s; Comment: %s", store_table, store_comment)
238+
store_table = None
239+
store_comment = None
240+
try:
241+
chunk_overlap_ceil = math.ceil(chunk_overlap)
242+
table_string = f"{model}_{chunk_size}_{chunk_overlap_ceil}_{distance_metric}"
243+
if embed_alias:
244+
table_string = f"{embed_alias}_{table_string}"
245+
store_table = re.sub(r"\W", "_", table_string.upper())
246+
store_comment = (
247+
f'{{"alias": "{embed_alias}",'
248+
f'"model": "{model}",'
249+
f'"chunk_size": {chunk_size},'
250+
f'"chunk_overlap": {chunk_overlap_ceil},'
251+
f'"distance_metric": "{distance_metric}"}}'
252+
)
253+
logger.info("Vector Store Table: %s; Comment: %s", store_table, store_comment)
254+
except TypeError:
255+
logger.fatal("Not all required values provided to get Vector Store Table name.")
251256
return store_table, store_comment
252257

253258

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

@@ -370,7 +376,6 @@ def get_vs_tables(conn, enabled_embed):
370376

371377
return json.dumps(output, indent=4)
372378

373-
374379
###############################################################################
375380
# Oracle Cloud Infrastructure
376381
###############################################################################

docs/content/walkthrough/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ To start Oracle Database 23ai Free:
114114

115115
alter session set container=FREEPDB1;
116116

117-
CREATE USER "WALKTHROUGH" IDENTIFIED BY ORA_41_M_SANDBOX
117+
CREATE USER "WALKTHROUGH" IDENTIFIED BY OrA_41_M_SANDBOX
118118
DEFAULT TABLESPACE "USERS"
119119
TEMPORARY TABLESPACE "TEMP";
120120
GRANT "DB_DEVELOPER_ROLE" TO "WALKTHROUGH";

0 commit comments

Comments
 (0)