Class Agent<UserData>

Type Parameters

  • UserData = any

Hierarchy (view full)

Constructors

Properties

default: {
    llmNode(agent, chatCtx, toolCtx, modelSettings): Promise<null | ReadableStream<string | ChatChunk>>;
    realtimeAudioOutputNode(_agent, audio, _modelSettings): Promise<null | ReadableStream<AudioFrame>>;
    sttNode(agent, audio, _modelSettings): Promise<null | ReadableStream<string | SpeechEvent>>;
    transcriptionNode(agent, text, _modelSettings): Promise<null | ReadableStream<string | TimedString>>;
    ttsNode(agent, text, _modelSettings): Promise<null | ReadableStream<AudioFrame>>;
} = ...

Type declaration

Accessors

  • get turnHandling(): undefined | Partial<TurnHandlingOptions>
  • Returns undefined | Partial<TurnHandlingOptions>

Methods

  • Parameters

    • audio: ReadableStream<AudioFrame> | AsyncIterable<AudioFrame, any, any>
    • modelSettings: ModelSettings

    Returns Promise<null | ReadableStream<AudioFrame>>

  • Transcribes audio frames into speech events. Override it for custom pre-processing or STT strategies.

    For an STT with capabilities.manualFlush, the framework flushes the stream created by Agent.default.sttNode at turn boundaries, in order with the audio. If your override wraps the audio before passing it to Agent.default.sttNode, the wrapper can read ahead, so that flush can reach the STT before audio the wrapper still holds. If your override creates its own STT stream, the framework can't flush it. In either case, set stt.capabilities.manualFlush = false and call flush() on the stream yourself.

    Parameters

    • audio: ReadableStream<AudioFrame> | AsyncIterable<AudioFrame, any, any>
    • modelSettings: ModelSettings

    Returns Promise<null | ReadableStream<string | SpeechEvent>>

  • Parameters

    • text: ReadableStream<string> | AsyncIterable<string, any, any>
    • modelSettings: ModelSettings

    Returns Promise<null | ReadableStream<AudioFrame>>