Skip to content

Prompt

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.

90 exports Added in v1.0.0 Source

Combinators

appendSystem

Added in v1.0.0 Source

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.

Signature

declare const appendSystem: {
  (content: string): (self: Prompt) => Prompt;
  (self: Prompt, content: string): Prompt;
};

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.appendSystem(prompt, " You are a helpful assistant.")
// result content: "You are an expert in programming. You are a helpful assistant."

merge

Added in v1.0.0 Source

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.

Signature

declare const merge: {
  (input: RawInput): (self: Prompt) => Prompt;
  (self: Prompt, input: RawInput): Prompt;
};

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!")

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.

Signature

declare const prependSystem: {
  (content: string): (self: Prompt) => Prompt;
  (self: Prompt, content: string): Prompt;
};

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. ")
// result content: "You are a helpful assistant. You are an expert in programming."

setSystem

Added in v1.0.0 Source

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.

Signature

declare const setSystem: {
  (content: string): (self: Prompt) => Prompt;
  (self: Prompt, content: string): 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")

Constructors

Constructs a new assistant message.

Signature

declare function assistantMessage(
  params: MessageConstructorParams<AssistantMessage>,
): AssistantMessage;

empty

Added in v1.0.0 Source

An empty prompt with no messages.

Signature

declare const empty: Prompt;

Example

import { Prompt } from "@effect/ai"

const emptyPrompt = Prompt.empty
console.log(emptyPrompt.content) // []

filePart

Added in v1.0.0 Source

Constructs a new file part.

Signature

declare function filePart(params: PartConstructorParams<FilePart>): FilePart;

fromMessages

Added in v1.0.0 Source

Creates a Prompt from an array of messages.

Signature

declare function fromMessages(messages: readonly Array<Message>): Prompt

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.

Signature

declare function fromResponseParts(parts: readonly Array<AnyPart>): Prompt

make

Added in v1.0.0 Source

Creates a Prompt from an input.

This is the primary constructor for creating prompts, supporting multiple input formats for convenience and flexibility.

Signature

declare function make(input: RawInput): Prompt;

makeMessage

Added in v1.0.0 Source

Creates a new message with the specified role.

Signature

declare function makeMessage<Role extends "user" | "assistant" | "system" | "tool">(
  role: Role,
  params: Omit<
    | Extract<
        SystemMessage,
        {
          role: Role;
        }
      >
    | Extract<
        UserMessage,
        {
          role: Role;
        }
      >
    | Extract<
        AssistantMessage,
        {
          role: Role;
        }
      >
    | Extract<
        ToolMessage,
        {
          role: Role;
        }
      >,
    "role" | "options" | "~effect/ai/Prompt/Message"
  > & {
    readonly options?:
      | Extract<
          SystemMessage,
          {
            role: Role;
          }
        >
      | Extract<
          UserMessage,
          {
            role: Role;
          }
        >
      | Extract<
          AssistantMessage,
          {
            role: Role;
          }
        >
      | Extract<
          ToolMessage,
          {
            role: Role;
          }
        >["options"];
  },
):
  | Extract<
      SystemMessage,
      {
        role: Role;
      }
    >
  | Extract<
      UserMessage,
      {
        role: Role;
      }
    >
  | Extract<
      AssistantMessage,
      {
        role: Role;
      }
    >
  | Extract<
      ToolMessage,
      {
        role: Role;
      }
    >;

makePart

Added in v1.0.0 Source

Creates a new content part of the specified type.

Signature

declare function makePart<Type extends "text" | "reasoning" | "file" | "tool-call" | "tool-result">(
  type: Type,
  params: Omit<
    | Extract<
        TextPart,
        {
          type: Type;
        }
      >
    | Extract<
        ReasoningPart,
        {
          type: Type;
        }
      >
    | Extract<
        FilePart,
        {
          type: Type;
        }
      >
    | Extract<
        ToolCallPart,
        {
          type: Type;
        }
      >
    | Extract<
        ToolResultPart,
        {
          type: Type;
        }
      >,
    "type" | "~effect/ai/Prompt/Part" | "options"
  > & {
    readonly options?:
      | Extract<
          TextPart,
          {
            type: Type;
          }
        >
      | Extract<
          ReasoningPart,
          {
            type: Type;
          }
        >
      | Extract<
          FilePart,
          {
            type: Type;
          }
        >
      | Extract<
          ToolCallPart,
          {
            type: Type;
          }
        >
      | Extract<
          ToolResultPart,
          {
            type: Type;
          }
        >["options"];
  },
):
  | Extract<
      TextPart,
      {
        type: Type;
      }
    >
  | Extract<
      ReasoningPart,
      {
        type: Type;
      }
    >
  | Extract<
      FilePart,
      {
        type: Type;
      }
    >
  | Extract<
      ToolCallPart,
      {
        type: Type;
      }
    >
  | Extract<
      ToolResultPart,
      {
        type: Type;
      }
    >;

Constructs a new reasoning part.

Signature

declare function reasoningPart(params: PartConstructorParams<ReasoningPart>): ReasoningPart;

Constructs a new system message.

Signature

declare function systemMessage(params: MessageConstructorParams<SystemMessage>): SystemMessage;

textPart

Added in v1.0.0 Source

Constructs a new text part.

Signature

declare function textPart(params: PartConstructorParams<TextPart>): TextPart;

toolCallPart

Added in v1.0.0 Source

Constructs a new tool call part.

Signature

declare function toolCallPart(params: PartConstructorParams<ToolCallPart>): ToolCallPart;

toolMessage

Added in v1.0.0 Source

Constructs a new tool message.

Signature

declare function toolMessage(params: MessageConstructorParams<ToolMessage>): ToolMessage;

Constructs a new tool result part.

Signature

declare function toolResultPart(params: PartConstructorParams<ToolResultPart>): ToolResultPart;

userMessage

Added in v1.0.0 Source

Constructs a new user message.

Signature

declare function userMessage(params: MessageConstructorParams<UserMessage>): UserMessage;

Guards

isMessage

Added in v1.0.0 Source

Type guard to check if a value is a Message.

Signature

declare function isMessage(u: unknown): u is Message;

isPart

Added in v1.0.0 Source

Type guard to check if a value is a Part.

Signature

declare function isPart(u: unknown): u is Part;

isPrompt

Added in v1.0.0 Source

Type guard to check if a value is a Prompt.

Signature

declare function isPrompt(u: unknown): u is Prompt;

Models

AssistantMessage interface

Added in v1.0.0 Source

Message representing large language model assistant responses.

Signature

interface AssistantMessage extends BaseMessage<"assistant", AssistantMessageOptions> {
  readonly content: readonly Array<AssistantMessagePart>;
}

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",
      isFailure: false,
      result: {
        temperature: 72,
        condition: "sunny",
      },
      providerExecuted: false,
    }),
    Prompt.makePart("text", {
      text: "The weather in San Francisco is currently 72ยฐF and sunny.",
    }),
  ],
})

