AxPromptTemplate Generated TypeScript API reference. typescript api api/reference build/apidocs/Class.AxPromptTemplate.md class AxPromptTemplate

AxPromptTemplate

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/prompt.ts#L83

Constructors

Constructor

TypeScript
new AxPromptTemplate(
   sig: Readonly<AxSignature>, 
   options?: Readonly<AxPromptTemplateOptions>, 
   fieldTemplates?: Record<string, AxFieldTemplateFn>): AxPromptTemplate;

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/prompt.ts#L114

Parameters

ParameterType
sigReadonly<AxSignature>
options?Readonly<AxPromptTemplateOptions>
fieldTemplates?Record<string, AxFieldTemplateFn>

Returns

AxPromptTemplate

Methods

clearInstruction()

TypeScript
clearInstruction(): void;

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/prompt.ts#L102

Returns

void


getInstruction()

TypeScript
getInstruction(): undefined | string;

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/prompt.ts#L98

Returns

undefined | string


render()

TypeScript
render<T>(values: T, options: Readonly<{
  demos?: Record<string, AxFieldValue>[];
  examples?: Record<string, AxFieldValue>[];
  skipSystemPrompt?: boolean;
}>): (
  | {
  cache?: boolean;
  content: string;
  role: "system";
}
  | {
  cache?: boolean;
  content:   | string
     | (
     | {
     cache?: boolean;
     text: string;
     type: "text";
   }
     | {
     altText?: string;
     cache?: boolean;
     details?: "high" | "low" | "auto";
     image: string;
     mimeType: string;
     optimize?: "auto" | "quality" | "size";
     type: "image";
   }
     | {
     cache?: boolean;
     channels?: number;
     data: string;
     duration?: number;
     format?: AxAudioFormat;
     mimeType?: string;
     sampleRate?: number;
     transcription?: string;
     type: "audio";
   }
     | {
     cache?: boolean;
     data: string;
     extractedText?: string;
     filename?: string;
     mimeType: string;
     type: "file";
   }
     | {
     cache?: boolean;
     extractedText?: string;
     filename?: string;
     fileUri: string;
     mimeType: string;
     type: "file";
   }
     | {
     cache?: boolean;
     cachedContent?: string;
     description?: string;
     title?: string;
     type: "url";
     url: string;
   })[];
  name?: string;
  role: "user";
}
  | {
  audio?: {
     id: string;
     transcript?: string;
  };
  cache?: boolean;
  content?: string;
  functionCalls?: object[];
  name?: string;
  role: "assistant";
  thought?: string;
  thoughtBlocks?: AxThoughtBlockItem[];
}
  | {
  cache?: boolean;
  functionId: string;
  isError?: boolean;
  result: string;
  role: "function";
})[];

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/prompt.ts#L321

Type Parameters

Type ParameterDefault type
Tany

Parameters

ParameterType
valuesT
optionsReadonly<{ demos?: Record<string, AxFieldValue>[]; examples?: Record<string, AxFieldValue>[]; skipSystemPrompt?: boolean; }>

Returns


renderExtraFields()

TypeScript
renderExtraFields(extraFields: readonly AxIField[]): (
  | {
  cache?: boolean;
  text: string;
  type: "text";
}
  | {
  altText?: string;
  cache?: boolean;
  details?: "high" | "low" | "auto";
  image: string;
  mimeType: string;
  optimize?: "auto" | "quality" | "size";
  type: "image";
}
  | {
  cache?: boolean;
  channels?: number;
  data: string;
  duration?: number;
  format?: AxAudioFormat;
  mimeType?: string;
  sampleRate?: number;
  transcription?: string;
  type: "audio";
}
  | {
  cache?: boolean;
  data: string;
  extractedText?: string;
  filename?: string;
  mimeType: string;
  type: "file";
}
  | {
  cache?: boolean;
  extractedText?: string;
  filename?: string;
  fileUri: string;
  mimeType: string;
  type: "file";
}
  | {
  cache?: boolean;
  cachedContent?: string;
  description?: string;
  title?: string;
  type: "url";
  url: string;
})[];

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/prompt.ts#L558

Parameters

ParameterType
extraFieldsreadonly AxIField[]

Returns


renderWithMetrics()

TypeScript
renderWithMetrics<T>(values: T, options: Readonly<{
  demos?: Record<string, AxFieldValue>[];
  examples?: Record<string, AxFieldValue>[];
  skipSystemPrompt?: boolean;
}>): AxRenderedPrompt;

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/prompt.ts#L333

Type Parameters

Type ParameterDefault type
Tany

Parameters

ParameterType
valuesT
optionsReadonly<{ demos?: Record<string, AxFieldValue>[]; examples?: Record<string, AxFieldValue>[]; skipSystemPrompt?: boolean; }>

Returns

AxRenderedPrompt


setInstruction()

TypeScript
setInstruction(instruction: string): void;

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/src/ax/dsp/prompt.ts#L93

Parameters

ParameterType
instructionstring

Returns

void

Docs