Embedding Integration (runtime)
The Director can optionally use local semantic embeddings to improve scoring for thematic consistency, lore adherence, and character voice. This feature is opt-in and disabled by default.
- Set
enableEmbeddings: truein.gengine/config.yamlunderdirectorConfig, or pass{ enableEmbeddings: true }via theevaluate()configargument. - For Node integration tests you may set environment flags (used by embedding service):
EMBED_NODE=1to enable Node fallback.
When embeddings are enabled, Director emits embedding telemetry inside the director_decision event under metrics.embedding with fields:
used(boolean) - whether embeddings were successfully computedlatencyMs(number) - inference time in millisecondsfallback(boolean) - true when embeddings were not used and placeholders were appliedmetrics(optional object) - similarity metrics (0..1) forthematic,lore, andvoicewhen available
evaluate()computes embeddings asynchronously (usingweb/demo/js/embedding-service.jswhen available) and derives similarity metrics when story-level embeddings are provided onstoryContextasthemeEmbedding,loreEmbedding,voiceEmbeddingarrays.computeRiskScore()remains synchronous and reads precomputedconfig.embeddingMetrics(if present) to convert similarities into placeholder risks. This keeps the core scoring deterministic and testable.
- Precompute story-level embeddings at load-time and attach them to story context. (bead created)
- Optionally emit a dedicated
embedding_inferencetelemetry event in addition to including embedding metadata in director telemetry. (bead created)