AssistantMessageEncoded interface

Added in v1.0.0 Source

Encoded representation of assistant messages for serialization.

Signature

interface AssistantMessageEncoded extends BaseMessageEncoded<"assistant", AssistantMessageOptions> {
  readonly content: string | readonly Array<AssistantMessagePartEncoded>;
}

AssistantMessagePart type

Added in v1.0.0 Source

Union type of content parts allowed in assistant messages.

Signature

type AssistantMessagePart = TextPart | FilePart | ReasoningPart | ToolCallPart | ToolResultPart;

Union type of encoded content parts for assistant messages.

Signature

type AssistantMessagePartEncoded =
  | TextPartEncoded
  | FilePartEncoded
  | ReasoningPartEncoded
  | ToolCallPartEncoded
  | ToolResultPartEncoded;

BaseMessage interface

Added in v1.0.0 Source

Base interface for all message types.

Provides common structure including role and provider options.

Signature

interface BaseMessage<Role extends string, Options extends ProviderOptions> {
  readonly "~effect/ai/Prompt/Message": "~effect/ai/Prompt/Message";
  readonly options: Options;
  readonly role: Role;
}

BaseMessageEncoded interface

Added in v1.0.0 Source

Base interface for encoded message types.

Signature

interface BaseMessageEncoded<Role extends string, Options extends ProviderOptions> {
  readonly options?: Options;
  readonly role: Role;
}

BasePart interface

Added in v1.0.0 Source

Base interface for all content parts.

Provides common structure including type and provider options.

Signature

interface BasePart<Type extends string, Options extends ProviderOptions> {
  readonly "~effect/ai/Prompt/Part": "~effect/ai/Prompt/Part";
  readonly options: Options;
  readonly type: Type;
}

BasePartEncoded interface

Added in v1.0.0 Source

Base interface for encoded content parts.

Signature

interface BasePartEncoded<Type extends string, Options extends ProviderOptions> {
  readonly options?: Options;
  readonly type: Type;
}

FilePart interface

Added in v1.0.0 Source

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.

