-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathfactory.py
More file actions
61 lines (50 loc) · 2.12 KB
/
Copy pathfactory.py
File metadata and controls
61 lines (50 loc) · 2.12 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
"""
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.extractor_agent import RuleExtractorAgent
from src.agents.feasibility_agent import RuleFeasibilityAgent
from src.agents.repository_analysis_agent import RepositoryAnalysisAgent
from src.agents.reviewer_reasoning_agent import ReviewerReasoningAgent
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", "extractor", "acknowledgment", "repository_analysis")
**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")
>>> extractor_agent = get_agent("extractor")
>>> 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)
elif agent_type == "reviewer_reasoning":
return ReviewerReasoningAgent(**kwargs)
else:
supported = ", ".join(
["engine", "feasibility", "extractor", "acknowledgment", "repository_analysis", "reviewer_reasoning"]
)
raise ValueError(f"Unsupported agent type: {agent_type}. Supported: {supported}")