refactor: 重构 config 目录结构,按领域分类静态配置
This commit is contained in:
@@ -18,7 +18,7 @@ def _write(path: Path, content: str) -> None:
|
||||
|
||||
def _prepare_static_root(root: Path) -> Path:
|
||||
_write(
|
||||
root / "crewai" / "agents.yaml",
|
||||
root / "agents.yaml",
|
||||
"""
|
||||
intent:
|
||||
role: Intent Agent
|
||||
@@ -29,7 +29,7 @@ organization:
|
||||
""".strip(),
|
||||
)
|
||||
_write(
|
||||
root / "crewai" / "tasks.yaml",
|
||||
root / "tasks.yaml",
|
||||
"""
|
||||
intent:
|
||||
description: classify
|
||||
@@ -40,7 +40,7 @@ organization:
|
||||
""".strip(),
|
||||
)
|
||||
_write(
|
||||
root / "crewai" / "workflow.yaml",
|
||||
root / "workflow.yaml",
|
||||
"""
|
||||
stages:
|
||||
- intent
|
||||
@@ -48,9 +48,6 @@ stages:
|
||||
- organization
|
||||
""".strip(),
|
||||
)
|
||||
_write(root / "crewai" / "prompts" / "intent.md", "intent prompt")
|
||||
_write(root / "crewai" / "prompts" / "execution.md", "execution prompt")
|
||||
_write(root / "crewai" / "prompts" / "organization.md", "organization prompt")
|
||||
_write(
|
||||
root / "tools.yaml",
|
||||
"""
|
||||
@@ -63,24 +60,21 @@ tools:
|
||||
|
||||
|
||||
def test_load_crewai_template_success_when_all_files_valid(tmp_path: Path) -> None:
|
||||
static_root = _prepare_static_root(tmp_path / "agent")
|
||||
static_root = _prepare_static_root(tmp_path)
|
||||
|
||||
template = load_crewai_template(static_root)
|
||||
|
||||
assert set(template.agents.keys()) == {"intent", "execution", "organization"}
|
||||
assert set(template.tasks.keys()) == {"intent", "execution", "organization"}
|
||||
assert template.workflow["stages"] == ["intent", "execution", "organization"]
|
||||
assert template.prompts["intent"] == "intent prompt"
|
||||
assert template.prompts["execution"] == "execution prompt"
|
||||
assert template.prompts["organization"] == "organization prompt"
|
||||
assert template.tools_whitelist == {"asr_fun_asr", "doc_extract"}
|
||||
|
||||
|
||||
def test_load_crewai_template_raises_file_not_found_when_required_file_missing(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
static_root = _prepare_static_root(tmp_path / "agent")
|
||||
(static_root / "crewai" / "tasks.yaml").unlink()
|
||||
static_root = _prepare_static_root(tmp_path)
|
||||
(static_root / "tasks.yaml").unlink()
|
||||
|
||||
with pytest.raises(FileNotFoundError):
|
||||
load_crewai_template(static_root)
|
||||
@@ -89,9 +83,9 @@ def test_load_crewai_template_raises_file_not_found_when_required_file_missing(
|
||||
def test_load_crewai_template_raises_value_error_when_workflow_stages_invalid(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
static_root = _prepare_static_root(tmp_path / "agent")
|
||||
static_root = _prepare_static_root(tmp_path)
|
||||
_write(
|
||||
static_root / "crewai" / "workflow.yaml",
|
||||
static_root / "workflow.yaml",
|
||||
"""
|
||||
stages:
|
||||
- execution
|
||||
@@ -105,7 +99,7 @@ stages:
|
||||
|
||||
|
||||
def test_load_tools_whitelist_from_tools_yaml(tmp_path: Path) -> None:
|
||||
static_root = _prepare_static_root(tmp_path / "agent")
|
||||
static_root = _prepare_static_root(tmp_path)
|
||||
|
||||
whitelist = load_tools_whitelist(static_root)
|
||||
|
||||
@@ -124,7 +118,7 @@ def test_validate_workflow_stages_rejects_extra_or_missing_stage() -> None:
|
||||
|
||||
|
||||
def test_load_tools_whitelist_rejects_non_string_item(tmp_path: Path) -> None:
|
||||
static_root = _prepare_static_root(tmp_path / "agent")
|
||||
static_root = _prepare_static_root(tmp_path)
|
||||
_write(
|
||||
static_root / "tools.yaml",
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user