SemanticRetrieval.h header
#include <ew/app/SemanticRetrieval.h>
Namespace ew::app
Functions
AiRequest ew::app::buildRetrievalPrompt(const QString &question, const QString &retrievedCanon)
Builds an AI request that answers question grounded strictly on retrievedCanon – the codex facts most relevant to the question – so the model stays faithful to the established world and admits when the answer is not in the canon. Pure (assembles the prompt only); the caller fills the model from settings and sends it via an AiProvider.
QString ew::app::entityEmbeddingText(const ew::core::Project &project, ew::core::ContentId id)
The text used to embed the entity id for the semantic index: its name, category, and field values joined, so a query can match on any of them. Returns an empty string when id is not an entity (nothing to embed). Feed this to the embeddings provider when building a SemanticIndex.
QString ew::app::formatRetrievedCanon(const ew::core::Project &project, const std::vector< SemanticMatch > &matches)
Formats matches (from SemanticIndex::search) as a canon digest for AI grounding – one line per still-present entity (name, category, summary), most-relevant first. Ids that are no longer entities are skipped. Returns an empty string when nothing resolves.
std::vector< SemanticMatch > ew::app::similarEntities(const SemanticIndex &index, ew::core::ContentId entityId, int topK)
Returns up to topK entities semantically most similar to entityId, ranked most-similar first, using the embedding already stored for it in index – so this is offline (no re-embedding). The query entity is excluded from its own results. Empty when entityId is not indexed, topK is not positive, or nothing else is similar. (Build the index first, e.g. via the desktop's Build World Index.)