Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
use anthropic beta client (#2235)
Shuchang Zhenga8d237deeea4
diff --git a/skyvern/forge/agent.py b/skyvern/forge/agent.pyindex 37e370323..79586bee3 100644--- a/skyvern/forge/agent.py+++ b/skyvern/forge/agent.py@@ -1433,7 +1433,6 @@ class ForgeAgent:raw_response=True,betas=["computer-use-2025-01-24"],)- LOG.info("Anthropic response", llm_response=llm_response)assistant_content = llm_response["content"]llm_caller.message_history.append({"role": "assistant", "content": assistant_content})diff --git a/skyvern/forge/sdk/api/llm/api_handler_factory.py b/skyvern/forge/sdk/api/llm/api_handler_factory.pyindex 1386d295c..d704efaa0 100644--- a/skyvern/forge/sdk/api/llm/api_handler_factory.py+++ b/skyvern/forge/sdk/api/llm/api_handler_factory.py@@ -6,7 +6,7 @@ from typing import Anyimport litellmimport structlog-from anthropic.types.message import Message as AnthropicMessage+from anthropic.types.beta.beta_message import BetaMessage as AnthropicMessagefrom jinja2 import Templatefrom litellm.utils import CustomStreamWrapper, ModelResponse@@ -678,7 +678,7 @@ class LLMCaller:) -> AnthropicMessage:max_tokens = active_parameters.get("max_completion_tokens") or active_parameters.get("max_tokens") or 4096model_name = self.llm_config.model_name.replace("bedrock/", "").replace("anthropic/", "")- return await app.ANTHROPIC_CLIENT.messages.create(+ response = await app.ANTHROPIC_CLIENT.beta.messages.create(max_tokens=max_tokens,messages=messages,model=model_name,@@ -686,6 +686,8 @@ class LLMCaller:timeout=timeout,betas=active_parameters.get("betas", None),)+ LOG.info("Anthropic response", response=response)+ return responseclass LLMCallerManager:diff --git a/skyvern/webeye/actions/parse_actions.py b/skyvern/webeye/actions/parse_actions.pyindex 8e0cd40d2..325705d57 100644--- a/skyvern/webeye/actions/parse_actions.py+++ b/skyvern/webeye/actions/parse_actions.py@@ -482,7 +482,6 @@ async def parse_anthropic_actions(tool_call_id=tool_call_id,))- idx += 1elif action == "left_click":if idx - 1 >= 0:prev_tool_call = tool_calls[idx - 1]@@ -494,12 +493,12 @@ async def parse_anthropic_actions(else:coordinate = parsed_args.get("coordinate")- idx += 1if not coordinate:LOG.warning("Left click action has no coordinate and it doesn't have mouse_move before it",tool_call=tool_call,)+ idx += 1continuex, y = coordinateactions.append(@@ -519,12 +518,12 @@ async def parse_anthropic_actions()elif action == "type":text = parsed_args.get("text")- idx += 1if not text:LOG.warning("Type action has no text",tool_call=tool_call,)+ idx += 1continueactions.append(InputTextAction(@@ -541,12 +540,12 @@ async def parse_anthropic_actions()elif action == "key":text = parsed_args.get("text")- idx += 1if not text:LOG.warning("Key action has no text",tool_call=tool_call,)+ idx += 1continueactions.append(KeypressAction(@@ -561,12 +560,24 @@ async def parse_anthropic_actions(tool_call_id=tool_call_id,))+ elif action == "screenshot":+ actions.append(+ NullAction(+ organization_id=task.organization_id,+ workflow_run_id=task.workflow_run_id,+ task_id=task.task_id,+ step_id=step.step_id,+ step_order=step.order,+ action_order=idx,+ tool_call_id=tool_call_id,+ )+ )else:LOG.error("Unsupported action",tool_call=tool_call,)- idx += 1+ idx += 1return actions