Skip to content

Commit

Permalink
add get assigned issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-XT committed Jan 11, 2025
1 parent 7cf3b4f commit f4feb55
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions agixt/extensions/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ def __init__(
"Get Github Repository Code Contents": self.get_repo_code_contents,
"Get Github Repository Issues": self.get_repo_issues,
"Get Github Repository Issue": self.get_repo_issue,
"Get Github Assigned Issues": self.get_assigned_issues,
"Create Github Repository": self.create_repo,
"Create Github Repository Issue": self.create_repo_issue,
"Update Github Repository Issue": self.update_repo_issue,
Expand Down Expand Up @@ -2864,3 +2865,40 @@ async def fix_github_issue(
I have created and reviewed pull request [#{new_pr.number}]({repo_url}/pull/{new_pr.number}) to fix issue [#{issue_number}]({repo_url}/issues/{issue_number})."""
return response

async def get_assigned_issues(self, github_username: str = "None") -> str:
"""
Get all open issues assigned to a specific GitHub user.
Args:
github_username (str): The GitHub username to search for. If the assistant uses "None", it will default to the user's GitHub username automatically.
Returns:
str: A list of open issues assigned to the user in markdown format.
"""
if github_username.lower() == "none":
github_username = self.GITHUB_USERNAME
response = requests.get(
f"https://api.github.com/search/issues",
headers={
"Authorization": f"token {self.GITHUB_API_KEY}",
"Accept": "application/vnd.github.v3+json",
},
params={
"q": f"is:open is:issue assignee:{github_username} archived:false",
},
)

# Check if the response was successful
if response.status_code == 200:
issues = response.json().get("items", [])
issue_string = f"# Issues assigned to {github_username}\n\n"
for issue in issues:
issue_string += (
f"## [{issue['title']}]({issue['html_url']})\n\n{issue['body']}\n\n"
)
return issue_string
else:
return f"Failed to fetch issues: {response.status_code} {response.text}"

0 comments on commit f4feb55

Please sign in to comment.