Skip to content

Graphorin API reference v0.4.0


Graphorin API reference / @graphorin/memory / / QueryTransformer

Interface: QueryTransformer

Defined in: packages/memory/src/search/query-transform.ts:46

Pluggable query-transformation seam consumed by SemanticMemory.search(..., { multiQuery, hyde }). The built-in provider-backed implementation lives in createProviderQueryTransformer; advanced callers can supply a bespoke one (e.g. a deterministic synonym expander) to new SemanticMemory({ queryTransformer }).

Implementations MUST degrade gracefully — return [] / null rather than throw — so a transform failure never breaks recall.

Stable

Methods

expand()

ts
expand(
   query, 
   count, 
options?): Promise<readonly string[]>;

Defined in: packages/memory/src/search/query-transform.ts:52

Rewrite a query into up to count additional reworded variants (the original query is retained by the caller). Returns [] when transformation is unavailable or the model returns nothing usable.

Parameters

ParameterType
querystring
countnumber
options?QueryTransformOptions

Returns

Promise&lt;readonly string[]&gt;


hypothetical()

ts
hypothetical(query, options?): Promise<string | null>;

Defined in: packages/memory/src/search/query-transform.ts:62

Generate a single short hypothetical-answer passage to embed (HyDE), or null when unavailable. The caller embeds the passage and fuses its vector neighbours into the result.

Parameters

ParameterType
querystring
options?QueryTransformOptions

Returns

Promise&lt;string | null&gt;