forked from warestack/watchflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfactory.py
More file actions
55 lines (44 loc) · 1.83 KB
/
Copy pathfactory.py
File metadata and controls
55 lines (44 loc) · 1.83 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
"""
Agent factory for creating agent instances by name.
Provides a simple interface to get agents by their type name,
centralizing agent instantiation for consistency.
"""
import logging
from typing import Any
from src.agents.acknowledgment_agent import AcknowledgmentAgent
from src.agents.base import BaseAgent
from src.agents.engine_agent import RuleEngineAgent
from src.agents.feasibility_agent import RuleFeasibilityAgent
from src.agents.extractor_agent import RuleExtractorAgent
from src.agents.repository_analysis_agent import RepositoryAnalysisAgent
logger = logging.getLogger(__name__)
def get_agent(agent_type: str, **kwargs: Any) -> BaseAgent:
"""
Get an agent instance by type name.
Args:
agent_type: Type of agent ("engine", "feasibility", "acknowledgment")
**kwargs: Additional configuration for the agent
Returns:
Agent instance
Raises:
ValueError: If agent_type is not supported
Examples:
>>> engine_agent = get_agent("engine")
>>> feasibility_agent = get_agent("feasibility")
>>> acknowledgment_agent = get_agent("acknowledgment")
>>> analysis_agent = get_agent("repository_analysis")
"""
agent_type = agent_type.lower()
if agent_type == "engine":
return RuleEngineAgent(**kwargs)
elif agent_type == "feasibility":
return RuleFeasibilityAgent(**kwargs)
elif agent_type == "extractor":
return RuleExtractorAgent(**kwargs)
elif agent_type == "acknowledgment":
return AcknowledgmentAgent(**kwargs)
elif agent_type == "repository_analysis":
return RepositoryAnalysisAgent(**kwargs)
else:
supported = ", ".join(["engine", "feasibility", "extractor", "acknowledgment", "repository_analysis"])
raise ValueError(f"Unsupported agent type: {agent_type}. Supported: {supported}")