Skip to content

Specifying problems

We currently support the following input types:

  • A string of text (TextProblemStatement)
  • A path to a file on the local filesystem (FileProblemStatement)
  • A URL to a GitHub issue (GithubIssue)
  • An empty problem statement (EmptyProblemStatement)

With sweagent run, you can specify the problem statement type with the --problem-statement flag. For example:

From text
--problem-statement.text="This is a problem statement"
--problem-statement.type=text
From a file
--problem-statement.path=path/to/file.txt
--problem-statement.type=text_file
From a GitHub issue
--problem-statement.url=https://github.com/org/repo/issues/123
--problem-statement.type=github_issue

See below for more details on the configuration options.

All of these classes are defined in sweagent.agent.problem_statement.

problem_statement_from_simplified_input

problem_statement_from_simplified_input(*, input: str, type: Literal['text', 'text_file', 'github_issue']) -> ProblemStatementConfig

Get a problem statement from an input string and a type.

Parameters:

Name Type Description Default
input str

Url/path/text

required
type Literal['text', 'text_file', 'github_issue']

The type of problem statement

required
Source code in sweagent/agent/problem_statement.py
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
def problem_statement_from_simplified_input(
    *, input: str, type: Literal["text", "text_file", "github_issue"]
) -> ProblemStatementConfig:
    """Get a problem statement from an `input` string and a `type`.

    Args:
        input: Url/path/text
        type: The type of problem statement
    """
    if type == "text":
        return TextProblemStatement(text=input)
    elif type == "text_file":
        return FileProblemStatement(path=Path(input))
    elif type == "github_issue":
        return GithubIssue(github_url=input)
    else:
        msg = f"Unknown problem statement type: {type}"
        raise ValueError(msg)

TextProblemStatement pydantic-model

Config:

  • extra: 'forbid'

Fields:

extra_fields pydantic-field

extra_fields: dict[str, Any]

Any additional data to be added to the instance. This data will be available when formatting prompt templates.

id pydantic-field

id: str = None

text pydantic-field

text: str

type pydantic-field

type: Literal['text'] = 'text'

Discriminator for (de)serialization/CLI. Do not change.

get_extra_fields

get_extra_fields() -> dict[str, Any]
Source code in sweagent/agent/problem_statement.py
62
63
def get_extra_fields(self) -> dict[str, Any]:
    return self.extra_fields

get_problem_statement

get_problem_statement() -> str
Source code in sweagent/agent/problem_statement.py
59
60
def get_problem_statement(self) -> str:
    return self.text

FileProblemStatement pydantic-model

Config:

  • extra: 'forbid'

Fields:

extra_fields pydantic-field

extra_fields: dict[str, Any]

Any additional data to be added to the instance. This data will be available when formatting prompt templates.

id pydantic-field

id: str = None

path pydantic-field

path: Path

type pydantic-field

type: Literal['text_file'] = 'text_file'

Discriminator for (de)serialization/CLI. Do not change.

get_extra_fields

get_extra_fields() -> dict[str, Any]
Source code in sweagent/agent/problem_statement.py
95
96
def get_extra_fields(self) -> dict[str, Any]:
    return self.extra_fields

get_problem_statement

get_problem_statement() -> str
Source code in sweagent/agent/problem_statement.py
92
93
def get_problem_statement(self) -> str:
    return self.path.read_text()

GithubIssue pydantic-model

Config:

  • extra: 'forbid'

Fields:

extra_fields pydantic-field

extra_fields: dict[str, Any]

Any additional data to be added to the instance. This data will be available when formatting prompt templates.

github_url pydantic-field

github_url: str

id pydantic-field

id: str = None

type pydantic-field

type: Literal['github'] = 'github'

Discriminator for (de)serialization/CLI. Do not change.

get_extra_fields

get_extra_fields() -> dict[str, Any]
Source code in sweagent/agent/problem_statement.py
124
125
def get_extra_fields(self) -> dict[str, Any]:
    return self.extra_fields

get_problem_statement

get_problem_statement() -> str
Source code in sweagent/agent/problem_statement.py
120
121
122
def get_problem_statement(self) -> str:
    owner, repo, issue_number = _parse_gh_issue_url(self.github_url)
    return _get_problem_statement_from_github_issue(owner, repo, issue_number, token=os.getenv("GITHUB_TOKEN"))

EmptyProblemStatement pydantic-model

Config:

  • extra: 'forbid'

Fields:

  • id (str)
  • type (Literal['empty'])

id pydantic-field

id: str

type pydantic-field

type: Literal['empty'] = 'empty'

Discriminator for (de)serialization/CLI. Do not change.

get_extra_fields

get_extra_fields() -> dict[str, Any]
Source code in sweagent/agent/problem_statement.py
35
36
def get_extra_fields(self) -> dict[str, Any]:
    return {}

get_problem_statement

get_problem_statement() -> str
Source code in sweagent/agent/problem_statement.py
32
33
def get_problem_statement(self) -> str:
    return ""