PromptSpec#
- class rapidtools.gui.PromptSpec(asset: str = 'building', imagery: str = 'aerial', objective: str = '', persona: str = '', focus: str = '', marking: str = '', steps: list[str] = <factory>, edge_cases: list[str] = <factory>, fields: list[OutputField] = <factory>, rubric_title: str = '', rubric_field: str = '', rubric: list[RubricEntry] = <factory>, context: str = '', json_output: bool = False)[source]#
Bases:
objectEverything needed to assemble a prompt in the rapidtools sample layout.
- Variables:
asset (str) – What is being analysed (
'building','vehicle').imagery (str) –
'aerial','street'or'multi-temporal street'.objective (str) – What the model must do, phrased after “Analyze each provided image and …” (
'assign a CHS Level (0-4) to the primary building structure').persona (str) – Expertise the model should adopt.
focus (str) – Scope statements such as what to ignore.
marking (str) – How the asset is marked on the crop, from
describe_marking().steps (list[str]) – Numbered analysis steps; generated when empty.
edge_cases (list[str]) – Sentences describing alternative classifications.
fields (list[OutputField]) – The output fields, in order.
rubric_title (str) – Heading of the class descriptions block.
rubric_field (str) – Name of the field the rubric explains; defaults to the first categorical field.
rubric (list[RubricEntry]) – One
RubricEntryper class.context (str) – Optional background paragraph appended at the end.
json_output (bool) – Ask for a JSON object instead of
Key: valuelines.
Example
>>> spec = PromptSpec.from_dict({'asset': 'road', 'fields': [ ... {'name': 'Blocked', 'kind': 'boolean'}]}) >>> spec.fields[0].format_line() 'Blocked: [true or false]'
Methods
Attribute names the analyzer will write for this prompt.
Analysis steps used when the user has not written any.
Build a spec from a JSON object, ignoring unknown keys.
The field the rubric describes.
Serialise to plain JSON-compatible data.
- classmethod from_dict(data: dict[str, Any] | None) PromptSpec[source]#
Build a spec from a JSON object, ignoring unknown keys.
- Parameters:
data (dict[str, Any] | None) – Keys matching the attributes; nested
fieldsandrubricentries may be dicts.- Returns:
PromptSpec – The coerced specification.
- Raises:
ValueError – If
datais not an object or a field kind is invalid.
- primary_field() OutputField | None[source]#
The field the rubric describes.
- Returns:
OutputField | None – The field named by
rubric_fieldif it exists, else the first categorical field, elseNone.