|
10 | 10 | from langrocks.client import WebBrowser as WebBrowserClient |
11 | 11 | from langrocks.common.models.web_browser import ( |
12 | 12 | WebBrowserCommand, |
| 13 | + WebBrowserCommandOutput, |
13 | 14 | WebBrowserCommandType, |
14 | 15 | WebBrowserContent, |
| 16 | + WebBrowserResponse, |
15 | 17 | ) |
16 | 18 | from pydantic import BaseModel, Field |
17 | 19 |
|
@@ -434,8 +436,49 @@ def _execute_anthropic_instruction_in_browser( |
434 | 436 | ), |
435 | 437 | ] |
436 | 438 | ) |
| 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 | + ) |
437 | 471 | 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 | + ) |
439 | 482 |
|
440 | 483 | def _process_anthropic(self) -> dict: |
441 | 484 | client = get_llm_client_from_provider_config( |
|
0 commit comments