Core API
cotlab.core.base.BasePromptStrategy
Bases: ABC
Abstract base class for prompt construction strategies.
name
abstractmethod
property
Strategy name for logging.
build_prompt(input_data)
abstractmethod
Build a prompt from input data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_data
|
Dict[str, Any]
|
Dictionary with at least 'question' key |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted prompt string |
get_compatible_datasets()
Return list of compatible dataset names, or None if compatible with all.
Override this in specialized prompts to restrict usage.
get_system_message()
Return system message if applicable.
parse_response(response)
abstractmethod
Parse model response to extract answer and reasoning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
str
|
Raw model output |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary with 'answer', 'reasoning', and any other extracted fields |
cotlab.core.base.StructuredOutputMixin
Mixin to add multi-format structured output capability to any prompt strategy.
Supports: PLAIN, JSON, TOON, TOML, XML, YAML, MARKDOWN
Usage
class MyStrategy(StructuredOutputMixin, BasePromptStrategy): def init(self, output_format="plain", ...): self.output_format = output_format self.cot_format = False # Set True for CoT inside structure
cotlab.core.base.ExperimentResult
dataclass
JSON-serializable experiment result.
load(path)
classmethod
Load from JSON file.
save(path)
Save to JSON file.
to_json()
Serialize to JSON string.
cotlab.core.base.OutputFormat
Supported output formats for structured responses.