Prompt.ts overview
The Prompt
module provides several data structures to simplify creating and combining prompts.
This module defines the complete structure of a conversation with a large language model, including messages, content parts, and provider-specific options. It supports rich content types like text, files, tool calls, and reasoning.
Example
import { Prompt } from "@effect/ai"
// Create a structured conversation
const conversation = Prompt.make([
{
role: "system",
content: "You are a helpful assistant specialized in mathematics."
},
{
role: "user",
content: [
{
type: "text",
text: "What is the derivative of x²?"
}
]
},
{
role: "assistant",
content: [
{
type: "text",
text: "The derivative of x² is 2x."
}
]
}
])
Example
import { Prompt } from "@effect/ai"
// Merge multiple prompts
const systemPrompt = Prompt.make([
{
role: "system",
content: "You are a coding assistant."
}
])
const userPrompt = Prompt.make("Help me write a function")
const combined = Prompt.merge(systemPrompt, userPrompt)
Since v1.0.0
Exports Grouped by Category
- Combinators
- Constructors
- Guards
- Models
- AssistantMessage (interface)
- AssistantMessageEncoded (interface)
- AssistantMessagePart (type alias)
- AssistantMessagePartEncoded (type alias)
- BaseMessage (interface)
- BaseMessageEncoded (interface)
- BasePart (interface)
- BasePartEncoded (interface)
- FilePart (interface)
- FilePartEncoded (interface)
- Message (type alias)
- MessageEncoded (type alias)
- Part (type alias)
- PartEncoded (type alias)
- Prompt (interface)
- PromptEncoded (interface)
- ProviderOptions
- ProviderOptions (type alias)
- RawInput (type alias)
- ReasoningPart (interface)
- ReasoningPartEncoded (interface)
- SystemMessage (interface)
- SystemMessageEncoded (interface)
- TextPart (interface)
- TextPartEncoded (interface)
- ToolCallPart (interface)
- ToolCallPartEncoded (interface)
- ToolMessage (interface)
- ToolMessageEncoded (interface)
- ToolMessagePart (type alias)
- ToolMessagePartEncoded (type alias)
- ToolResultPart (interface)
- ToolResultPartEncoded (interface)
- UserMessage (interface)
- UserMessageEncoded (interface)
- UserMessagePart (type alias)
- UserMessagePartEncoded (type alias)
- ProviderOptions
- Schemas
- Type Ids
Combinators
appendSystem
Creates a new prompt from the specified prompt with the provided text content appended to the end of existing system message content.
If no system message exists in the specified prompt, the provided content will be used to create a system message.
Example
import { Prompt } from "@effect/ai"
const systemPrompt = Prompt.make([
{
role: "system",
content: "You are a helpful assistant."
}
])
const userPrompt = Prompt.make("Hello, world!")
const prompt = Prompt.merge(systemPrompt, userPrompt)
const replaced = Prompt.appendSystem(prompt, " You are an expert in programming.")
Signature
declare const appendSystem: { (content: string): (self: Prompt) => Prompt; (self: Prompt, content: string): Prompt }
Since v1.0.0
merge
Merges a prompt with additional raw input by concatenating messages.
Creates a new prompt containing all messages from both the original prompt, and the provided raw input, maintaining the order of messages.
Example
import { Prompt } from "@effect/ai"
const systemPrompt = Prompt.make([
{
role: "system",
content: "You are a helpful assistant."
}
])
const merged = Prompt.merge(systemPrompt, "Hello, world!")
Signature
declare const merge: { (input: RawInput): (self: Prompt) => Prompt; (self: Prompt, input: RawInput): Prompt }
Since v1.0.0
prependSystem
Creates a new prompt from the specified prompt with the provided text content prepended to the start of existing system message content.
If no system message exists in the specified prompt, the provided content will be used to create a system message.
Example
import { Prompt } from "@effect/ai"
const systemPrompt = Prompt.make([
{
role: "system",
content: "You are an expert in programming."
}
])
const userPrompt = Prompt.make("Hello, world!")
const prompt = Prompt.merge(systemPrompt, userPrompt)
const replaced = Prompt.prependSystem(prompt, "You are a helpful assistant. ")
Signature
declare const prependSystem: { (content: string): (self: Prompt) => Prompt; (self: Prompt, content: string): Prompt }
Since v1.0.0
setSystem
Creates a new prompt from the specified prompt with the system message set to the specified text content.
NOTE: This method will remove and replace any previous system message from the prompt.
Example
import { Prompt } from "@effect/ai"
const systemPrompt = Prompt.make([
{
role: "system",
content: "You are a helpful assistant."
}
])
const userPrompt = Prompt.make("Hello, world!")
const prompt = Prompt.merge(systemPrompt, userPrompt)
const replaced = Prompt.setSystem(prompt, "You are an expert in programming")
Signature
declare const setSystem: { (content: string): (self: Prompt) => Prompt; (self: Prompt, content: string): Prompt }
Since v1.0.0
Constructors
empty
An empty prompt with no messages.
Example
import { Prompt } from "@effect/ai"
const emptyPrompt = Prompt.empty
console.log(emptyPrompt.content) // []
Signature
declare const empty: Prompt
Since v1.0.0
fromMessages
Creates a Prompt from an array of messages.
Example
import { Prompt } from "@effect/ai"
const messages: ReadonlyArray<Prompt.Message> = [
Prompt.makeMessage("system", {
content: "You are a coding assistant."
}),
Prompt.makeMessage("user", {
content: [Prompt.makePart("text", { text: "Help me with TypeScript" })]
})
]
const prompt = Prompt.fromMessages(messages)
Signature
declare const fromMessages: (messages: ReadonlyArray<Message>) => Prompt
Since v1.0.0
fromResponseParts
Creates a Prompt from the response parts of a previous interaction with a large language model.
Converts streaming or non-streaming AI response parts into a structured prompt, typically for use in conversation history or further processing.
Example
import { Prompt, Response } from "@effect/ai"
const responseParts: ReadonlyArray<Response.AnyPart> = [
Response.makePart("text", {
text: "Hello there!"
}),
Response.makePart("tool-call", {
id: "call_1",
name: "get_time",
params: {},
providerExecuted: false
}),
Response.makePart("tool-result", {
id: "call_1",
name: "get_time",
result: "10:30 AM",
encodedResult: "10:30 AM",
providerExecuted: false
})
]
const prompt = Prompt.fromResponseParts(responseParts)
// Creates an assistant message with the response content
Signature
declare const fromResponseParts: (parts: ReadonlyArray<Response.AnyPart>) => Prompt
Since v1.0.0
make
Creates a Prompt from an input.
This is the primary constructor for creating prompts, supporting multiple input formats for convenience and flexibility.
Example
import { Prompt } from "@effect/ai"
// From string - creates a user message
const textPrompt = Prompt.make("Hello, how are you?")
// From messages array
const structuredPrompt = Prompt.make([
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: [{ type: "text", text: "Hi!" }] }
])
// From existing prompt
declare const existingPrompt: Prompt.Prompt
const copiedPrompt = Prompt.make(existingPrompt)
Signature
declare const make: (input: RawInput) => Prompt
Since v1.0.0
makeMessage
Creates a new message with the specified role.
Example
import { Prompt } from "@effect/ai"
const textPart = Prompt.makePart("text", {
text: "Hello, world!"
})
const filePart = Prompt.makeMessage("user", {
content: [textPart]
})
Signature
declare const makeMessage: <const Role extends Message["role"]>(
role: Role,
params: Omit<Extract<Message, { role: Role }>, MessageTypeId | "role" | "options"> & {
readonly options?: Extract<Message, { role: Role }>["options"]
}
) => Extract<Message, { role: Role }>
Since v1.0.0
makePart
Creates a new content part of the specified type.
Example
import { Prompt } from "@effect/ai"
const textPart = Prompt.makePart("text", {
text: "Hello, world!"
})
const filePart = Prompt.makePart("file", {
mediaType: "image/png",
fileName: "screenshot.png",
data: new Uint8Array([1, 2, 3])
})
Signature
declare const makePart: <const Type extends Part["type"]>(
type: Type,
params: Omit<Extract<Part, { type: Type }>, PartTypeId | "type" | "options"> & {
readonly options?: Extract<Part, { type: Type }>["options"] | undefined
}
) => Extract<Part, { type: Type }>
Since v1.0.0
Guards
isMessage
Type guard to check if a value is a Message.
Signature
declare const isMessage: (u: unknown) => u is Message
Since v1.0.0
isPart
Type guard to check if a value is a Part.
Signature
declare const isPart: (u: unknown) => u is Part
Since v1.0.0
isPrompt
Type guard to check if a value is a Prompt.
Signature
declare const isPrompt: (u: unknown) => u is Prompt
Since v1.0.0
Models
AssistantMessage (interface)
Message representing large language model assistant responses.
Example
import { Prompt } from "@effect/ai"
const assistantMessage: Prompt.AssistantMessage = Prompt.makeMessage("assistant", {
content: [
Prompt.makePart("text", {
text: "The user is asking about the weather. I should use the weather tool."
}),
Prompt.makePart("tool-call", {
id: "call_123",
name: "get_weather",
params: { city: "San Francisco" },
providerExecuted: false
}),
Prompt.makePart("tool-result", {
id: "call_123",
name: "get_weather",
result: { temperature: 72, condition: "sunny" }
}),
Prompt.makePart("text", {
text: "The weather in San Francisco is currently 72°F and sunny."
})
]
})
Signature
export interface AssistantMessage extends BaseMessage<"assistant", AssistantMessageOptions> {
/**
* Array of content parts that make up the assistant's response.
*/
readonly content: ReadonlyArray<AssistantMessagePart>
}
Since v1.0.0
AssistantMessageEncoded (interface)
Encoded representation of assistant messages for serialization.
Signature
export interface AssistantMessageEncoded extends BaseMessageEncoded<"assistant", AssistantMessageOptions> {
readonly content: string | ReadonlyArray<AssistantMessagePartEncoded>
}
Since v1.0.0
AssistantMessagePart (type alias)
Union type of content parts allowed in assistant messages.
Signature
type AssistantMessagePart = TextPart | FilePart | ReasoningPart | ToolCallPart | ToolResultPart
Since v1.0.0
AssistantMessagePartEncoded (type alias)
Union type of encoded content parts for assistant messages.
Signature
type AssistantMessagePartEncoded =
| TextPartEncoded
| FilePartEncoded
| ReasoningPartEncoded
| ToolCallPartEncoded
| ToolResultPartEncoded
Since v1.0.0
BaseMessage (interface)
Base interface for all message types.
Provides common structure including role and provider options.
Signature
export interface BaseMessage<Role extends string, Options extends ProviderOptions> {
readonly [MessageTypeId]: MessageTypeId
/**
* The role of the message participant.
*/
readonly role: Role
/**
* Provider-specific options for this message.
*/
readonly options: Options
}
Since v1.0.0
BaseMessageEncoded (interface)
Base interface for encoded message types.
Signature
export interface BaseMessageEncoded<Role extends string, Options extends ProviderOptions> {
/**
* The role of the message participant.
*/
readonly role: Role
/**
* Provider-specific options for this message.
*/
readonly options?: Options | undefined
}
Since v1.0.0
BasePart (interface)
Base interface for all content parts.
Provides common structure including type and provider options.
Signature
export interface BasePart<Type extends string, Options extends ProviderOptions> {
readonly [PartTypeId]: PartTypeId
/**
* The type of this content part.
*/
readonly type: Type
/**
* Provider-specific options for this part.
*/
readonly options: Options
}
Since v1.0.0
BasePartEncoded (interface)
Base interface for encoded content parts.
Signature
export interface BasePartEncoded<Type extends string, Options extends ProviderOptions> {
/**
* The type of this content part.
*/
readonly type: Type
/**
* Provider-specific options for this part.
*/
readonly options?: Options | undefined
}
Since v1.0.0
FilePart (interface)
Content part representing a file attachment. Files can be provided as base64 strings of data, byte arrays, or URLs.
Supports various file types including images, documents, and binary data.
Example
import { Prompt } from "@effect/ai"
const imagePart: Prompt.FilePart = Prompt.makePart("file", {
mediaType: "image/jpeg",
fileName: "photo.jpg",
data: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ..."
})
const documentPart: Prompt.FilePart = Prompt.makePart("file", {
mediaType: "application/pdf",
fileName: "report.pdf",
data: new Uint8Array([1, 2, 3])
})
Signature
export interface FilePart extends BasePart<"file", FilePartOptions> {
/**
* MIME type of the file (e.g., "image/jpeg", "application/pdf").
*/
readonly mediaType: string
/**
* Optional filename for the file.
*/
readonly fileName?: string | undefined
/**
* File data as base64 string of data, a byte array, or a URL.
*/
readonly data: string | Uint8Array | URL
}
Since v1.0.0
FilePartEncoded (interface)
Encoded representation of file parts for serialization.
Signature
export interface FilePartEncoded extends BasePartEncoded<"file", FilePartOptions> {
/**
* MIME type of the file (e.g., "image/jpeg", "application/pdf").
*/
readonly mediaType: string
/**
* Optional filename for the file.
*/
readonly fileName?: string | undefined
/**
* File data as base64 string of data, a byte array, or a URL.
*/
readonly data: string | Uint8Array | URL
}
Since v1.0.0
Message (type alias)
A type representing all possible message types in a conversation.
Signature
type Message = SystemMessage | UserMessage | AssistantMessage | ToolMessage
Since v1.0.0
MessageEncoded (type alias)
A type representing all possible encoded message types for serialization.
Signature
type MessageEncoded = SystemMessageEncoded | UserMessageEncoded | AssistantMessageEncoded | ToolMessageEncoded
Since v1.0.0
Part (type alias)
Union type representing all possible content parts within messages.
Parts are the building blocks of message content, supporting text, files, reasoning, tool calls, and tool results.
Signature
type Part = TextPart | ReasoningPart | FilePart | ToolCallPart | ToolResultPart
Since v1.0.0
PartEncoded (type alias)
Encoded representation of a Part.
Signature
type PartEncoded =
| TextPartEncoded
| ReasoningPartEncoded
| FilePartEncoded
| ToolCallPartEncoded
| ToolResultPartEncoded
Since v1.0.0
Prompt (interface)
A Prompt contains a sequence of messages that form the context of a conversation with a large language model.
Signature
export interface Prompt extends Pipeable {
readonly [TypeId]: TypeId
/**
* Array of messages that make up the conversation.
*/
readonly content: ReadonlyArray<Message>
}
Since v1.0.0
PromptEncoded (interface)
Encoded representation of prompts for serialization.
Signature
export interface PromptEncoded {
/**
* Array of messages that make up the conversation.
*/
readonly content: ReadonlyArray<MessageEncoded>
}
Since v1.0.0
ProviderOptions
Schema for provider-specific options which can be attached to both content parts and messages, enabling provider-specific behavior.
Provider-specific options are namespaced by provider and have the structure:
{
"<provider-specific-key>": {
// Provider-specific options
}
}
Signature
declare const ProviderOptions: Schema.Record$<
typeof Schema.String,
Schema.UndefinedOr<Schema.Record$<typeof Schema.String, typeof Schema.Unknown>>
>
Since v1.0.0
ProviderOptions (type alias)
Signature
type ProviderOptions = typeof ProviderOptions.Type
Since v1.0.0
RawInput (type alias)
Raw input types that can be converted into a Prompt.
Supports various input formats for convenience, including simple strings, message arrays, response parts, and existing prompts.
Example
import { Prompt } from "@effect/ai"
// String input - creates a user message
const stringInput: Prompt.RawInput = "Hello, world!"
// Message array input
const messagesInput: Prompt.RawInput = [
{ role: "system", content: "You are helpful." },
{ role: "user", content: [{ type: "text", text: "Hi!" }] }
]
// Existing prompt
declare const existingPrompt: Prompt.Prompt
const promptInput: Prompt.RawInput = existingPrompt
Signature
type RawInput = string | Iterable<MessageEncoded> | Prompt
Since v1.0.0
ReasoningPart (interface)
Content part representing reasoning or chain-of-thought.
Example
import { Prompt } from "@effect/ai"
const reasoningPart: Prompt.ReasoningPart = Prompt.makePart("reasoning", {
text: "Let me think step by step: First I need to understand the user's question..."
})
Signature
export interface ReasoningPart extends BasePart<"reasoning", ReasoningPartOptions> {
/**
* The reasoning or thought process text.
*/
readonly text: string
}
Since v1.0.0
ReasoningPartEncoded (interface)
Encoded representation of reasoning parts for serialization.
Signature
export interface ReasoningPartEncoded extends BasePartEncoded<"reasoning", ReasoningPartOptions> {
/**
* The reasoning or thought process text.
*/
readonly text: string
}
Since v1.0.0
SystemMessage (interface)
Message representing system instructions or context.
Example
import { Prompt } from "@effect/ai"
const systemMessage: Prompt.SystemMessage = Prompt.makeMessage("system", {
content: "You are a helpful assistant specialized in mathematics. " + "Always show your work step by step."
})
Signature
export interface SystemMessage extends BaseMessage<"system", SystemMessageOptions> {
/**
* The system instruction or context as plain text.
*/
readonly content: string
}
Since v1.0.0
SystemMessageEncoded (interface)
Encoded representation of system messages for serialization.
Signature
export interface SystemMessageEncoded extends BaseMessageEncoded<"system", SystemMessageOptions> {
/**
* The system instruction or context as plain text.
*/
readonly content: string
}
Since v1.0.0
TextPart (interface)
Content part representing plain text.
The most basic content type used for textual information in messages.
Example
import { Prompt } from "@effect/ai"
const textPart: Prompt.TextPart = Prompt.makePart("text", {
text: "Hello, how can I help you today?"
})
Signature
export interface TextPart extends BasePart<"text", TextPartOptions> {
/**
* The text content.
*/
readonly text: string
}
Since v1.0.0
TextPartEncoded (interface)
Encoded representation of text parts for serialization.
Signature
export interface TextPartEncoded extends BasePartEncoded<"text", TextPartOptions> {
/**
* The text content.
*/
readonly text: string
}
Since v1.0.0
ToolCallPart (interface)
Content part representing a tool call request.
Example
import { Prompt } from "@effect/ai"
const toolCallPart: Prompt.ToolCallPart = Prompt.makePart("tool-call", {
id: "call_123",
name: "get_weather",
params: { city: "San Francisco", units: "celsius" },
providerExecuted: false
})
Signature
export interface ToolCallPart extends BasePart<"tool-call", ToolCallPartOptions> {
/**
* Unique identifier for this tool call.
*/
readonly id: string
/**
* Name of the tool to invoke.
*/
readonly name: string
/**
* Parameters to pass to the tool.
*/
readonly params: unknown
/**
* Whether the tool was executed by the provider (true) or framework (false).
*/
readonly providerExecuted: boolean
}
Since v1.0.0
ToolCallPartEncoded (interface)
Encoded representation of tool call parts for serialization.
Signature
export interface ToolCallPartEncoded extends BasePartEncoded<"tool-call", ToolCallPartOptions> {
/**
* Unique identifier for this tool call.
*/
readonly id: string
/**
* Name of the tool to invoke.
*/
readonly name: string
/**
* Parameters to pass to the tool.
*/
readonly params: unknown
/**
* Whether the tool was executed by the provider (true) or framework (false).
*/
readonly providerExecuted?: boolean | undefined
}
Since v1.0.0
ToolMessage (interface)
Message representing tool execution results.
Example
import { Prompt } from "@effect/ai"
const toolMessage: Prompt.ToolMessage = Prompt.makeMessage("tool", {
content: [
Prompt.makePart("tool-result", {
id: "call_123",
name: "search_web",
result: {
query: "TypeScript best practices",
results: [
{ title: "TypeScript Handbook", url: "https://..." },
{ title: "Effective TypeScript", url: "https://..." }
]
}
})
]
})
Signature
export interface ToolMessage extends BaseMessage<"tool", ToolMessageOptions> {
/**
* Array of tool result parts.
*/
readonly content: ReadonlyArray<ToolMessagePart>
}
Since v1.0.0
ToolMessageEncoded (interface)
Encoded representation of tool messages for serialization.
Signature
export interface ToolMessageEncoded extends BaseMessageEncoded<"tool", ToolMessageOptions> {
/**
* Array of tool result parts.
*/
readonly content: ReadonlyArray<ToolMessagePartEncoded>
}
Since v1.0.0
ToolMessagePart (type alias)
Union type of content parts allowed in tool messages.
Signature
type ToolMessagePart = ToolResultPart
Since v1.0.0
ToolMessagePartEncoded (type alias)
Union type of encoded content parts for tool messages.
Signature
type ToolMessagePartEncoded = ToolResultPartEncoded
Since v1.0.0
ToolResultPart (interface)
Content part representing the result of a tool call.
Example
import { Prompt } from "@effect/ai"
const toolResultPart: Prompt.ToolResultPart = Prompt.makePart("tool-result", {
id: "call_123",
name: "get_weather",
result: {
temperature: 22,
condition: "sunny",
humidity: 65
}
})
Signature
export interface ToolResultPart extends BasePart<"tool-result", ToolResultPartOptions> {
/**
* Unique identifier matching the original tool call.
*/
readonly id: string
/**
* Name of the tool that was executed.
*/
readonly name: string
/**
* The result returned by the tool execution.
*/
readonly result: unknown
}
Since v1.0.0
ToolResultPartEncoded (interface)
Encoded representation of tool result parts for serialization.
Signature
export interface ToolResultPartEncoded extends BasePartEncoded<"tool-result", ToolResultPartOptions> {
/**
* Unique identifier matching the original tool call.
*/
readonly id: string
/**
* Name of the tool that was executed.
*/
readonly name: string
/**
* The result returned by the tool execution.
*/
readonly result: unknown
}
Since v1.0.0
UserMessage (interface)
Message representing user input or questions.
Example
import { Prompt } from "@effect/ai"
const textUserMessage: Prompt.UserMessage = Prompt.makeMessage("user", {
content: [
Prompt.makePart("text", {
text: "Can you analyze this image for me?"
})
]
})
const multimodalUserMessage: Prompt.UserMessage = Prompt.makeMessage("user", {
content: [
Prompt.makePart("text", {
text: "What do you see in this image?"
}),
Prompt.makePart("file", {
mediaType: "image/jpeg",
fileName: "vacation.jpg",
data: "data:image/jpeg;base64,..."
})
]
})
Signature
export interface UserMessage extends BaseMessage<"user", UserMessageOptions> {
/**
* Array of content parts that make up the user's message.
*/
readonly content: ReadonlyArray<UserMessagePart>
}
Since v1.0.0
UserMessageEncoded (interface)
Encoded representation of user messages for serialization.
Signature
export interface UserMessageEncoded extends BaseMessageEncoded<"user", UserMessageOptions> {
/**
* Array of content parts that make up the user's message.
*/
readonly content: string | ReadonlyArray<UserMessagePartEncoded>
}
Since v1.0.0
UserMessagePart (type alias)
Union type of content parts allowed in user messages.
Signature
type UserMessagePart = TextPart | FilePart
Since v1.0.0
UserMessagePartEncoded (type alias)
Union type of encoded content parts for user messages.
Signature
type UserMessagePartEncoded = TextPartEncoded | FilePartEncoded
Since v1.0.0
ProviderOptions
AssistantMessageOptions (interface)
Represents provider-specific options that can be associated with a AssistantMessage
through module augmentation.
Signature
export interface AssistantMessageOptions extends ProviderOptions {}
Since v1.0.0
FilePartOptions (interface)
Represents provider-specific options that can be associated with a FilePart
through module augmentation.
Signature
export interface FilePartOptions extends ProviderOptions {}
Since v1.0.0
ReasoningPartOptions (interface)
Represents provider-specific options that can be associated with a ReasoningPart
through module augmentation.
Signature
export interface ReasoningPartOptions extends ProviderOptions {}
Since v1.0.0
SystemMessageOptions (interface)
Represents provider-specific options that can be associated with a SystemMessage
through module augmentation.
Signature
export interface SystemMessageOptions extends ProviderOptions {}
Since v1.0.0
TextPartOptions (interface)
Represents provider-specific options that can be associated with a TextPart
through module augmentation.
Signature
export interface TextPartOptions extends ProviderOptions {}
Since v1.0.0
ToolCallPartOptions (interface)
Represents provider-specific options that can be associated with a ToolCallPart
through module augmentation.
Signature
export interface ToolCallPartOptions extends ProviderOptions {}
Since v1.0.0
ToolMessageOptions (interface)
Represents provider-specific options that can be associated with a ToolMessage
through module augmentation.
Signature
export interface ToolMessageOptions extends ProviderOptions {}
Since v1.0.0
ToolResultPartOptions (interface)
Represents provider-specific options that can be associated with a ToolResultPart
through module augmentation.
Signature
export interface ToolResultPartOptions extends ProviderOptions {}
Since v1.0.0
UserMessageOptions (interface)
Represents provider-specific options that can be associated with a UserMessage
through module augmentation.
Signature
export interface UserMessageOptions extends ProviderOptions {}
Since v1.0.0
Schemas
AssistantMessage
Schema for validation and encoding of assistant messages.
Signature
declare const AssistantMessage: Schema.Schema<AssistantMessage, AssistantMessageEncoded, never>
Since v1.0.0
FilePart
Schema for validation and encoding of file parts.
Signature
declare const FilePart: Schema.Schema<FilePart, FilePartEncoded, never>
Since v1.0.0
FromJson
Schema for parsing a Prompt from JSON strings.
Signature
declare const FromJson: Schema.transform<
Schema.SchemaClass<unknown, string, never>,
Schema.Schema<Prompt, PromptEncoded, never>
>
Since v1.0.0
Message
Schema for validation and encoding of messages.
Signature
declare const Message: Schema.Schema<Message, MessageEncoded, never>
Since v1.0.0
MessageContentFromString
Schema for decoding message content (i.e. an array containing a single TextPart
) from a string.
Signature
declare const MessageContentFromString: Schema.Schema<readonly [TextPart, ...TextPart[]], string, never>
Since v1.0.0
Prompt
Schema for validation and encoding of prompts.
Signature
declare const Prompt: Schema.Schema<Prompt, PromptEncoded, never>
Since v1.0.0
PromptFromSelf (class)
Describes a schema that represents a Prompt
instance.
Signature
declare class PromptFromSelf
Since v1.0.0
ReasoningPart
Schema for validation and encoding of reasoning parts.
Signature
declare const ReasoningPart: Schema.Schema<ReasoningPart, ReasoningPartEncoded, never>
Since v1.0.0
SystemMessage
Schema for validation and encoding of system messages.
Signature
declare const SystemMessage: Schema.Schema<SystemMessage, SystemMessageEncoded, never>
Since v1.0.0
TextPart
Schema for validation and encoding of text parts.
Signature
declare const TextPart: Schema.Schema<TextPart, TextPartEncoded, never>
Since v1.0.0
ToolCallPart
Schema for validation and encoding of tool call parts.
Signature
declare const ToolCallPart: Schema.Schema<ToolCallPart, ToolCallPartEncoded, never>
Since v1.0.0
ToolMessage
Schema for validation and encoding of tool messages.
Signature
declare const ToolMessage: Schema.Schema<ToolMessage, ToolMessageEncoded, never>
Since v1.0.0
ToolResultPart
Schema for validation and encoding of tool result parts.
Signature
declare const ToolResultPart: Schema.Schema<ToolResultPart, ToolResultPartEncoded, never>
Since v1.0.0
UserMessage
Schema for validation and encoding of user messages.
Signature
declare const UserMessage: Schema.Schema<UserMessage, UserMessageEncoded, never>
Since v1.0.0
Type Ids
MessageTypeId
Unique identifier for Message instances.
Signature
declare const MessageTypeId: "~effect/ai/Prompt/Message"
Since v1.0.0
MessageTypeId (type alias)
Type-level representation of the Message identifier.
Signature
type MessageTypeId = typeof MessageTypeId
Since v1.0.0
PartTypeId
Unique identifier for Part instances.
Signature
declare const PartTypeId: "~effect/ai/Prompt/Part"
Since v1.0.0
PartTypeId (type alias)
Type-level representation of the Part identifier.
Signature
type PartTypeId = typeof PartTypeId
Since v1.0.0
TypeId
Unique identifier for Prompt instances.
Signature
declare const TypeId: "~@effect/ai/Prompt"
Since v1.0.0
TypeId (type alias)
Type-level representation of the Prompt identifier.
Signature
type TypeId = typeof TypeId
Since v1.0.0