-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathtools.py
More file actions
74 lines (56 loc) · 2.18 KB
/
Copy pathtools.py
File metadata and controls
74 lines (56 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"""Bash tool spec and LLM provider factory for A-Evolve."""
from __future__ import annotations
import subprocess
from pathlib import Path
from ...config import EvolveConfig
from ...llm.base import LLMProvider
BASH_TOOL_SPEC = {
"name": "workspace_bash",
"description": (
"Execute a bash command in the agent workspace directory. "
"Use this to read/write skills, prompts, memory files, and inspect git history."
),
"input_schema": {
"type": "object",
"properties": {
"command": {
"type": "string",
"description": "The bash command to execute in the workspace directory.",
},
},
"required": ["command"],
},
}
def make_workspace_bash(workspace_root: str | Path):
"""Create a bash callable scoped to the workspace directory."""
def bash(command: str) -> str:
try:
result = subprocess.run(
["bash", "-c", command],
capture_output=True,
text=True,
timeout=60,
cwd=str(workspace_root),
)
output = (result.stdout + result.stderr).strip()
return output if output else "(no output)"
except subprocess.TimeoutExpired:
return "ERROR: Command timed out."
except Exception as e:
return f"ERROR: {e}"
return bash
def create_default_llm(config: EvolveConfig) -> LLMProvider:
"""Create the default LLM provider based on the evolver_model config string."""
model = config.evolver_model
if "." in model and ("anthropic" in model or "amazon" in model or "meta" in model):
from ...llm.bedrock import BedrockProvider
region = config.extra.get("region", "us-west-2")
return BedrockProvider(model_id=model, region=region)
if model.startswith("claude"):
from ...llm.anthropic import AnthropicProvider
return AnthropicProvider(model=model)
if model.startswith(("gpt-", "o1", "o3")):
from ...llm.openai import OpenAIProvider
return OpenAIProvider(model=model)
from ...llm.bedrock import BedrockProvider
return BedrockProvider(model_id=model)