Signature

interface FilePart extends BasePart<"file", FilePartOptions> {
  readonly data: string | Uint8Array<ArrayBufferLike> | URL;
  readonly fileName?: string;
  readonly mediaType: string;
}

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]),
})

FilePartEncoded interface

Added in v1.0.0 Source

Encoded representation of file parts for serialization.

Signature

interface FilePartEncoded extends BasePartEncoded<"file", FilePartOptions> {
  readonly data: string | Uint8Array<ArrayBufferLike> | URL;
  readonly fileName?: string;
  readonly mediaType: string;
}

Message type

Added in v1.0.0 Source

A type representing all possible message types in a conversation.

Signature

type Message = SystemMessage | UserMessage | AssistantMessage | ToolMessage;

MessageEncoded type

Added in v1.0.0 Source

A type representing all possible encoded message types for serialization.

Signature

type MessageEncoded =
  | SystemMessageEncoded
  | UserMessageEncoded
  | AssistantMessageEncoded
  | ToolMessageEncoded;

Part type

Added in v1.0.0 Source

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;

PartEncoded type

Added in v1.0.0 Source

Encoded representation of a Part.

Signature

type PartEncoded =
  | TextPartEncoded
  | ReasoningPartEncoded
  | FilePartEncoded
  | ToolCallPartEncoded
  | ToolResultPartEncoded;

Prompt interface

Added in v1.0.0 Source

A Prompt contains a sequence of messages that form the context of a conversation with a large language model.

Signature

interface Prompt extends Pipeable {
  readonly "~@effect/ai/Prompt": "~@effect/ai/Prompt";
  readonly content: readonly Array<Message>;
}

PromptEncoded interface

Added in v1.0.0 Source

Encoded representation of prompts for serialization.

Signature

interface PromptEncoded {
  readonly content: readonly Array<MessageEncoded>;
}

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:

Signature

declare const ProviderOptions: $Record<Key, Constraint>;

Example

{
  "<provider-specific-key>": {
    // Provider-specific options
  }
}

ProviderOptions type

Added in v1.0.0 Source

Signature

type ProviderOptions = typeof ProviderOptions.Type;

RawInput type

Added in v1.0.0 Source

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.

Signature

type RawInput = string | Iterable<MessageEncoded> | Prompt;

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

ReasoningPart interface

Added in v1.0.0 Source

Content part representing reasoning or chain-of-thought.

Signature

interface ReasoningPart extends BasePart<"reasoning", ReasoningPartOptions> {
  readonly text: string;
}

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...",
})

ReasoningPartEncoded interface

Added in v1.0.0 Source

Encoded representation of reasoning parts for serialization.

Signature

interface ReasoningPartEncoded extends BasePartEncoded<"reasoning", ReasoningPartOptions> {
  readonly text: string;
}

SystemMessage interface

Added in v1.0.0 Source

Message representing system instructions or context.

Signature

interface SystemMessage extends BaseMessage<"system", SystemMessageOptions> {
  readonly content: string;
}

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.",
})

SystemMessageEncoded interface

Added in v1.0.0 Source

Encoded representation of system messages for serialization.

Signature

interface SystemMessageEncoded extends BaseMessageEncoded<"system", SystemMessageOptions> {
  readonly content: string;
}

TextPart interface

Added in v1.0.0 Source

Content part representing plain text.

The most basic content type used for textual information in messages.

Signature

interface TextPart extends BasePart<"text", TextPartOptions> {
  readonly text: string;
}

Example

import { Prompt } from "@effect/ai"

const textPart: Prompt.TextPart = Prompt.makePart("text", {
  text: "Hello, how can I help you today?",
})

TextPartEncoded interface

Added in v1.0.0 Source

Encoded representation of text parts for serialization.

Signature

interface TextPartEncoded extends BasePartEncoded<"text", TextPartOptions> {
  readonly text: string;
}

ToolCallPart interface

Added in v1.0.0 Source

Content part representing a tool call request.

Signature

interface ToolCallPart extends BasePart<"tool-call", ToolCallPartOptions> {
  readonly id: string;
  readonly name: string;
  readonly params: unknown;
  readonly providerExecuted: boolean;
}

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,
})

ToolCallPartEncoded interface

Added in v1.0.0 Source

Encoded representation of tool call parts for serialization.

Signature

interface ToolCallPartEncoded extends BasePartEncoded<"tool-call", ToolCallPartOptions> {
  readonly id: string;
  readonly name: string;
  readonly params: unknown;
  readonly providerExecuted?: boolean;
}

