Skip to content

Commit

Permalink
Exception handling in case an incorrect key is loaded.
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanlacerenza committed Nov 17, 2023
1 parent 11b86cf commit e0a5086
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion core/cat/routes/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def get_llm_settings(request: Request, languageModelName: str) -> Dict:
"value": setting,
"schema": schema
}



@router.put("/settings/{languageModelName}")
Expand Down Expand Up @@ -119,7 +120,19 @@ def upsert_llm_setting(
# crete new collections
# (in case embedder is not configured, it will be changed automatically and aligned to vendor)
# TODO: should we take this feature away?
ccat.load_memory()
# Exception handling in case an incorrect key is loaded.
try:
ccat.load_memory()
except Exception as e:
log.error(e)
crud.delete_settings_by_category(category=LLM_SELECTED_CATEGORY)
crud.delete_settings_by_category(category=LLM_CATEGORY)
raise HTTPException(
status_code=400,
detail={
"error": str(e)
}
)
# recreate tools embeddings
ccat.mad_hatter.find_plugins()
ccat.mad_hatter.embed_tools()
Expand Down

0 comments on commit e0a5086

Please sign in to comment.