PromptSection interface

A section that can be rendered to a prompt as either text or an array of Message objects.

Properties

required

If true the section is mandatory otherwise it can be safely dropped.

tokens

The requested token budget for this section.

  • Values between 0.0 and 1.0 represent a percentage of the total budget and the section will be layed out proportionally to all other sections.
  • Values greater than 1.0 represent the max number of tokens the section should be allowed to consume.

Methods

renderAsMessages(TurnContext, Memory, PromptFunctions, Tokenizer, number)

Renders the section as a list of messages.

renderAsText(TurnContext, Memory, PromptFunctions, Tokenizer, number)

Renders the section as a string of text.

Property Details

required

If true the section is mandatory otherwise it can be safely dropped.

required: boolean

Property Value

boolean

tokens

The requested token budget for this section.

  • Values between 0.0 and 1.0 represent a percentage of the total budget and the section will be layed out proportionally to all other sections.
  • Values greater than 1.0 represent the max number of tokens the section should be allowed to consume.
tokens: number

Property Value

number

Method Details

renderAsMessages(TurnContext, Memory, PromptFunctions, Tokenizer, number)

Renders the section as a list of messages.

function renderAsMessages(context: TurnContext, memory: Memory, functions: PromptFunctions, tokenizer: Tokenizer, maxTokens: number): Promise<RenderedPromptSection<Message<string>[]>>

Parameters

context

TurnContext

Context for the current turn of conversation with the user.

memory
Memory

An interface for accessing state values.

functions
PromptFunctions

Registry of functions that can be used by the section.

tokenizer
Tokenizer

Tokenizer to use when rendering the section.

maxTokens

number

Maximum number of tokens allowed to be rendered.

Returns

Promise<RenderedPromptSection<Message<string>[]>>

renderAsText(TurnContext, Memory, PromptFunctions, Tokenizer, number)

Renders the section as a string of text.

function renderAsText(context: TurnContext, memory: Memory, functions: PromptFunctions, tokenizer: Tokenizer, maxTokens: number): Promise<RenderedPromptSection<string>>

Parameters

context

TurnContext

Context for the current turn of conversation with the user.

memory
Memory

An interface for accessing state values.

functions
PromptFunctions

Registry of functions that can be used by the section.

tokenizer
Tokenizer

Tokenizer to use when rendering the section.

maxTokens

number

Maximum number of tokens allowed to be rendered.

Returns

Promise<RenderedPromptSection<string>>