forked from phoenix/litellm-mirror
error handling for huggingface endpoints
This commit is contained in:
parent
f898693c9c
commit
15944eb0f3
6 changed files with 7 additions and 5 deletions
|
@ -315,6 +315,8 @@ def completion(
|
|||
response = requests.post(API_URL, headers=headers, json=input_payload)
|
||||
## LOGGING
|
||||
logging(model=model, input=prompt, custom_llm_provider=custom_llm_provider, additional_args={"max_tokens": max_tokens, "original_response": response.text}, logger_fn=logger_fn)
|
||||
if isinstance(response, dict) and "error" in response:
|
||||
raise Exception(response["error"])
|
||||
completion_response = response.json()[0]['generated_text']
|
||||
prompt_tokens = len(encoding.encode(prompt))
|
||||
completion_tokens = len(encoding.encode(completion_response))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue