SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]
Doc: Start filling in reference pages
Kilian Lieret2eb0083b3ba1
diff --git a/docs/assets/mkdocstrings.css b/docs/assets/mkdocstrings.cssnew file mode 100644index 00000000..149ba24a--- /dev/null+++ b/docs/assets/mkdocstrings.css@@ -0,0 +1,16 @@+/* From https://mkdocstrings.github.io/python/usage/customization/#symbol-types */+[data-md-color-scheme="default"] {+ --doc-symbol-parameter-fg-color: #df50af;+ --doc-symbol-attribute-fg-color: #0079ff;+ --doc-symbol-function-fg-color: #00dfa2;+ --doc-symbol-method-fg-color: #00dfa2;+ --doc-symbol-class-fg-color: #d1b619;+ --doc-symbol-module-fg-color: #ff0060;++ --doc-symbol-parameter-bg-color: #df50af1a;+ --doc-symbol-attribute-bg-color: #0079ff1a;+ --doc-symbol-function-bg-color: #00dfa21a;+ --doc-symbol-method-bg-color: #00dfa21a;+ --doc-symbol-class-bg-color: #d1b6191a;+ --doc-symbol-module-bg-color: #ff00601a;+}diff --git a/docs/reference/agent.md b/docs/reference/agent.mdindex 3d0a55c8..adc1730b 100644--- a/docs/reference/agent.md+++ b/docs/reference/agent.md@@ -1,5 +1,7 @@# The agent class-::: sweagent.agent.agents- options:- allow_inspection: false\ No newline at end of file+This page documents the `Agent` class, which runs the main loop of the agent.+To learn about the configuration objects used to specify the behavior of an agent,+see the [agent configuration reference page](agent_config.md).++::: sweagent.agent.agents.Agent\ No newline at end of filediff --git a/docs/reference/agent_config.md b/docs/reference/agent_config.mdnew file mode 100644index 00000000..71902da3--- /dev/null+++ b/docs/reference/agent_config.md@@ -0,0 +1,8 @@+# Agent configuration++This page documents the configuration objects used to specify the behavior of an agent.+To learn about the agent class itself, see the [agent class reference page](agent.md).++::: sweagent.agent.agents.AgentConfig++::: sweagent.agent.agents.TemplateConfig\ No newline at end of filediff --git a/docs/reference/env.md b/docs/reference/env.mdindex 1fea0c83..ef0182b4 100644--- a/docs/reference/env.md+++ b/docs/reference/env.md@@ -1,5 +1,5 @@# The environment class-::: sweagent.environment.swe_env+::: sweagent.environment.swe_env.SWEEnvoptions:allow_inspection: false\ No newline at end of filediff --git a/docs/reference/env_config.md b/docs/reference/env_config.mdnew file mode 100644index 00000000..4c7b191f--- /dev/null+++ b/docs/reference/env_config.md@@ -0,0 +1,6 @@+# Environment configuration++This page documents the configuration objects used to specify the behavior of the environment.+To learn about the environment class itself, see the [environment class reference page](env.md).++::: sweagent.environment.swe_env.EnvironmentConfig\ No newline at end of filediff --git a/docs/reference/model_config.md b/docs/reference/model_config.mdnew file mode 100644index 00000000..1538ff3f--- /dev/null+++ b/docs/reference/model_config.md@@ -0,0 +1,28 @@+# Models++This page documents the configuration objects used to specify the behavior of a language model (LM).++## Normal LMs++::: sweagent.agent.models.GenericAPIModelConfig+ options:+ heading_level: 3++## Human-in-the-loop models++The following two models allow you to test new commands by prompting you for actions.+This can also be very useful to create your first [demonstrations](../config/demonstrations.md).++::: sweagent.agent.models.HumanModel+ options:+ heading_level: 3++::: sweagent.agent.models.HumanThoughtModel+ options:+ heading_level: 3++## Testing models++::: sweagent.agent.models.ReplayModel+ options:+ heading_level: 3diff --git a/docs/reference/models.md b/docs/reference/models.mddeleted file mode 100644index 01a71f2b..00000000--- a/docs/reference/models.md+++ /dev/null@@ -1,5 +0,0 @@-# Models--::: sweagent.agent.models- options:- allow_inspection: false\ No newline at end of filediff --git a/docs/reference/problem_statements.md b/docs/reference/problem_statements.mdnew file mode 100644index 00000000..6ad90898--- /dev/null+++ b/docs/reference/problem_statements.md@@ -0,0 +1,11 @@+# Specifying problems++::: sweagent.environment.config.problem_statement.TextProblemStatement++::: sweagent.environment.config.problem_statement.FileProblemStatement++::: sweagent.environment.config.problem_statement.GithubIssue++::: sweagent.environment.config.problem_statement.EmptyProblemStatement++::: sweagent.environment.config.problem_statement.problem_statement_from_simplified_input\ No newline at end of filediff --git a/docs/reference/repo.md b/docs/reference/repo.mdnew file mode 100644index 00000000..3b3a9efa--- /dev/null+++ b/docs/reference/repo.md@@ -0,0 +1,9 @@+# Configuring repositories++::: sweagent.environment.config.repo.PreExistingRepo++::: sweagent.environment.config.repo.LocalRepoConfig++::: sweagent.environment.config.repo.GithubRepoConfig++::: sweagent.environment.config.repo.repo_from_simplified_input\ No newline at end of filediff --git a/mkdocs.yml b/mkdocs.ymlindex be9218e6..c9a6d37e 100644--- a/mkdocs.yml+++ b/mkdocs.yml@@ -82,9 +82,13 @@ nav:- "Formatting conflicts": "dev/formatting_conflicts.md"- Reference:- "reference/index.md"- - "Agent": "reference/agent.md"- - "Models": "reference/models.md"- - "Environment": "reference/env.md"+ - "Problem statements": "reference/problem_statements.md"+ - "Repository": "reference/repo.md"+ - "Model config": "reference/model_config.md"+ - "Agent config": "reference/agent_config.md"+ - "Environment config": "reference/env_config.md"+ - "Agent class": "reference/agent.md"+ - "Environment class": "reference/env.md"- "FAQ": "faq.md"plugins:- glightbox@@ -95,8 +99,29 @@ plugins:handlers:python:paths: [sweagent]+ options:+ merge_init_into_class: true+ summary: false+ show_root_heading: true+ heading_level: 2+ docstring_style: google+ show_if_no_docstring: true+ show_signature: true+ show_signature_annotations: true+ signature_crossrefs: true+ separate_signature: true+ show_symbol_type_heading: true+ show_symbol_type_toc: true+ extensions:+ - griffe_pydantic:+ schema: false+ filters:+ - "!^_"+ - "!^model_config"+ - "!^model_post_init"repo_url: https://github.com/princeton-nlp/SWE-agentrepo_name: princeton-nlp/SWE-agentedit_uri: edit/main/docs/extra_css:- - assets/custom.css\ No newline at end of file+ - assets/custom.css+ - assets/mkdocstrings.css\ No newline at end of filediff --git a/sweagent/agent/agents.py b/sweagent/agent/agents.pyindex da000d7c..4eefad1c 100644--- a/sweagent/agent/agents.py+++ b/sweagent/agent/agents.py@@ -77,6 +77,8 @@ class TemplateConfig(BaseModel):class AgentConfig(BaseModel):+ """This configuration object specifies the behavior of an agent."""+name: str = "main"templates: TemplateConfig = Field(default_factory=TemplateConfig)tools: ToolConfig = Field(default_factory=ToolConfig)diff --git a/sweagent/agent/models.py b/sweagent/agent/models.pyindex 833bdb00..4da40281 100644--- a/sweagent/agent/models.py+++ b/sweagent/agent/models.py@@ -34,6 +34,8 @@ logger = get_logger("swea-lm", emoji="🤖")class RetryConfig(PydanticBaseModel):+ """This configuration object specifies how many times to retry a failed LM API call."""+retries: int = 5"""Number of retries"""min_wait: float = 1@@ -43,8 +45,12 @@ class RetryConfig(PydanticBaseModel):class GenericAPIModelConfig(PydanticBaseModel):- name: str = Field(description="Model name.")- """Arguments configuring the model and its behavior."""+ """This configuration object specifies a LM like GPT4 or similar.+ The model will be served with the help of the `litellm` library.+ """++ name: str = Field(description="Name of the model.")+per_instance_cost_limit: float = Field(default=3.0,description="Cost limit for every instance (task).",@@ -61,6 +67,7 @@ class GenericAPIModelConfig(PydanticBaseModel):or putting your environment variables in a `.env` file."""stop: list[str] = []+ """Custom stop sequences"""completion_kwargs: dict[str, Any] = {}"""Additional kwargs to pass to `litellm.completion`"""@@ -71,6 +78,7 @@ class GenericAPIModelConfig(PydanticBaseModel):"""retry: RetryConfig = RetryConfig()+ """Retry configuration"""# pydanticmodel_config = ConfigDict(extra="forbid")@@ -131,6 +139,8 @@ GLOBAL_STATS_LOCK = Lock()class InstanceStats(PydanticBaseModel):+ """This object tracks usage numbers (costs etc.) for a single instance."""+instance_cost: float = 0tokens_sent: int = 0tokens_received: int = 0@@ -172,6 +182,7 @@ class AbstractModel(ABC):class HumanModel(AbstractModel):def __init__(self, config: HumanModelConfig, tools: ToolConfig):+ """Model that allows for human-in-the-loop"""self.config = configself.stats = InstanceStats()@@ -251,6 +262,9 @@ class HumanThoughtModel(HumanModel):class ReplayModel(AbstractModel):def __init__(self, config: ReplayModelConfig, tools: ToolConfig):+ """Model used for replaying a trajectory (i.e., taking all the actions for the `.traj` file+ and re-issuing them.+ """self.config = configself.stats = InstanceStats()@@ -295,6 +309,7 @@ class ReplayModel(AbstractModel):class PredeterminedTestModel(AbstractModel):def __init__(self, outputs: list[dict | str]):+ """Model that outputs a predetermined sequence of messages. Useful for testing."""self._outputs = outputsself._idx = -1self.stats = InstanceStats()@@ -349,7 +364,8 @@ class InstantEmptySubmitTestModel(AbstractModel):class LiteLLMModel(AbstractModel):- def __init__(self, args: ModelConfig, tools: ToolConfig):+ def __init__(self, args: GenericAPIModelConfig, tools: ToolConfig):+ """Model served by the `litellm` library."""self.args = argsself.stats = InstanceStats()self.tools = toolsdiff --git a/sweagent/environment/config/repo.py b/sweagent/environment/config/repo.pyindex 5272c65d..8aa27256 100644--- a/sweagent/environment/config/repo.py+++ b/sweagent/environment/config/repo.py@@ -42,6 +42,7 @@ class PreExistingRepo(BaseModel):"""Discriminator for (de)serialization/CLI. Do not change."""def copy(self, deployment: AbstractDeployment):+ """Does nothing."""pass@@ -105,6 +106,7 @@ class GithubRepoConfig(BaseModel):return f"https://{token}@{url_no_protocol}"def copy(self, deployment: AbstractDeployment):+ """Clones the repository to the sandbox."""base_commit = self.base_commitgithub_token = os.getenv("GITHUB_TOKEN", "")url = self._get_url_with_token(github_token)