Merge pull request #1735 from NousResearch/fix/tool-handler-safety
fix(tools): browser handlers TypeError on unexpected LLM params + fuzzy_match docstring
This commit is contained in:
commit
23a3f01b2b
2 changed files with 11 additions and 10 deletions
|
|
@ -1734,7 +1734,7 @@ registry.register(
|
||||||
name="browser_click",
|
name="browser_click",
|
||||||
toolset="browser",
|
toolset="browser",
|
||||||
schema=_BROWSER_SCHEMA_MAP["browser_click"],
|
schema=_BROWSER_SCHEMA_MAP["browser_click"],
|
||||||
handler=lambda args, **kw: browser_click(**args, task_id=kw.get("task_id")),
|
handler=lambda args, **kw: browser_click(ref=args.get("ref", ""), task_id=kw.get("task_id")),
|
||||||
check_fn=check_browser_requirements,
|
check_fn=check_browser_requirements,
|
||||||
emoji="👆",
|
emoji="👆",
|
||||||
)
|
)
|
||||||
|
|
@ -1742,7 +1742,7 @@ registry.register(
|
||||||
name="browser_type",
|
name="browser_type",
|
||||||
toolset="browser",
|
toolset="browser",
|
||||||
schema=_BROWSER_SCHEMA_MAP["browser_type"],
|
schema=_BROWSER_SCHEMA_MAP["browser_type"],
|
||||||
handler=lambda args, **kw: browser_type(**args, task_id=kw.get("task_id")),
|
handler=lambda args, **kw: browser_type(ref=args.get("ref", ""), text=args.get("text", ""), task_id=kw.get("task_id")),
|
||||||
check_fn=check_browser_requirements,
|
check_fn=check_browser_requirements,
|
||||||
emoji="⌨️",
|
emoji="⌨️",
|
||||||
)
|
)
|
||||||
|
|
@ -1750,7 +1750,7 @@ registry.register(
|
||||||
name="browser_scroll",
|
name="browser_scroll",
|
||||||
toolset="browser",
|
toolset="browser",
|
||||||
schema=_BROWSER_SCHEMA_MAP["browser_scroll"],
|
schema=_BROWSER_SCHEMA_MAP["browser_scroll"],
|
||||||
handler=lambda args, **kw: browser_scroll(**args, task_id=kw.get("task_id")),
|
handler=lambda args, **kw: browser_scroll(direction=args.get("direction", "down"), task_id=kw.get("task_id")),
|
||||||
check_fn=check_browser_requirements,
|
check_fn=check_browser_requirements,
|
||||||
emoji="📜",
|
emoji="📜",
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -6,16 +6,17 @@ Implements a multi-strategy matching chain to robustly find and replace text,
|
||||||
accommodating variations in whitespace, indentation, and escaping common
|
accommodating variations in whitespace, indentation, and escaping common
|
||||||
in LLM-generated code.
|
in LLM-generated code.
|
||||||
|
|
||||||
The 9-strategy chain (inspired by OpenCode):
|
The 8-strategy chain (inspired by OpenCode), tried in order:
|
||||||
1. Exact match - Direct string comparison
|
1. Exact match - Direct string comparison
|
||||||
2. Line-trimmed - Strip leading/trailing whitespace per line
|
2. Line-trimmed - Strip leading/trailing whitespace per line
|
||||||
3. Block anchor - Match first+last lines, use similarity for middle
|
3. Whitespace normalized - Collapse multiple spaces/tabs to single space
|
||||||
4. Whitespace normalized - Collapse multiple spaces/tabs to single space
|
4. Indentation flexible - Ignore indentation differences entirely
|
||||||
5. Indentation flexible - Ignore indentation differences entirely
|
5. Escape normalized - Convert \\n literals to actual newlines
|
||||||
6. Escape normalized - Convert \\n literals to actual newlines
|
6. Trimmed boundary - Trim first/last line whitespace only
|
||||||
7. Trimmed boundary - Trim first/last line whitespace only
|
7. Block anchor - Match first+last lines, use similarity for middle
|
||||||
8. Context-aware - 50% line similarity threshold
|
8. Context-aware - 50% line similarity threshold
|
||||||
9. Multi-occurrence - For replace_all flag
|
|
||||||
|
Multi-occurrence matching is handled via the replace_all flag.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
from tools.fuzzy_match import fuzzy_find_and_replace
|
from tools.fuzzy_match import fuzzy_find_and_replace
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue