locodellm.bench.prompt_test#
Defines test cases for evaluating generated code from prompts.
- class locodellm.bench.prompt_test.ExpectedResult(args: tuple[Any, ...], expected: Any)#
A single expected input/output pair for a generated function.
- expected#
The expected return value.
- Type:
Any
- classmethod from_dict(data: dict[str, Any]) ExpectedResult#
Creates an instance from a dictionary.
- class locodellm.bench.prompt_test.PromptTest(prompt: str, expected: list[ExpectedResult] = <factory>)#
A test case pairing a prompt with expected input/output pairs.
- expected#
A list of
ExpectedResultinstances describing how the generated function should behave.
- classmethod from_json(text: str) PromptTest#
Deserializes a
PromptTestfrom a JSON string.
- locodellm.bench.prompt_test.dump_prompt_tests(tests: list[PromptTest], path: str) None#
Writes a list of
PromptTestto a JSON Lines file.Each line in the output file is a self-contained JSON object representing one
PromptTest.- Parameters:
tests – The list of prompt tests to serialize.
path – File path to write to.
- locodellm.bench.prompt_test.load_prompt_tests(path: str) list[PromptTest]#
Reads a list of
PromptTestfrom a JSON Lines file.- Parameters:
path – File path to read from.
- Returns:
The deserialized list of prompt tests.