ToolMessage interface

Added in v1.0.0 Source

Message representing tool execution results.

Signature

interface ToolMessage extends BaseMessage<"tool", ToolMessageOptions> {
  readonly content: readonly Array<ToolResultPart>;
}

Example

import { Prompt } from "@effect/ai"

const toolMessage: Prompt.ToolMessage = Prompt.makeMessage("tool", {
  content: [
    Prompt.makePart("tool-result", {
      id: "call_123",
      name: "search_web",
      isFailure: false,
      result: {
        query: "TypeScript best practices",
        results: [
          { title: "TypeScript Handbook", url: "https://..." },
          { title: "Effective TypeScript", url: "https://..." },
        ],
      },
      providerExecuted: false,
    }),
  ],
})

ToolMessageEncoded interface

Added in v1.0.0 Source

Encoded representation of tool messages for serialization.

Signature

interface ToolMessageEncoded extends BaseMessageEncoded<"tool", ToolMessageOptions> {
  readonly content: readonly Array<ToolResultPartEncoded>;
}

ToolMessagePart type

Added in v1.0.0 Source

Union type of content parts allowed in tool messages.

Signature

type ToolMessagePart = ToolResultPart;

Union type of encoded content parts for tool messages.

Signature

type ToolMessagePartEncoded = ToolResultPartEncoded;

ToolResultPart interface

Added in v1.0.0 Source

Content part representing the result of a tool call.

Signature

interface ToolResultPart extends BasePart<"tool-result", ToolResultPartOptions> {
  readonly id: string;
  readonly isFailure: boolean;
  readonly name: string;
  readonly providerExecuted: boolean;
  readonly result: unknown;
}

Example

import { Prompt } from "@effect/ai"

const toolResultPart: Prompt.ToolResultPart = Prompt.makePart("tool-result", {
  id: "call_123",
  name: "get_weather",
  isFailure: false,
  result: {
    temperature: 22,
    condition: "sunny",
    humidity: 65,
  },
  providerExecuted: false,
})

ToolResultPartEncoded interface

Added in v1.0.0 Source

Encoded representation of tool result parts for serialization.

Signature

interface ToolResultPartEncoded extends BasePartEncoded<"tool-result", ToolResultPartOptions> {
  readonly id: string;
  readonly isFailure: boolean;
  readonly name: string;
  readonly providerExecuted: boolean;
  readonly result: unknown;
}

UserMessage interface

Added in v1.0.0 Source

Message representing user input or questions.

Signature

interface UserMessage extends BaseMessage<"user", UserMessageOptions> {
  readonly content: readonly Array<UserMessagePart>;
}

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,...",
    }),
  ],
})

UserMessageEncoded interface

Added in v1.0.0 Source

Encoded representation of user messages for serialization.

Signature

interface UserMessageEncoded extends BaseMessageEncoded<"user", UserMessageOptions> {
  readonly content: string | readonly Array<UserMessagePartEncoded>;
}

UserMessagePart type

Added in v1.0.0 Source

Union type of content parts allowed in user messages.

Signature

type UserMessagePart = TextPart | FilePart;

Union type of encoded content parts for user messages.

Signature

type UserMessagePartEncoded = TextPartEncoded | FilePartEncoded;

ProviderOptions

AssistantMessageOptions interface

Added in v1.0.0 Source

Represents provider-specific options that can be associated with a AssistantMessage through module augmentation.

Signature

interface AssistantMessageOptions extends ProviderOptions {
  [key: string]: unknown;
  [key: number]: unknown;
  [key: symbol]: unknown;
}

FilePartOptions interface

Added in v1.0.0 Source

Represents provider-specific options that can be associated with a FilePart through module augmentation.

Signature

interface FilePartOptions extends ProviderOptions {
  [key: string]: unknown;
  [key: number]: unknown;
  [key: symbol]: unknown;
}

ReasoningPartOptions interface

Added in v1.0.0 Source

Represents provider-specific options that can be associated with a ReasoningPart through module augmentation.

Signature

interface ReasoningPartOptions extends ProviderOptions {
  [key: string]: unknown;
  [key: number]: unknown;
  [key: symbol]: unknown;
}

SystemMessageOptions interface

Added in v1.0.0 Source

Represents provider-specific options that can be associated with a SystemMessage through module augmentation.

Signature

interface SystemMessageOptions extends ProviderOptions {
  [key: string]: unknown;
  [key: number]: unknown;
  [key: symbol]: unknown;
}

TextPartOptions interface

Added in v1.0.0 Source

