handle litellm APIError for the router and raise LLMProviderErrorRetryableTask (#750)
This commit is contained in:
@@ -5,7 +5,6 @@ from asyncio import CancelledError
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import litellm
|
import litellm
|
||||||
import openai
|
|
||||||
import structlog
|
import structlog
|
||||||
|
|
||||||
from skyvern.forge import app
|
from skyvern.forge import app
|
||||||
@@ -107,8 +106,8 @@ class LLMAPIHandlerFactory:
|
|||||||
LOG.info("Calling LLM API", llm_key=llm_key, model=llm_config.model_name)
|
LOG.info("Calling LLM API", llm_key=llm_key, model=llm_config.model_name)
|
||||||
response = await router.acompletion(model=main_model_group, messages=messages, **parameters)
|
response = await router.acompletion(model=main_model_group, messages=messages, **parameters)
|
||||||
LOG.info("LLM API call successful", llm_key=llm_key, model=llm_config.model_name)
|
LOG.info("LLM API call successful", llm_key=llm_key, model=llm_config.model_name)
|
||||||
except openai.OpenAIError as e:
|
except litellm.exceptions.APIError as e:
|
||||||
raise LLMProviderError(llm_key) from e
|
raise LLMProviderErrorRetryableTask(llm_key) from e
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.exception(
|
LOG.exception(
|
||||||
"LLM request failed unexpectedly",
|
"LLM request failed unexpectedly",
|
||||||
|
|||||||
Reference in New Issue
Block a user