| 1 | """This is the simplest possible example of how to use mini-SWE-agent with python bindings.
|
| 2 | For a more complete example, see mini.py
|
| 3 | """
|
| 4 |
|
| 5 | import logging
|
| 6 | import os
|
| 7 | from pathlib import Path
|
| 8 |
|
| 9 | import typer
|
| 10 | import yaml
|
| 11 |
|
| 12 | from minisweagent import package_dir
|
| 13 | from minisweagent.agents.default import DefaultAgent
|
| 14 | from minisweagent.environments.local import LocalEnvironment
|
| 15 | from minisweagent.models.litellm_model import LitellmModel
|
| 16 |
|
| 17 | app = typer.Typer()
|
| 18 |
|
| 19 |
|
| 20 | @app.command()
|
| 21 | def main(
|
| 22 | task: str = typer.Option(..., "-t", "--task", help="Task/problem statement", show_default=False, prompt=True),
|
| 23 | model_name: str = typer.Option(
|
| 24 | os.getenv("MSWEA_MODEL_NAME"),
|
| 25 | "-m",
|
| 26 | "--model",
|
| 27 | help="Model name (defaults to MSWEA_MODEL_NAME env var)",
|
| 28 | prompt="What model do you want to use?",
|
| 29 | ),
|
| 30 | ) -> DefaultAgent:
|
| 31 | logging.basicConfig(level=logging.DEBUG)
|
| 32 | agent = DefaultAgent(
|
| 33 | LitellmModel(model_name=model_name),
|
| 34 | LocalEnvironment(),
|
| 35 | **yaml.safe_load(Path(package_dir / "config" / "default.yaml").read_text())["agent"],
|
| 36 | )
|
| 37 | agent.run(task)
|
| 38 | return agent
|
| 39 |
|
| 40 |
|
| 41 | if __name__ == "__main__":
|
| 42 | app()
|
| 43 |
|