Represents provider-specific options that can be associated with a TextPart through module augmentation.

Signature

interface TextPartOptions extends ProviderOptions {
  [key: string]: unknown;
  [key: number]: unknown;
  [key: symbol]: unknown;
}

ToolCallPartOptions interface

Added in v1.0.0 Source

Represents provider-specific options that can be associated with a ToolCallPart through module augmentation.

Signature

interface ToolCallPartOptions extends ProviderOptions {
  [key: string]: unknown;
  [key: number]: unknown;
  [key: symbol]: unknown;
}

ToolMessageOptions interface

Added in v1.0.0 Source

Represents provider-specific options that can be associated with a ToolMessage through module augmentation.

Signature

interface ToolMessageOptions extends ProviderOptions {
  [key: string]: unknown;
  [key: number]: unknown;
  [key: symbol]: unknown;
}

ToolResultPartOptions interface

Added in v1.0.0 Source

Represents provider-specific options that can be associated with a ToolResultPart through module augmentation.

Signature

interface ToolResultPartOptions extends ProviderOptions {
  [key: string]: unknown;
  [key: number]: unknown;
  [key: symbol]: unknown;
}

UserMessageOptions interface

Added in v1.0.0 Source

Represents provider-specific options that can be associated with a UserMessage through module augmentation.

Signature

interface UserMessageOptions extends ProviderOptions {
  [key: string]: unknown;
  [key: number]: unknown;
  [key: symbol]: unknown;
}

Schemas

Schema for validation and encoding of assistant messages.

Signature

declare const AssistantMessage: any;

FilePart

Added in v1.0.0 Source

Schema for validation and encoding of file parts.

Signature

declare const FilePart: any;

FromJson

Added in v1.0.0 Source

Schema for parsing a Prompt from JSON strings.

Signature

declare const FromJson: any;

Message

Added in v1.0.0 Source

Schema for validation and encoding of messages.

Signature

declare const Message: any;

Schema for decoding message content (i.e. an array containing a single TextPart) from a string.

Signature

declare const MessageContentFromString: Schema.Schema<Arr.NonEmptyReadonlyArray<TextPart>, string>;

Prompt

Added in v1.0.0 Source

Schema for validation and encoding of prompts.

Signature

declare const Prompt: any;

Describes a schema that represents a Prompt instance.

Signature

declare class PromptFromSelf extends any {
  constructor();
}

Schema for validation and encoding of reasoning parts.

Signature

declare const ReasoningPart: any;

Schema for validation and encoding of system messages.

Signature

declare const SystemMessage: any;

TextPart

Added in v1.0.0 Source

Schema for validation and encoding of text parts.

Signature

declare const TextPart: any;

ToolCallPart

Added in v1.0.0 Source

Schema for validation and encoding of tool call parts.

Signature

declare const ToolCallPart: any;

ToolMessage

Added in v1.0.0 Source

Schema for validation and encoding of tool messages.

Signature

declare const ToolMessage: any;

Schema for validation and encoding of tool result parts.

Signature

declare const ToolResultPart: any;

UserMessage

Added in v1.0.0 Source

Schema for validation and encoding of user messages.

Signature

declare const UserMessage: any;

Type Ids

Unique identifier for Message instances.

Signature

declare const MessageTypeId: "~effect/ai/Prompt/Message";

MessageTypeId type

Added in v1.0.0 Source

Type-level representation of the Message identifier.

Signature

type MessageTypeId = typeof MessageTypeId;

PartTypeId

Added in v1.0.0 Source

Unique identifier for Part instances.

Signature

declare const PartTypeId: "~effect/ai/Prompt/Part";

PartTypeId type

Added in v1.0.0 Source

Type-level representation of the Part identifier.

Signature

type PartTypeId = typeof PartTypeId;

TypeId

Added in v1.0.0 Source

Unique identifier for Prompt instances.

Signature

declare const TypeId: "~@effect/ai/Prompt";

TypeId type

Added in v1.0.0 Source

Type-level representation of the Prompt identifier.

Signature

type TypeId = typeof TypeId;

Utility Types

A utility type for specifying the parameters required to construct a specific message for a prompt.

Signature

type MessageConstructorParams<M extends Message> = Omit<M, MessageTypeId | "role" | "options"> & {
  readonly options?: Part["options"];
};

A utility type for specifying the parameters required to construct a specific part of a prompt.

Signature

type PartConstructorParams<P extends Part> = Omit<P, PartTypeId | "type" | "options"> & {
  readonly options?: Part["options"];
};