This repository has been archived by the owner on Nov 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Slightly improve error handling for external providers (#220)
* [kb] Improve error handling for OpenAIRecord encoder Catch specific OpenAI errors and re-raise with a clear message * [kb] Improve the error in case of failing to infer dimensionality * Added option to ignore specific warnings, or ignore warnings from a specific module In addition, the `transformers` module is very insisstent, so I added their dedicated mechanism for silencing warnings * Bug fix - infering dimension incorrectly * [CLI] Removed dedicated error message for OpenAI auth problem Instead, individual RecordEncoders and LLMs would need to raise their own errors * [server] Call health_check() on startup To detect errors early * [cli] Bug fix - validate function did not connect to KB * [LLM] Explicit error when initializing and when using OpenAI components - both LLM and RecordEncoder * [kb] Slightly better solution for error handling Catch the error in RecordEncoder base class, then format for each inhertor differently * linter * revert accidental commit * [test] KB test - improved dimension infer testing 1. Needed to change after code was changed. 2. Added a few more test cases 3. Added more assertions on the naive create() * [test] Fix LLM tests after error handling Some error types changed * [cli] Improve error message in case of index already exists The CLI shouldn't mention `delete_index()` * [CLI] Improve ChatEngine validate - use less tokens Sending just "hello" without any limitations can use many tokens * [LLM] Explicit error for function calling failed Based on feedback in PR #220
- Loading branch information
1 parent
4eac053
commit bd1c039
Showing
11 changed files
with
184 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,25 @@ | ||
import importlib.metadata | ||
import warnings | ||
import logging | ||
import os | ||
from typing import List | ||
|
||
# Taken from https://stackoverflow.com/a/67097076 | ||
__version__ = importlib.metadata.version("canopy-sdk") | ||
|
||
|
||
IGNORED_WARNINGS: List[str] = [ | ||
] | ||
|
||
IGNORED_WARNING_IN_MODULES = [ | ||
"transformers", | ||
] | ||
|
||
for warning in IGNORED_WARNINGS: | ||
warnings.filterwarnings("ignore", message=warning) | ||
for module in IGNORED_WARNING_IN_MODULES: | ||
warnings.filterwarnings("ignore", module=module) | ||
logging.getLogger(module).setLevel(logging.ERROR) | ||
|
||
# Apparently, `transformers` has its own logging system, and needs to be silenced separately # noqa: E501 | ||
os.environ["TRANSFORMERS_VERBOSITY"] = "error" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.