Class: Prompt
Accessors
id
• get
id(): string
Returns
string
name
• get
name(): string
Returns
string
options
• get
options(): Object
Returns
Object
Name | Type |
---|---|
model? | string |
params? | objectOutputType <{ frequency_penalty : ZodOptional <ZodNumber > ; function_call : ZodOptional <ZodUnion <[ZodLiteral <"auto" >, ZodLiteral <"none" >, ZodObject <{ name : ZodString }, "strict" , 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" > }, "strict" , 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(): 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"
}[] } | { 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(): string
Returns
string
Constructors
constructor
• new Prompt(metadata
, defaults
, noTrace
): Prompt
Parameters
Name | Type |
---|---|
metadata | Omit <{ _xact_id : string ; created? : null | string ; description? : null | string ; id : string ; log_id : "p" ; metadata? : null | Record <string , any > ; name : string ; org_id : string ; project_id : string ; prompt_data? : null | { options? : null | { model? : string ; params? : objectOutputType <{ frequency_penalty : ZodOptional <ZodNumber > ; function_call : ZodOptional <ZodUnion <[ZodLiteral <"auto" >, ZodLiteral <"none" >, ZodObject <{ name : ZodString }, "strict" , 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" > }, "strict" , 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 } ; 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" }[] } | { content? : null | string ; role : "model" })[] ; tools? : string ; type : "chat" } } ; slug : string ; tags? : null | string [] }, "log_id" > | { _xact_id : string ; completion? : any ; created : string ; id : string ; object_data? : any ; project_id : string ; prompt_data? : any ; prompt_session_data? : any ; prompt_session_id : string ; tags? : null | string [] } |
defaults | Partial <Omit <undefined | objectOutputType <{ frequency_penalty : ZodOptional <ZodNumber > ; function_call : ZodOptional <ZodUnion <[ZodLiteral <"auto" >, ZodLiteral <"none" >, ZodObject <{ name : ZodString }, "strict" , 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" > }, "strict" , 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? : "none" | "auto" | { 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? : "none" | "auto" | { function : { name : string } ; type : "function" } ; topK? : number ; topP? : number ; top_k? : number ; top_p? : number ; use_cache? : boolean } & ChatPrompt & CompletionPrompt > |
noTrace | boolean |
Returns
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
Name | Type |
---|---|
Flavor | extends "chat" | "completion" = "chat" |
Parameters
Name | Type | Description |
---|---|---|
buildArgs | unknown | Args to forward along to the prompt template. |
options | Object | - |
options.flavor? | Flavor | - |
Returns
CompiledPrompt
<Flavor
>