Skip to content

LLMMessageBuilder

Defined in: core/messages.ts:69

new LLMMessageBuilder(promptConfig?): LLMMessageBuilder

Defined in: core/messages.ts:76

PromptTemplateConfig

LLMMessageBuilder

addAssistant(content, metadata?): this

Defined in: core/messages.ts:370

string

Record<string, unknown>

this


addGadgetCallResult(gadget, parameters, result, invocationId, media?, mediaIds?): LLMMessageBuilder

Defined in: core/messages.ts:504

Record a gadget execution result in the message history. Creates an assistant message with the gadget invocation and a user message with the result.

The invocationId is shown to the LLM so it can reference previous calls when building dependencies.

string

Name of the gadget that was executed

Record<string, unknown>

Parameters that were passed to the gadget

string

Text result from the gadget execution

string

Invocation ID (shown to LLM so it can reference for dependencies)

GadgetMediaOutput[]

Optional media outputs from the gadget

string[]

Optional IDs for the media outputs

LLMMessageBuilder


addGadgets(gadgets, options?): this

Defined in: core/messages.ts:98

AbstractGadget[]

string

string

string

this


addSystem(content, metadata?): this

Defined in: core/messages.ts:93

string

Record<string, unknown>

this


addUser(content, metadata?): this

Defined in: core/messages.ts:365

Add a user message. Content can be a string (text only) or an array of content parts (multimodal).

MessageContent

Message content

Record<string, unknown>

Optional metadata

this

// Text only
builder.addUser("Hello!");
// Multimodal
builder.addUser([
text("What's in this image?"),
imageFromBuffer(imageData),
]);

addUserMultimodal(parts): this

Defined in: core/messages.ts:486

Add a user message with multiple content parts. Provides full flexibility for complex multimodal messages.

ContentPart[]

Array of content parts

this

builder.addUserMultimodal([
text("Compare these images:"),
imageFromBuffer(image1),
imageFromBuffer(image2),
]);

addUserWithAudio(textContent, audioData, mimeType?): this

Defined in: core/messages.ts:458

Add a user message with an audio attachment (Gemini only).

string

Text prompt

Audio data (Buffer, Uint8Array, or base64 string)

string | Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike>

AudioMimeType

Optional MIME type (auto-detected if not provided)

this

builder.addUserWithAudio(
"Transcribe this audio",
await fs.readFile("recording.mp3"),
"audio/mp3" // Optional - auto-detected
);

addUserWithImage(textContent, imageData, mimeType?): this

Defined in: core/messages.ts:391

Add a user message with an image attachment.

string

Text prompt

Image data (Buffer, Uint8Array, or base64 string)

string | Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike>

ImageMimeType

Optional MIME type (auto-detected if not provided)

this

builder.addUserWithImage(
"What's in this image?",
await fs.readFile("photo.jpg"),
"image/jpeg" // Optional - auto-detected
);

addUserWithImageUrl(textContent, imageUrl): this

Defined in: core/messages.ts:436

Add a user message with an image URL (OpenAI only).

string

Text prompt

string

URL to the image

this

builder.addUserWithImageUrl(
"What's in this image?",
"https://example.com/image.jpg"
);

build(): LLMMessage[]

Defined in: core/messages.ts:581

LLMMessage[]


withPrefixes(startPrefix, endPrefix, argPrefix?): this

Defined in: core/messages.ts:84

Set custom prefixes for gadget markers. Used to configure history builder to match system prompt markers.

string

string

string

this