Reference/SDK/TypeScript/Classes

Class: Prompt<HasId, HasVersion>

Type parameters

NameType
HasIdextends boolean = true
HasVersionextends boolean = true

Accessors

id

get id(): HasId extends true ? string : undefined | string

Returns

HasId extends true ? string : undefined | string


name

get name(): string

Returns

string


options

get options(): Object

Returns

Object

NameType
model?string
params?objectOutputType<{ frequency_penalty: ZodOptional<ZodNumber> ; function_call: ZodOptional<ZodUnion<[ZodLiteral<"auto">, ZodLiteral<"none">, ZodObject<{ name: ZodString }, "strip", ZodTypeAny, { name: string }, { name: string }>]>> ; max_tokens: ZodOptional<ZodNumber> ; n: ZodOptional<ZodNumber> ; presence_penalty: ZodOptional<ZodNumber> ; response_format: ZodOptional<ZodNullable<ZodObject<{ type: ZodLiteral<"json_object"> }, "strip", ZodTypeAny, { type: "json_object" }, { type: "json_object" }>>> ; stop: ZodOptional<ZodArray<ZodString, "many">> ; temperature: ZodOptional<ZodNumber> ; tool_choice: ZodOptional<ZodUnion<[ZodLiteral<"auto">, ZodLiteral<"none">, ZodObject<{ function: ZodObject<{ name: ZodString }, "strip", ZodTypeAny, { name: string }, { name: string }> ; type: ZodLiteral<"function"> }, "strip", ZodTypeAny, { function: { name: string } ; type: "function" }, { function: { name: string } ; type: "function" }>]>> ; top_p: ZodOptional<ZodNumber> ; use_cache: ZodOptional<ZodBoolean> }, ZodTypeAny, "passthrough"> | objectOutputType<{ max_tokens: ZodNumber ; max_tokens_to_sample: ZodOptional<ZodNumber> ; stop_sequences: ZodOptional<ZodArray<ZodString, "many">> ; temperature: ZodNumber ; top_k: ZodOptional<ZodNumber> ; top_p: ZodOptional<ZodNumber> ; use_cache: ZodOptional<ZodBoolean> }, ZodTypeAny, "passthrough"> | objectOutputType<{ maxOutputTokens: ZodOptional<ZodNumber> ; temperature: ZodOptional<ZodNumber> ; topK: ZodOptional<ZodNumber> ; topP: ZodOptional<ZodNumber> ; use_cache: ZodOptional<ZodBoolean> }, ZodTypeAny, "passthrough"> | objectOutputType<{ temperature: ZodOptional<ZodNumber> ; topK: ZodOptional<ZodNumber> ; use_cache: ZodOptional<ZodBoolean> }, ZodTypeAny, "passthrough"> | objectOutputType<{ use_cache: ZodOptional<ZodBoolean> }, ZodTypeAny, "passthrough">
position?string

projectId

get projectId(): undefined | string

Returns

undefined | 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" }[] } | { content?: null | string ; role: "model" })[] ; 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" }[] } | { content?: null | string ; role: "model" })[] ; tools?: string ; type: "chat" }


slug

get slug(): string

Returns

string


version

get version(): HasId extends true ? string : undefined | string

Returns

HasId extends true ? string : undefined | string

Constructors

constructor

new Prompt<HasId, HasVersion>(metadata, defaults, noTrace): Prompt<HasId, HasVersion>

Type parameters

NameType
HasIdextends boolean = true
HasVersionextends boolean = true

Parameters

NameType
metadataPromptRowWithId<HasId, HasVersion> | { _xact_id: string ; completion?: unknown ; created: string ; id: string ; object_data?: unknown ; project_id: string ; prompt_data?: unknown ; prompt_session_data?: unknown ; prompt_session_id: string ; tags?: null | string[] }
defaultsPartial<Omit<undefined | objectOutputType<{ frequency_penalty: ZodOptional<ZodNumber> ; function_call: ZodOptional<ZodUnion<[ZodLiteral<"auto">, ZodLiteral<"none">, ZodObject<{ name: ZodString }, "strip", ZodTypeAny, { name: string }, { name: string }>]>> ; max_tokens: ZodOptional<ZodNumber> ; n: ZodOptional<ZodNumber> ; presence_penalty: ZodOptional<ZodNumber> ; response_format: ZodOptional<ZodNullable<ZodObject<{ type: ZodLiteral<"json_object"> }, "strip", ZodTypeAny, { type: "json_object" }, { type: "json_object" }>>> ; stop: ZodOptional<ZodArray<ZodString, "many">> ; temperature: ZodOptional<ZodNumber> ; tool_choice: ZodOptional<ZodUnion<[ZodLiteral<"auto">, ZodLiteral<"none">, ZodObject<{ function: ZodObject<{ name: ZodString }, "strip", ZodTypeAny, { name: string }, { name: string }> ; type: ZodLiteral<"function"> }, "strip", ZodTypeAny, { function: { name: string } ; type: "function" }, { function: { name: string } ; type: "function" }>]>> ; top_p: ZodOptional<ZodNumber> ; use_cache: ZodOptional<ZodBoolean> }, ZodTypeAny, "passthrough"> | objectOutputType<{ max_tokens: ZodNumber ; max_tokens_to_sample: ZodOptional<ZodNumber> ; stop_sequences: ZodOptional<ZodArray<ZodString, "many">> ; temperature: ZodNumber ; top_k: ZodOptional<ZodNumber> ; top_p: ZodOptional<ZodNumber> ; use_cache: ZodOptional<ZodBoolean> }, ZodTypeAny, "passthrough"> | objectOutputType<{ maxOutputTokens: ZodOptional<ZodNumber> ; temperature: ZodOptional<ZodNumber> ; topK: ZodOptional<ZodNumber> ; topP: ZodOptional<ZodNumber> ; use_cache: ZodOptional<ZodBoolean> }, ZodTypeAny, "passthrough"> | objectOutputType<{ temperature: ZodOptional<ZodNumber> ; topK: ZodOptional<ZodNumber> ; use_cache: ZodOptional<ZodBoolean> }, ZodTypeAny, "passthrough"> | objectOutputType<{ use_cache: ZodOptional<ZodBoolean> }, ZodTypeAny, "passthrough">, "use_cache"> & { model: string } & { frequency_penalty?: number ; function_call?: "auto" | "none" | { name: string } ; maxOutputTokens?: number ; max_tokens: number ; max_tokens_to_sample?: number ; n?: number ; presence_penalty?: number ; response_format?: null | { type: "json_object" } ; stop?: string[] ; stop_sequences?: string[] ; 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<HasId, HasVersion>

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 "completion" | "chat" = "chat"

Parameters

NameTypeDescription
buildArgsunknownArgs to forward along to the prompt template.
optionsObject-
options.flavor?Flavor-
options.messages?({ content: string ; name?: string ; role: "system" } | { content: {} ; name?: string ; role: "user" } | { content?: null | string ; function_call?: { arguments: string ; name: string } ; name?: string ; role: "assistant" ; tool_calls?: { function: { arguments: string ; name: string } ; id: string ; type: "function" }[] } | { content: string ; role: "tool" ; tool_call_id: string } | { content: string ; name: string ; role: "function" } | { content?: null | string ; role: "model" })[]-

Returns

CompiledPrompt<Flavor>

On this page