thread_helpers.ts

Declarations
#

3 declarations

view source

render_completion_messages
#

thread_helpers.ts view source

(turns: Iterable<Turn>, completion_messages?: { [x: string]: unknown; role: string; content: string; }[]): { [x: string]: unknown; role: string; content: string; }[]

Creates a thread history array for model consumption from a collection of turns. Normalizes content for assistant turns with responses.

turns

type Iterable<Turn>

completion_messages

type { [x: string]: unknown; role: string; content: string; }[]
default []

returns

{ [x: string]: unknown; role: string; content: string; }[]

render_message_with_role
#

thread_helpers.ts view source

(role: string, content: string, tag?: string): string

Renders a single message with an XML tag that includes the role attribute.

role

type string

content

type string

tag

type string
default 'message'

returns

string

render_messages_to_string
#

thread_helpers.ts view source

(turns: Iterable<{ role: string; content: string; enabled?: boolean | undefined; }>, tag?: string): string

turns

type Iterable<{ role: string; content: string; enabled?: boolean | undefined; }>

tag

type string
default 'message'

returns

string

Depends on
#

Imported by
#