Skip to content

Commit 91a6b0f

Browse files
committed
Handle additional anthropic computer use commands
1 parent 245bb1a commit 91a6b0f

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

llmstack/processors/providers/promptly/web_browser.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
from langrocks.client import WebBrowser as WebBrowserClient
1111
from langrocks.common.models.web_browser import (
1212
WebBrowserCommand,
13+
WebBrowserCommandOutput,
1314
WebBrowserCommandType,
1415
WebBrowserContent,
16+
WebBrowserResponse,
1517
)
1618
from pydantic import BaseModel, Field
1719

@@ -434,8 +436,49 @@ def _execute_anthropic_instruction_in_browser(
434436
),
435437
]
436438
)
439+
elif instruction_input.get("action") == "right_click":
440+
return web_browser.run_commands(
441+
commands=[
442+
WebBrowserCommand(
443+
command_type=WebBrowserCommandType.RIGHT_CLICK,
444+
)
445+
]
446+
)
447+
elif instruction_input.get("action") == "middle_click":
448+
return web_browser.run_commands(
449+
commands=[
450+
WebBrowserCommand(
451+
command_type=WebBrowserCommandType.MIDDLE_CLICK,
452+
)
453+
]
454+
)
455+
elif instruction_input.get("action") == "double_click":
456+
return web_browser.run_commands(
457+
commands=[
458+
WebBrowserCommand(
459+
command_type=WebBrowserCommandType.DOUBLE_CLICK,
460+
)
461+
]
462+
)
463+
elif instruction_input.get("action") == "cursor_position":
464+
return web_browser.run_commands(
465+
commands=[
466+
WebBrowserCommand(
467+
command_type=WebBrowserCommandType.CURSOR_POSITION,
468+
)
469+
]
470+
)
437471
else:
438-
raise Exception("Invalid instruction")
472+
return WebBrowserResponse(
473+
content=WebBrowserContent(
474+
command_outputs=[
475+
WebBrowserCommandOutput(
476+
index=0,
477+
output="We do not currently support this action",
478+
)
479+
],
480+
),
481+
)
439482

440483
def _process_anthropic(self) -> dict:
441484
client = get_llm_client_from_provider_config(

0 commit comments

Comments
 (0)