raise exception if optional param is not mapped to model

This commit is contained in:
Krrish Dholakia 2023-10-02 11:17:44 -07:00
parent 49f65b7eb8
commit 1cae080eb2
8 changed files with 155 additions and 112 deletions

View file

@ -17,6 +17,11 @@ class HuggingfaceError(Exception):
self.message
) # Call the base class constructor with the parameters it needs
# contains any default values we need to pass to the provider
HuggingfaceConfig = {
"return_full_text": False # override by setting - completion(..,return_full_text=True)
}
def validate_environment(api_key):
headers = {
"content-type": "application/json",
@ -101,6 +106,11 @@ def completion(
else:
completion_url = f"https://api-inference.huggingface.co/models/{model}"
## Load Config
for k, v in HuggingfaceConfig.items():
if k not in optional_params:
optional_params[k] = v
### MAP INPUT PARAMS
if task == "conversational":
inference_params = copy.deepcopy(optional_params)