This agent returns a list of open pull requests in a github repository with in an organisation along with other details. It uses the Github API to get these details.
GitHubPRRequest(
organisation_name = "fetchai",
repo_name = "uAgents"
)GitHubPRResponse(
pr_list=[
GitHubPR(
title="fix(core): enable configuring RegistrationPolicy on agent creation",
url="https://github.com/fetchai/uAgents/pull/604",
user="Dacksus",
created_at="2025-01-09T14:03:59Z",
),
GitHubPR(
title="chore(core): always return envelope on sync responses",
url="https://github.com/fetchai/uAgents/pull/590",
user="jrriehl",
created_at="2024-12-11T16:16:32Z",
),
GitHubPR(
title="feat(core): integrate domain + full agent address in Envelope and handler",
url="https://github.com/fetchai/uAgents/pull/573",
user="Archento",
created_at="2024-10-29T20:22:26Z",
),
...
]
)
Copy and paste the following code into a new Blank agent for an example of how to interact with this agent.
import json
from uagents import Agent, Context, Model
class GitHubPRRequest(Model):
organisation_name: str
repo_name: str
class GitHubPR(Model):
title: str
url: str
user: str
created_at: str
class GitHubPRResponse(Model):
pr_list: list[GitHubPR]
agent = Agent()
GITHUB_REPO_AGENT_ADDRESS = "{{ .Agent.Address }}"
# Organisation name and repo name
organisation_name = "fetchai"
repo_name = "uAgents"
@agent.on_event("startup")
async def send_message(ctx: Context):
await ctx.send(
GITHUB_REPO_AGENT_ADDRESS,
GitHubPRRequest(
organisation_name=organisation_name,
repo_name=repo_name
),
)
ctx.logger.info(f"Sent organisation name: {organisation_name} and repo name: {repo_name} to agent.")
@agent.on_message(GitHubPRResponse)
async def handle_response(ctx: Context, sender: str, msg: GitHubPRResponse):
ctx.logger.info(f"Received response from {sender}:")
ctx.logger.info(msg.pr_list)
if __name__ == "__main__":
agent.run()-
Install the necessary packages:
pip install requests uagents
-
To interact with this agent from a local agent instead, replace
agent = Agent()in the above with:agent = Agent( name="user", endpoint="http://localhost:8000/submit", )
-
Run the agent:
python agent.py