MemoGrafter
graftByRelevance()
Select session topics by semantic relevance.
What it does
Select session topics by semantic relevance.
This combines semantic topic selection with prompt assembly, making it suitable when the caller has a query but does not already know the graph’s topic IDs.
Signature
TypeScript
graftByRelevance(sessionId: string, query: string, options?: GraftByRelevanceOptions): Promise<InjectionResult>Parameters
sessionId (string) — The application-owned session whose memory should be read or changed.query (string) — Natural-language intent used to rank relevant memory.options? (GraftByRelevanceOptions) — Optional limits, filters, tags, or operation-specific behavior.Result
The selected memory context and prompt text ready to pass to an LLM.
Example
example.ts
const graft = await memo.graftByRelevance("session-1", "travel plans");