Skip to content

Commit e0a5086

Browse files
Exception handling in case an incorrect key is loaded.
1 parent 11b86cf commit e0a5086

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

core/cat/routes/llm.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def get_llm_settings(request: Request, languageModelName: str) -> Dict:
7979
"value": setting,
8080
"schema": schema
8181
}
82+
8283

8384

8485
@router.put("/settings/{languageModelName}")
@@ -119,7 +120,19 @@ def upsert_llm_setting(
119120
# crete new collections
120121
# (in case embedder is not configured, it will be changed automatically and aligned to vendor)
121122
# TODO: should we take this feature away?
122-
ccat.load_memory()
123+
# Exception handling in case an incorrect key is loaded.
124+
try:
125+
ccat.load_memory()
126+
except Exception as e:
127+
log.error(e)
128+
crud.delete_settings_by_category(category=LLM_SELECTED_CATEGORY)
129+
crud.delete_settings_by_category(category=LLM_CATEGORY)
130+
raise HTTPException(
131+
status_code=400,
132+
detail={
133+
"error": str(e)
134+
}
135+
)
123136
# recreate tools embeddings
124137
ccat.mad_hatter.find_plugins()
125138
ccat.mad_hatter.embed_tools()

0 commit comments

Comments
 (0)