Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
log duration and prompt_name in llm failure log (#2578)
Shuchang Zheng2ddcb9eb0b41
diff --git a/skyvern/forge/sdk/api/llm/api_handler_factory.py b/skyvern/forge/sdk/api/llm/api_handler_factory.pyindex c8b3864d7..46ef21a0a 100644--- a/skyvern/forge/sdk/api/llm/api_handler_factory.py+++ b/skyvern/forge/sdk/api/llm/api_handler_factory.py@@ -149,24 +149,33 @@ class LLMAPIHandlerFactory:except litellm.exceptions.APIError as e:raise LLMProviderErrorRetryableTask(local_llm_key) from eexcept litellm.exceptions.ContextWindowExceededError as e:+ duration_seconds = time.time() - start_timeLOG.exception("Context window exceeded",llm_key=local_llm_key,model=main_model_group,+ prompt_name=prompt_name,+ duration_seconds=duration_seconds,)raise SkyvernContextWindowExceededError() from eexcept ValueError as e:+ duration_seconds = time.time() - start_timeLOG.exception("LLM token limit exceeded",llm_key=local_llm_key,model=main_model_group,+ prompt_name=prompt_name,+ duration_seconds=duration_seconds,)raise LLMProviderErrorRetryableTask(local_llm_key) from eexcept Exception as e:+ duration_seconds = time.time() - start_timeLOG.exception("LLM request failed unexpectedly",llm_key=local_llm_key,model=main_model_group,+ prompt_name=prompt_name,+ duration_seconds=duration_seconds,)raise LLMProviderError(local_llm_key) from e@@ -352,10 +361,13 @@ class LLMAPIHandlerFactory:except litellm.exceptions.APIError as e:raise LLMProviderErrorRetryableTask(local_llm_key) from eexcept litellm.exceptions.ContextWindowExceededError as e:+ duration_seconds = time.time() - start_timeLOG.exception("Context window exceeded",llm_key=local_llm_key,model=model_name,+ prompt_name=prompt_name,+ duration_seconds=duration_seconds,)raise SkyvernContextWindowExceededError() from eexcept CancelledError:@@ -364,11 +376,19 @@ class LLMAPIHandlerFactory:"LLM request got cancelled",llm_key=local_llm_key,model=model_name,+ prompt_name=prompt_name,duration=t_llm_cancelled - t_llm_request,)raise LLMProviderError(local_llm_key)except Exception as e:- LOG.exception("LLM request failed unexpectedly", llm_key=local_llm_key)+ duration_seconds = time.time() - start_time+ LOG.exception(+ "LLM request failed unexpectedly",+ llm_key=local_llm_key,+ model=model_name,+ prompt_name=prompt_name,+ duration_seconds=duration_seconds,+ )raise LLMProviderError(local_llm_key) from eawait app.ARTIFACT_MANAGER.create_llm_artifact(