Skip to main content

Class: EchoLLM

LLM stand-in. Answers with answer (a string, or a function of the query and documents), or else with the top document's content. Every call is recorded in calls, so tests can assert on what the pipeline sent.

Constructors​

Constructor​

new EchoLLM(options?): EchoLLM;

Parameters​

ParameterTypeDescription
options?{ answer?: string | ((arg0, arg1) => string); fallback?: string; }-
options.answer?string | ((arg0, arg1) => string)-
options.fallback?stringAnswer when there are no documents and no answer

Returns​

EchoLLM

Properties​

PropertyTypeDescription
answerstring | ((arg0, arg1) => string)The fixed answer, or a function of (query, docs) that returns it.
callsobject[]-
fallbackstringReturned when there are no documents and no answer.
metadataobject-
metadata.namestring-
metadata.typestring-
metadata.versionstring-

Methods​

generate()​

generate(
query,
docs?,
options?
): Promise<string>;

Parameters​

ParameterTypeDescription
querystring-
docs?any[]-
options?{ signal?: AbortSignal; }-
options.signal?AbortSignal-

Returns​

Promise<string>


generateStream()​

generateStream(
query,
docs?,
options?
): AsyncGenerator<{
done: boolean;
token: string;
}, void, unknown>;

Streams the same answer word by word, then a done chunk.

Parameters​

ParameterTypeDescription
querystring-
docs?any[]-
options?{ signal?: AbortSignal; }-
options.signal?AbortSignal-

Returns​

AsyncGenerator<{ done: boolean; token: string; }, void, unknown>

Yields​


getCacheKey()​

getCacheKey(role): string;

Cache identity for createRagPipeline({ cache }); none when answer is a function, since its output cannot be identified.

Parameters​

ParameterTypeDescription
rolestring-

Returns​

string