Skip to content

Commit

Permalink
Merge pull request #573 from ethanlacerenza/devolp-issue#572
Browse files Browse the repository at this point in the history
Fix Exception handling in case an incorrect key is loaded.
  • Loading branch information
pieroit authored Nov 20, 2023
2 parents 0f32919 + f9921a9 commit a6769cd
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions core/cat/routes/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def get_llm_settings(request: Request, languageModelName: str) -> Dict:
"value": setting,
"schema": schema
}


@router.put("/settings/{languageModelName}")
def upsert_llm_setting(
Expand Down Expand Up @@ -119,7 +119,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 a6769cd

Please sign in to comment.