mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-04-28 11:40:47 +00:00
v0.9.5-pre cleanup, polishing, bugfixing
This commit is contained in:
parent
ca7a069891
commit
0aacdf98bc
42 changed files with 419 additions and 276 deletions
|
|
@ -0,0 +1,31 @@
|
|||
from typing import Any
|
||||
from python.helpers.extension import Extension
|
||||
from python.helpers.strings import replace_file_includes
|
||||
|
||||
|
||||
class ReplaceIncludeAlias(Extension):
|
||||
async def execute(
|
||||
self,
|
||||
loop_data=None,
|
||||
text: str = "",
|
||||
parsed: dict[str, Any] | None = None,
|
||||
**kwargs
|
||||
):
|
||||
if not parsed or not isinstance(parsed, dict):
|
||||
return
|
||||
|
||||
def replace_placeholders(value: Any) -> Any:
|
||||
if isinstance(value, str):
|
||||
new_val = value
|
||||
new_val = replace_file_includes(new_val, r"§§include\(([^)]+)\)")
|
||||
return new_val
|
||||
if isinstance(value, dict):
|
||||
return {k: replace_placeholders(v) for k, v in value.items()}
|
||||
if isinstance(value, list):
|
||||
return [replace_placeholders(v) for v in value]
|
||||
if isinstance(value, tuple):
|
||||
return tuple(replace_placeholders(v) for v in value)
|
||||
return value
|
||||
|
||||
if "tool_args" in parsed and "tool_name" in parsed:
|
||||
parsed["tool_args"] = replace_placeholders(parsed["tool_args"])
|
||||
Loading…
Add table
Add a link
Reference in a new issue