Creates a new ChatPromptClient instance.
The chat prompt data
Whether this is fallback content
Readonly
commitOptional commit message for the prompt version
Readonly
configConfiguration object associated with the prompt
Readonly
isWhether this prompt client is using fallback content
Readonly
labelsLabels associated with the prompt
Readonly
nameThe name of the prompt
Readonly
promptThe chat messages that make up the prompt
Readonly
promptThe original prompt response from the API
Readonly
tagsTags associated with the prompt
Readonly
typeThe type of prompt ("text" or "chat")
Readonly
versionThe version number of the prompt
Protected
_Compiles the chat prompt by replacing placeholders and variables.
First resolves placeholders with provided values, then applies variable substitution to message content using Mustache templating. Unresolved placeholders remain as placeholder objects in the output.
Optional
variables: Record<string, string>Key-value pairs for Mustache variable substitution in message content
Optional
placeholders: Record<string, any>Key-value pairs where keys are placeholder names and values are ChatMessage arrays
Array of ChatMessage objects and unresolved placeholder objects
Protected
escapeEscapes every curly brace that is part of a JSON object by doubling it.
A curly brace is considered “JSON-related” when, after skipping any immediate whitespace, the next non-whitespace character is a single (') or double (") quote.
Braces that are already doubled (e.g. {{variable}}
placeholders) are left untouched.
Input string that may contain JSON snippets.
The string with JSON-related braces doubled.
Converts the prompt to LangChain ChatPromptTemplate format.
Resolves placeholders with provided values and converts unresolved ones to LangChain MessagesPlaceholder objects. Transforms variables from {{var}} to {var} format without rendering them.
Optional
options: { placeholders?: Record<string, any> }Configuration object
Optional
placeholders?: Record<string, any>Key-value pairs for placeholder resolution
Array of ChatMessage objects and LangChain MessagesPlaceholder objects
Serializes the prompt client to JSON.
JSON string representation of the prompt
Client for working with chat-based prompts.
Provides methods to compile chat prompts with variable substitution and placeholder resolution, and convert them to LangChain-compatible formats.