EntityDraft.h header

#include <ew/app/EntityDraft.h>

Namespace ew::app

DraftedField struct

struct ew::app::DraftedField

One field an AI drafted for an entity: the field label it filled and the proposed value. The desktop review UI maps the label back to the category's field key and applies the ones the writer accepts. Backs DESIGN §4.8 "draft entity pages".

Members

QString ew::app::DraftedField::label

The field label the model filled (echoes one of the requested labels).

QString ew::app::DraftedField::value

The proposed value for that field.

bool operator==(const DraftedField &, const DraftedField &)=default

Drafted fields compare equal when both members match.

Functions

AiRequest ew::app::buildEntityDraftRequest(const QString &entityName, const QString &categoryName, const QStringList &fieldLabels, const QString &knownDetails, const QString &canon)

Builds an AI request that asks the model to draft details for the entity entityName (of type categoryName), filling the fields named in fieldLabels, grounded strictly in canon (the story text and established facts) and without contradicting knownDetails (the entity's current field values). The model is told to return only a JSON object mapping each requested field label to a concise value – an empty string where the canon does not say – for parseEntityDraftResponse. Pure (assembles the prompt only); the caller fills the model from settings, sends it via an AiProvider, and parses the reply. The model name is left empty.

std::vector< DraftedField > ew::app::parseEntityDraftResponse(const QString &content)

Parses a model reply content (the assistant text from an entity-draft request) into the drafted fields. Tolerant of a JSON object wrapped in code fences or surrounding prose: it reads the first '{' through the last '}' and parses that. Keys whose value is empty (after trimming) are dropped, so an unknowable field is simply omitted. Returns an empty vector when no JSON object is present or it is malformed. Pure and unit-testable (no network).