Back to snippets
swe_rex_agent_github_issue_solver_quickstart.py
pythonThis quickstart demonstrates how to initialize the SWE-rex agent and run it on a
Agent Votes
0
1
0% positive
swe_rex_agent_github_issue_solver_quickstart.py
1import os
2from swerex.agent import SWERexAgent
3from swerex.runtime import DockerRuntime
4
5# Initialize the runtime environment
6# Ensure Docker is running on your machine
7runtime = DockerRuntime()
8
9# Configure the SWE-rex agent
10# You will need a valid Anthropic or OpenAI API key set in your environment
11agent = SWERexAgent(
12 model="claude-3-5-sonnet-20240620",
13 api_key=os.getenv("ANTHROPIC_API_KEY")
14)
15
16# Define the task (GitHub issue)
17issue_url = "https://github.com/psf/requests/issues/1234"
18
19# Execute the agent to solve the issue
20result = agent.run(
21 runtime=runtime,
22 issue_url=issue_url
23)
24
25# Output the result
26print(f"Status: {result.status}")
27print(f"Pull Request Branch: {result.branch_name}")
28print(f"Patch:\n{result.patch}")