Docs
Reference
SDK
classes
Prompt

Class: Prompt

Accessors

id

get id(): string

Returns

string


name

get name(): string

Returns

string


options

get options(): Object

Returns

Object

NameType
model?string
params?{ frequency_penalty?: number ; max_tokens?: number ; presence_penalty?: number ; response_format?: null | { type: "json_object" } ; temperature?: number ; tool_choice?: "auto" | "none" | { function: { name: string } ; type: "function" } ; top_p?: number ; use_cache?: boolean } | { max_tokens: number ; max_tokens_to_sample?: number ; temperature: number ; top_k?: number ; top_p?: number ; use_cache?: boolean } | { maxOutputTokens?: number ; temperature: number ; topK?: number ; topP?: number ; use_cache?: boolean } | { use_cache?: boolean }
position?string

projectId

get projectId(): string

Returns

string


prompt

get prompt(): undefined | null | { content: string ; type: "completion" } | { messages: ({ content: string ; name?: string ; role: "system" } | { content: {} ; name?: string ; role: "user" } | { content: string ; role: "tool" ; tool_call_id: string } | { content: string ; name: string ; role: "function" } | { content?: null | string ; function_call?: { arguments: string ; name: string } ; name?: string ; role: "assistant" ; tool_calls?: { function: { arguments: string ; name: string } ; id: string ; type: "function" }[] })[] ; tools?: string ; type: "chat" }

Returns

undefined | null | { content: string ; type: "completion" } | { messages: ({ content: string ; name?: string ; role: "system" } | { content: {} ; name?: string ; role: "user" } | { content: string ; role: "tool" ; tool_call_id: string } | { content: string ; name: string ; role: "function" } | { content?: null | string ; function_call?: { arguments: string ; name: string } ; name?: string ; role: "assistant" ; tool_calls?: { function: { arguments: string ; name: string } ; id: string ; type: "function" }[] })[] ; tools?: string ; type: "chat" }


slug

get slug(): string

Returns

string


version

get version(): string

Returns

string

Constructors

constructor

new Prompt(metadata, defaults, noTrace): Prompt

Parameters

NameType
metadataObject
metadata._xact_idstring
metadata.created?null | string
metadata.description?null | string
metadata.idstring
metadata.log_id"p"
metadata.metadata?null | Record<string, any>
metadata.namestring
metadata.org_idstring
metadata.project_idstring
metadata.prompt_data?null | { options?: null | { model?: string ; params?: { frequency_penalty?: number ; max_tokens?: number ; presence_penalty?: number ; response_format?: null | { type: "json_object" } ; temperature?: number ; tool_choice?: "auto" | "none" | { function: { name: string } ; type: "function" } ; top_p?: number ; use_cache?: boolean } | { max_tokens: number ; max_tokens_to_sample?: number ; temperature: number ; top_k?: number ; top_p?: number ; use_cache?: boolean } | { maxOutputTokens?: number ; temperature: number ; topK?: number ; topP?: number ; use_cache?: boolean } | { use_cache?: boolean } ; position?: string } ; origin?: null | { project_id?: string ; prompt_id?: string ; prompt_version?: string } ; prompt?: null | { content: string ; type: "completion" } | { messages: ({ content: string ; name?: string ; role: "system" } | { content: {} ; name?: string ; role: "user" } | { content: string ; role: "tool" ; tool_call_id: string } | { content: string ; name: string ; role: "function" } | { content?: null | string ; function_call?: { arguments: string ; name: string } ; name?: string ; role: "assistant" ; tool_calls?: { function: { arguments: string ; name: string } ; id: string ; type: "function" }[] })[] ; tools?: string ; type: "chat" } }
metadata.slugstring
metadata.tags?null | string[]
defaultsPartial<Omit<undefined | { frequency_penalty?: number ; max_tokens?: number ; presence_penalty?: number ; response_format?: null | { type: "json_object" } ; temperature?: number ; tool_choice?: "auto" | "none" | { function: { name: string } ; type: "function" } ; top_p?: number ; use_cache?: boolean } | { max_tokens: number ; max_tokens_to_sample?: number ; temperature: number ; top_k?: number ; top_p?: number ; use_cache?: boolean } | { maxOutputTokens?: number ; temperature: number ; topK?: number ; topP?: number ; use_cache?: boolean } | { use_cache?: boolean }, "use_cache"> & { model: string } & { frequency_penalty?: number ; maxOutputTokens?: number ; max_tokens: number ; max_tokens_to_sample?: number ; presence_penalty?: number ; response_format?: null | { type: "json_object" } ; temperature: number ; tool_choice?: "auto" | "none" | { function: { name: string } ; type: "function" } ; topK?: number ; topP?: number ; top_k?: number ; top_p?: number ; use_cache?: boolean } & ChatPrompt & CompletionPrompt>
noTraceboolean

Returns

Prompt

Methods

build

build<Flavor>(buildArgs, options?): CompiledPrompt<Flavor>

Build the prompt with the given formatting options. The args you pass in will be forwarded to the mustache template that defines the prompt and rendered with the mustache-js library.

Type parameters

NameType
Flavorextends "chat" | "completion" = "chat"

Parameters

NameTypeDescription
buildArgsRecord<string, unknown>Args to forward along to the prompt template.
optionsObject-
options.flavor?Flavor-

Returns

CompiledPrompt<Flavor>