Skip to documentation
Docs navigation
Docs/graftByRelevance()
MemoGrafterAgent

graftByRelevance()

Select topics semantically and assemble a graft prompt.

What it does

Select topics semantically and assemble a graft prompt.

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(query: string, options?: GraftByRelevanceOptions): Promise<InjectionResult>

Parameters

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 agent.graftByRelevance("travel plans", { topK: 3 });