-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathanalyst.py
More file actions
65 lines (53 loc) · 2.82 KB
/
Copy pathanalyst.py
File metadata and controls
65 lines (53 loc) · 2.82 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
from textwrap import dedent
from beeai_framework.agents.requirement import RequirementAgent
from beeai_framework.agents.requirement.requirements.conditional import ConditionalRequirement
from beeai_framework.middleware.trajectory import GlobalTrajectoryMiddleware
from beeai_framework.tools import Tool
from github_issue_creator.tools.github_tools import create_repo_scoped_tool, get_tools_by_names
from github_issue_creator.utils.config import llm, session_manager
from github_issue_creator.utils.exceptions import ToolNotFoundError
async def get_agent_analyst():
"""Create and configure the duplicate issue analyzer agent."""
tools = await session_manager.get_tools()
tool_names = ["issue_read", "list_issues", "search_issues"]
try:
original_tools = await get_tools_by_names(tools, tool_names)
# Create repo-scoped versions of all tools
available_tools = []
for tool in original_tools:
scoped_tool = await create_repo_scoped_tool(tool)
available_tools.append(scoped_tool)
except ToolNotFoundError as e:
raise RuntimeError(f"Failed to configure duplicate finder agent: {e}") from e
role = "helpful analyst"
instruction = dedent(
"""\
When given an issue title and description, you should:
1. Use GitHub search tools to find similar issues using relevant keywords from the title and description
2. Search for issues with similar titles, keywords, and concepts
3. Analyze the search results to identify potential duplicates
4. Present your findings in a clear, structured format
Your response should include:
- **Search Summary**: Brief description of the search terms and strategy used
- **Potential Duplicates Found**: List of similar issues with:
- Issue number and title
- Brief similarity explanation
- Link to the issue
- **Similarity Assessment**: Your assessment of how similar each found issue is (High/Medium/Low)
- **Recommendation**: Whether the new issue appears to be a duplicate or is sufficiently different
You have access to the following GitHub tools:
- search_issues: Search for issues using keywords
- list_issues: List issues in the repository
- issue_read: Get detailed information about a specific issue
Use these tools strategically to thoroughly search the repository for similar issues. Focus on finding issues with similar titles, descriptions, or concepts.
"""
)
return RequirementAgent(
name="Analyst",
llm=llm,
role=role,
instructions=instruction,
tools=available_tools,
requirements=[ConditionalRequirement(tool, max_invocations=3) for tool in available_tools],
middlewares=[GlobalTrajectoryMiddleware(included=[Tool])],
)