Products

class sim_panel.products.ProductRecord(product_id, attributes, display_name=None, display_text=None, schema_version='0.1.0', display_variant='default', spec_key=None, text_key=None, meta=<factory>, provenance=<factory>)[source]

Bases: object

Canonical product/intervention artifact (JSONL row).

  • product_id is internal/stable and should NOT be shown to panelists.

  • display_name is panelist-facing (short).

  • display_text is panelist-facing (longer), optional and can be LLM-enriched.

  • attributes are structured features used for policies/outcomes and for rendering.

Variants allow multiple display_text realizations (e.g., different campaigns).

Parameters:
  • product_id (str)

  • attributes (Dict[str, Any])

  • display_name (str | None)

  • display_text (str | None)

  • schema_version (str)

  • display_variant (str)

  • spec_key (str | None)

  • text_key (str | None)

  • meta (Dict[str, Any])

  • provenance (Dict[str, Any])

product_id: str
attributes: Dict[str, Any]
display_name: str | None = None
display_text: str | None = None
schema_version: str = '0.1.0'
display_variant: str = 'default'
spec_key: str | None = None
text_key: str | None = None
meta: Dict[str, Any]
provenance: Dict[str, Any]
compute_keys()[source]
Return type:

None

to_dict()[source]
Return type:

Dict[str, Any]

static from_dict(d)[source]
Return type:

ProductRecord

Parameters:

d (Dict[str, Any])

class sim_panel.products.Product(record)[source]

Bases: object

Runtime convenience wrapper.

Parameters:

record (ProductRecord)

record: ProductRecord
property product_id: str
property display_name: str | None
property display_text: str | None
property attributes: Mapping[str, Any]
display()[source]
Return type:

str

sim_panel.products.load_product_records(path)[source]
Return type:

List[ProductRecord]

Parameters:

path (str | Path)

sim_panel.products.save_product_records(path, records)[source]
Return type:

None

Parameters:
sim_panel.products.merge_product_records(base, incoming, *, prefer_incoming_attributes=True, prefer_incoming_display=False)[source]

Merge by (product_id, display_variant).

  • attributes: prefer incoming by default

  • display fields: prefer base by default unless prefer_incoming_display=True

Return type:

List[ProductRecord]

Parameters:
sim_panel.products.render_product_display(product, *, include_attributes=True, attribute_keys=None)[source]

Returns the human-facing product/intervention stimulus. Never includes product_id by default.

Return type:

str

Parameters:
  • product (ProductRecord)

  • include_attributes (bool)

  • attribute_keys (list[str] | None)

Priority:
  1. display_text if present

  2. display_name (+ attributes summary if include_attributes)

  3. attributes summary only

class sim_panel.products.ProductDisplayTextGenSettings(prompt_version='v1', temperature=0.2, max_tokens=None, metadata=None, campaign=None, tone='neutral', length='short', max_workers=1)[source]

Bases: object

Parameters:
  • prompt_version (str)

  • temperature (float)

  • max_tokens (int | None)

  • metadata (Dict[str, Any] | None)

  • campaign (str | None)

  • tone (str)

  • length (str)

  • max_workers (int)

prompt_version: str = 'v1'
temperature: float = 0.2
max_tokens: int | None = None
metadata: Dict[str, Any] | None = None
campaign: str | None = None
tone: str = 'neutral'
length: str = 'short'
max_workers: int = 1
sim_panel.products.ensure_display_text(records, *, backend, settings, variant='default', overwrite=False, progress=True)[source]
Return type:

List[ProductRecord]

Parameters:
For each record of the given display_variant:
  • if display_text missing (or overwrite=True), generate from attributes (+ display_name)

  • write provenance fields

sim_panel.products.build_products(records, *, variant='default')[source]
Return type:

List[Product]

Parameters:
class sim_panel.products.records.ProductRecord(product_id, attributes, display_name=None, display_text=None, schema_version='0.1.0', display_variant='default', spec_key=None, text_key=None, meta=<factory>, provenance=<factory>)[source]

Bases: object

Canonical product/intervention artifact (JSONL row).

  • product_id is internal/stable and should NOT be shown to panelists.

  • display_name is panelist-facing (short).

  • display_text is panelist-facing (longer), optional and can be LLM-enriched.

  • attributes are structured features used for policies/outcomes and for rendering.

Variants allow multiple display_text realizations (e.g., different campaigns).

Parameters:
  • product_id (str)

  • attributes (Dict[str, Any])

  • display_name (str | None)

  • display_text (str | None)

  • schema_version (str)

  • display_variant (str)

  • spec_key (str | None)

  • text_key (str | None)

  • meta (Dict[str, Any])

  • provenance (Dict[str, Any])

product_id: str
attributes: Dict[str, Any]
display_name: str | None = None
display_text: str | None = None
schema_version: str = '0.1.0'
display_variant: str = 'default'
spec_key: str | None = None
text_key: str | None = None
meta: Dict[str, Any]
provenance: Dict[str, Any]
compute_keys()[source]
Return type:

None

to_dict()[source]
Return type:

Dict[str, Any]

static from_dict(d)[source]
Return type:

ProductRecord

Parameters:

d (Dict[str, Any])

class sim_panel.products.product.Product(record)[source]

Bases: object

Runtime convenience wrapper.

Parameters:

record (ProductRecord)

record: ProductRecord
property product_id: str
property display_name: str | None
property display_text: str | None
property attributes: Mapping[str, Any]
display()[source]
Return type:

str