Octoroom.Agent.Pipeline.Spec (octoroom_agents v0.1.0)

Copy Markdown View Source

Builds a pipeline spec with |>:

import Octoroom.Agent.Pipeline.Spec

processor(:vad, Octoroom.Agent.VAD.Silero)
|> processor(:turns, MyApp.Turns, threshold: 0.5)
|> processor(:llm, MyApp.LLM, model: "google:gemini-3.5-flash")

A spec is a plain value: a chain of named stages. The editing helpers (insert_after/3, insert_before/3, replace/3, remove/2) find stages by name, so a default spec can be changed without rewriting it.

A stage's name defaults to its module. Names must be unique.

Summary

Functions

The usual pipeline of an agent, in two parts: {front_end, back_end}. Each input runs its own front end, and their turns go into one back end

The pipeline of a Gemini Live agent: no front end (the agent mixes its inputs) and one :gemini stage, Octoroom.Agent.Processors.GeminiLive, which takes opts: :model (needed), :voice, :api_key, :context_window_compression (false or [trigger_tokens: ..., target_tokens: ...]), :input_audio_transcription, :output_audio_transcription, and :response_modalities.

Inserts the stages of insert right after the stage name.

Inserts the stages of insert right before the stage name.

Names of the stages, in order.

An empty spec.

The pipeline of an OpenAI Live agent: no front end (the agent mixes its inputs) and one :openai stage, Octoroom.Agent.Processors.OpenAILive, which takes opts: :model (needed, such as "gpt-live-1.1"), :voice (default "marin"), :api_key (default OPENAI_API_KEY), :transport (:webrtc, the default, or :websocket), :sample_rate (24_000 default, or 16_000; WebSocket only), :delegation (:client, [model: "...", ...], or a delegation map), :idle_timeout_s (5..60 seconds before standby, or nil; WebRTC only), :wake_policy (:speech or [type: :speech, vad_threshold: 0.5]; WebRTC only), and :initial_items.

The options of the stage named name, or nil when there's none.

Adds a stage to the end of a spec.

Removes the stage name.

Replaces the stage name with the stages of replacement.

Checks that the spec has at least one stage, that names are unique, and that every module implements Octoroom.Agent.Processor.

Types

name()

@type name() :: atom()

t()

@type t() :: %Octoroom.Agent.Pipeline.Spec{
  stages: [
    %Octoroom.Agent.Pipeline.Spec.Stage{
      module: term(),
      name: term(),
      opts: term()
    }
  ]
}

Functions

default(opts)

The usual pipeline of an agent, in two parts: {front_end, back_end}. Each input runs its own front end, and their turns go into one back end:

front: vad -> stt -> turns
back:  context -> llm -> tools -> chunker -> tts -> collector

It picks no provider and no model: :stt, :llm and :tts are needed, each naming both. Options are their stage's, passed on as they are:

:stt, :llm and :tts also take just a "provider:model" string (or model: "provider:model" alongside extra stage options).

Spec.default(
  stt: "soniox:stt-rt-v6",
  llm: "google:gemini-3.5-flash",
  tts: [provider: :assembly_ai, model: "assemblyai-tts-1", voice: "aai-titus"]
)

With stt: false (half-cascaded) the LLM hears each turn as audio, so it must be a Gemini model, the VAD can't be left out, and :transcriber (Octoroom.Agent.Processors.Transcriber's options) names the model that writes each turn down afterwards:

front: vad -> turns (AudioTurns, Smart Turn)
back:  transcriber -> context -> llm -> tools -> chunker -> tts -> collector

The front end's turn stage doesn't interrupt; the agent decides who may. Change either part with the editing helpers.

gemini_live(opts)

The pipeline of a Gemini Live agent: no front end (the agent mixes its inputs) and one :gemini stage, Octoroom.Agent.Processors.GeminiLive, which takes opts: :model (needed), :voice, :api_key, :context_window_compression (false or [trigger_tokens: ..., target_tokens: ...]), :input_audio_transcription, :output_audio_transcription, and :response_modalities.

Spec.gemini_live(
  model: "gemini-3.8-live",
  voice: "Puck",
  context_window_compression: [trigger_tokens: 24_000, target_tokens: 12_000]
)

insert_after(spec, name, insert)

Inserts the stages of insert right after the stage name.

insert_before(spec, name, insert)

Inserts the stages of insert right before the stage name.

names(spec)

Names of the stages, in order.

new()

An empty spec.

openai_live(opts)

The pipeline of an OpenAI Live agent: no front end (the agent mixes its inputs) and one :openai stage, Octoroom.Agent.Processors.OpenAILive, which takes opts: :model (needed, such as "gpt-live-1.1"), :voice (default "marin"), :api_key (default OPENAI_API_KEY), :transport (:webrtc, the default, or :websocket), :sample_rate (24_000 default, or 16_000; WebSocket only), :delegation (:client, [model: "...", ...], or a delegation map), :idle_timeout_s (5..60 seconds before standby, or nil; WebRTC only), :wake_policy (:speech or [type: :speech, vad_threshold: 0.5]; WebRTC only), and :initial_items.

Spec.openai_live(
  model: "gpt-live-1.1",
  voice: "marin",
  delegation: [model: "gpt-5.4-mini"],
  idle_timeout_s: 15,
  wake_policy: [type: :speech, vad_threshold: 0.5]
)

opts(spec, name)

The options of the stage named name, or nil when there's none.

processor(a)

Adds a stage to the end of a spec.

Accepts, optionally after a spec to pipe into: module, name, module, module, opts, or name, module, opts.

processor(a, b)

processor(a, b, c)

processor(a, b, c, d)

remove(spec, name)

Removes the stage name.

replace(spec, name, replacement)

Replaces the stage name with the stages of replacement.

validate(spec)

Checks that the spec has at least one stage, that names are unique, and that every module implements Octoroom.Agent.Processor.