provideFakeAgent

Provides an agent with no backend, for demos, stories and tests. It is the agent provideAgent builds, over the in-memory session from @threadplane/core/testing.

Each submit appends the user's message and streams a canned assistant reply. A new thread is given an id on its first submit, and a thread the fake has seen comes back with its messages when the agent switches to it again.

Drive it from a test through injectFakeAgentSession.

import { provideFakeAgent } from '@threadplane/angular/chat/testing';

Declaration · overload 1

export declare function provideFakeAgent<TTools extends {
    [K in keyof TTools]: ToolContract;
} = Record<string, ToolContract>, TState = unknown>(ref: AgentRef<AgentSession<TTools, TState>>, config?: FakeAgentConfig<NoInfer<TTools>, NoInfer<TState>>): Provider[];

Type parameters

TTools
{ [K in keyof TTools]: ToolContract; } Default: Record<string, ToolContract>
TState
Default: unknown

Parameters

ref · required
AgentRef<AgentSession<TTools, TState>>
config · optional
FakeAgentConfig<NoInfer<TTools>, NoInfer<TState>>

Returns

Provider[]

Examples

TestBed.configureTestingModule({
  providers: [provideFakeAgent({ tokens: ['Hi', ' there'], delayMs: 0 })],
});

Declaration · overload 2

export declare function provideFakeAgent<TTools extends {
    [K in keyof TTools]: ToolContract;
} = Record<string, ToolContract>, TState = unknown>(config?: FakeAgentConfig<TTools, TState>): Provider[];

Type parameters

TTools
{ [K in keyof TTools]: ToolContract; } Default: Record<string, ToolContract>
TState
Default: unknown

Parameters

config · optional
FakeAgentConfig<TTools, TState>

Returns

Provider[]