LLMMessageBuilder
Defined in: core/messages.ts:69
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new LLMMessageBuilder(
promptConfig?):LLMMessageBuilder
Defined in: core/messages.ts:76
Parameters
Section titled “Parameters”promptConfig?
Section titled “promptConfig?”Returns
Section titled “Returns”LLMMessageBuilder
Methods
Section titled “Methods”addAssistant()
Section titled “addAssistant()”addAssistant(
content,metadata?):this
Defined in: core/messages.ts:370
Parameters
Section titled “Parameters”content
Section titled “content”string
metadata?
Section titled “metadata?”Record<string, unknown>
Returns
Section titled “Returns”this
addGadgetCallResult()
Section titled “addGadgetCallResult()”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.
Parameters
Section titled “Parameters”gadget
Section titled “gadget”string
Name of the gadget that was executed
parameters
Section titled “parameters”Record<string, unknown>
Parameters that were passed to the gadget
result
Section titled “result”string
Text result from the gadget execution
invocationId
Section titled “invocationId”string
Invocation ID (shown to LLM so it can reference for dependencies)
media?
Section titled “media?”Optional media outputs from the gadget
mediaIds?
Section titled “mediaIds?”string[]
Optional IDs for the media outputs
Returns
Section titled “Returns”LLMMessageBuilder
addGadgets()
Section titled “addGadgets()”addGadgets(
gadgets,options?):this
Defined in: core/messages.ts:98
Parameters
Section titled “Parameters”gadgets
Section titled “gadgets”options?
Section titled “options?”argPrefix?
Section titled “argPrefix?”string
endPrefix?
Section titled “endPrefix?”string
startPrefix?
Section titled “startPrefix?”string
Returns
Section titled “Returns”this
addSystem()
Section titled “addSystem()”addSystem(
content,metadata?):this
Defined in: core/messages.ts:93
Parameters
Section titled “Parameters”content
Section titled “content”string
metadata?
Section titled “metadata?”Record<string, unknown>
Returns
Section titled “Returns”this
addUser()
Section titled “addUser()”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).
Parameters
Section titled “Parameters”content
Section titled “content”Message content
metadata?
Section titled “metadata?”Record<string, unknown>
Optional metadata
Returns
Section titled “Returns”this
Example
Section titled “Example”// Text onlybuilder.addUser("Hello!");
// Multimodalbuilder.addUser([ text("What's in this image?"), imageFromBuffer(imageData),]);addUserMultimodal()
Section titled “addUserMultimodal()”addUserMultimodal(
parts):this
Defined in: core/messages.ts:486
Add a user message with multiple content parts. Provides full flexibility for complex multimodal messages.
Parameters
Section titled “Parameters”Array of content parts
Returns
Section titled “Returns”this
Example
Section titled “Example”builder.addUserMultimodal([ text("Compare these images:"), imageFromBuffer(image1), imageFromBuffer(image2),]);addUserWithAudio()
Section titled “addUserWithAudio()”addUserWithAudio(
textContent,audioData,mimeType?):this
Defined in: core/messages.ts:458
Add a user message with an audio attachment (Gemini only).
Parameters
Section titled “Parameters”textContent
Section titled “textContent”string
Text prompt
audioData
Section titled “audioData”Audio data (Buffer, Uint8Array, or base64 string)
string | Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike>
mimeType?
Section titled “mimeType?”Optional MIME type (auto-detected if not provided)
Returns
Section titled “Returns”this
Example
Section titled “Example”builder.addUserWithAudio( "Transcribe this audio", await fs.readFile("recording.mp3"), "audio/mp3" // Optional - auto-detected);addUserWithImage()
Section titled “addUserWithImage()”addUserWithImage(
textContent,imageData,mimeType?):this
Defined in: core/messages.ts:391
Add a user message with an image attachment.
Parameters
Section titled “Parameters”textContent
Section titled “textContent”string
Text prompt
imageData
Section titled “imageData”Image data (Buffer, Uint8Array, or base64 string)
string | Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike>
mimeType?
Section titled “mimeType?”Optional MIME type (auto-detected if not provided)
Returns
Section titled “Returns”this
Example
Section titled “Example”builder.addUserWithImage( "What's in this image?", await fs.readFile("photo.jpg"), "image/jpeg" // Optional - auto-detected);addUserWithImageUrl()
Section titled “addUserWithImageUrl()”addUserWithImageUrl(
textContent,imageUrl):this
Defined in: core/messages.ts:436
Add a user message with an image URL (OpenAI only).
Parameters
Section titled “Parameters”textContent
Section titled “textContent”string
Text prompt
imageUrl
Section titled “imageUrl”string
URL to the image
Returns
Section titled “Returns”this
Example
Section titled “Example”builder.addUserWithImageUrl( "What's in this image?", "https://example.com/image.jpg");build()
Section titled “build()”build():
LLMMessage[]
Defined in: core/messages.ts:581
Returns
Section titled “Returns”withPrefixes()
Section titled “withPrefixes()”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.
Parameters
Section titled “Parameters”startPrefix
Section titled “startPrefix”string
endPrefix
Section titled “endPrefix”string
argPrefix?
Section titled “argPrefix?”string
Returns
Section titled “Returns”this