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
| Parameter | Type | Description |
|---|---|---|
options? | { answer?: string | ((arg0, arg1) => string); fallback?: string; } | - |
options.answer? | string | ((arg0, arg1) => string) | - |
options.fallback? | string | Answer when there are no documents and no answer |
Returns
EchoLLM
Properties
Methods
generate()
generate(
query,
docs?,
options?
): Promise<string>;
Parameters
| Parameter | Type | Description |
|---|---|---|
query | string | - |
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
| Parameter | Type | Description |
|---|---|---|
query | string | - |
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
| Parameter | Type | Description |
|---|---|---|
role | string | - |
Returns
string