|
23 | 23 | BLOCK_COMMANDS, LoopBreak, LoopContinue, |
24 | 24 | ) |
25 | 25 | from je_auto_control.utils.executor.mouse_aliases import MOUSE_BUTTON_COMMANDS |
| 26 | +from je_auto_control.utils.llm.planner import ( |
| 27 | + plan_actions as llm_plan_actions, |
| 28 | + run_from_description as llm_run_from_description, |
| 29 | +) |
26 | 30 | from je_auto_control.utils.ocr.ocr_engine import ( |
27 | 31 | click_text as ocr_click_text, |
28 | 32 | find_text_regex as ocr_find_text_regex, |
@@ -97,6 +101,34 @@ def _vlm_locate_as_list(description: str, |
97 | 101 | return None if coords is None else [coords[0], coords[1]] |
98 | 102 |
|
99 | 103 |
|
| 104 | +def _llm_plan_for_executor(description: str, |
| 105 | + examples: Optional[list] = None, |
| 106 | + model: Optional[str] = None, |
| 107 | + max_tokens: int = 2048) -> list: |
| 108 | + """Executor adapter: plan without executing, using current command set.""" |
| 109 | + return llm_plan_actions( |
| 110 | + description, |
| 111 | + known_commands=executor.known_commands(), |
| 112 | + examples=examples, |
| 113 | + model=model, |
| 114 | + max_tokens=int(max_tokens), |
| 115 | + ) |
| 116 | + |
| 117 | + |
| 118 | +def _llm_run_for_executor(description: str, |
| 119 | + examples: Optional[list] = None, |
| 120 | + model: Optional[str] = None, |
| 121 | + max_tokens: int = 2048) -> Dict[str, Any]: |
| 122 | + """Executor adapter: plan and execute against the global executor.""" |
| 123 | + return llm_run_from_description( |
| 124 | + description, |
| 125 | + executor=executor, |
| 126 | + examples=examples, |
| 127 | + model=model, |
| 128 | + max_tokens=int(max_tokens), |
| 129 | + ) |
| 130 | + |
| 131 | + |
100 | 132 | def _ocr_read_region_as_dicts(region: Optional[List[int]] = None, |
101 | 133 | lang: str = "eng", |
102 | 134 | min_confidence: float = 60.0) -> List[dict]: |
@@ -260,6 +292,10 @@ def __init__(self): |
260 | 292 | # MCP server (Model Context Protocol stdio bridge) |
261 | 293 | "AC_start_mcp_server": start_mcp_stdio_server, |
262 | 294 | "AC_start_mcp_http_server": start_mcp_http_server, |
| 295 | + |
| 296 | + # LLM action planner |
| 297 | + "AC_llm_plan": _llm_plan_for_executor, |
| 298 | + "AC_llm_run": _llm_run_for_executor, |
263 | 299 | } |
264 | 300 |
|
265 | 301 | def known_commands(self) -> set: |
|
0 commit comments