Skip to main content

Class: PromptTemplateFullTextModel<PROMPT, MODEL_PROMPT, SETTINGS, MODEL>

Type parameters

NameType
PROMPTPROMPT
MODEL_PROMPTMODEL_PROMPT
SETTINGSextends TextGenerationModelSettings
MODELextends TextStreamingModel<MODEL_PROMPT, SETTINGS> & ToolCallGenerationModel<MODEL_PROMPT, SETTINGS> & ToolCallsGenerationModel<MODEL_PROMPT, SETTINGS>

Hierarchy

Implements

Accessors

contextWindowSize

get contextWindowSize(): MODEL["contextWindowSize"]

Returns

MODEL["contextWindowSize"]

Implementation of

TextStreamingModel.contextWindowSize

Inherited from

PromptTemplateTextStreamingModel.contextWindowSize

Defined in

packages/modelfusion/src/model-function/generate-text/PromptTemplateTextGenerationModel.ts:49


countPromptTokens

get countPromptTokens(): MODEL["countPromptTokens"] extends undefined ? undefined : (prompt: PROMPT) => PromiseLike<number>

Optional. Implement if you have a tokenizer and want to count the number of tokens in a prompt.

Returns

MODEL["countPromptTokens"] extends undefined ? undefined : (prompt: PROMPT) => PromiseLike<number>

Implementation of

TextStreamingModel.countPromptTokens

Inherited from

PromptTemplateTextStreamingModel.countPromptTokens

Defined in

packages/modelfusion/src/model-function/generate-text/PromptTemplateTextGenerationModel.ts:53


modelInformation

get modelInformation(): ModelInformation

Returns

ModelInformation

Implementation of

ToolCallsGenerationModel.modelInformation

Inherited from

PromptTemplateTextStreamingModel.modelInformation

Defined in

packages/modelfusion/src/model-function/generate-text/PromptTemplateTextGenerationModel.ts:37


settings

get settings(): SETTINGS

Returns

SETTINGS

Implementation of

ToolCallsGenerationModel.settings

Inherited from

PromptTemplateTextStreamingModel.settings

Defined in

packages/modelfusion/src/model-function/generate-text/PromptTemplateTextGenerationModel.ts:41


settingsForEvent

get settingsForEvent(): Partial<SETTINGS>

Returns settings that should be recorded in observability events. Security-related settings (e.g. API keys) should not be included here.

Returns

Partial<SETTINGS>

Implementation of

TextStreamingModel.settingsForEvent

Inherited from

PromptTemplateTextStreamingModel.settingsForEvent

Defined in

packages/modelfusion/src/model-function/generate-text/PromptTemplateTextGenerationModel.ts:83


tokenizer

get tokenizer(): MODEL["tokenizer"]

Returns

MODEL["tokenizer"]

Implementation of

TextStreamingModel.tokenizer

Inherited from

PromptTemplateTextStreamingModel.tokenizer

Defined in

packages/modelfusion/src/model-function/generate-text/PromptTemplateTextGenerationModel.ts:45

Constructors

constructor

new PromptTemplateFullTextModel<PROMPT, MODEL_PROMPT, SETTINGS, MODEL>(options): PromptTemplateFullTextModel<PROMPT, MODEL_PROMPT, SETTINGS, MODEL>

Type parameters

NameType
PROMPTPROMPT
MODEL_PROMPTMODEL_PROMPT
SETTINGSextends TextGenerationModelSettings
MODELextends TextStreamingModel<MODEL_PROMPT, SETTINGS> & ToolCallGenerationModel<MODEL_PROMPT, SETTINGS> & ToolCallsGenerationModel<MODEL_PROMPT, SETTINGS>

Parameters

NameType
optionsObject
options.modelMODEL
options.promptTemplateTextGenerationPromptTemplate<PROMPT, MODEL_PROMPT>

Returns

PromptTemplateFullTextModel<PROMPT, MODEL_PROMPT, SETTINGS, MODEL>

Overrides

PromptTemplateTextStreamingModel.constructor

Defined in

packages/modelfusion/src/model-function/generate-text/PromptTemplateFullTextModel.ts:31

Methods

asObjectGenerationModel

asObjectGenerationModel<INPUT_PROMPT>(promptTemplate): ObjectFromTextStreamingModel<INPUT_PROMPT, PROMPT, PromptTemplateFullTextModel<PROMPT, MODEL_PROMPT, SETTINGS, MODEL>>

Type parameters

Name
INPUT_PROMPT

Parameters

NameType
promptTemplateObjectFromTextPromptTemplate<INPUT_PROMPT, PROMPT>

Returns

ObjectFromTextStreamingModel<INPUT_PROMPT, PROMPT, PromptTemplateFullTextModel<PROMPT, MODEL_PROMPT, SETTINGS, MODEL>>

Inherited from

PromptTemplateTextStreamingModel.asObjectGenerationModel

Defined in

packages/modelfusion/src/model-function/generate-text/PromptTemplateTextStreamingModel.ts:43


asToolCallGenerationModel

asToolCallGenerationModel<INPUT_PROMPT>(promptTemplate): TextGenerationToolCallModel<INPUT_PROMPT, PROMPT, PromptTemplateFullTextModel<PROMPT, MODEL_PROMPT, SETTINGS, MODEL>>

Type parameters

Name
INPUT_PROMPT

Parameters

NameType
promptTemplateToolCallPromptTemplate<INPUT_PROMPT, PROMPT>

Returns

TextGenerationToolCallModel<INPUT_PROMPT, PROMPT, PromptTemplateFullTextModel<PROMPT, MODEL_PROMPT, SETTINGS, MODEL>>

Inherited from

PromptTemplateTextStreamingModel.asToolCallGenerationModel

Defined in

packages/modelfusion/src/model-function/generate-text/PromptTemplateTextGenerationModel.ts:87


asToolCallsOrTextGenerationModel

asToolCallsOrTextGenerationModel<INPUT_PROMPT>(promptTemplate): TextGenerationToolCallsModel<INPUT_PROMPT, PROMPT, PromptTemplateFullTextModel<PROMPT, MODEL_PROMPT, SETTINGS, MODEL>>

Type parameters

Name
INPUT_PROMPT

Parameters

NameType
promptTemplateToolCallsPromptTemplate<INPUT_PROMPT, PROMPT>

Returns

TextGenerationToolCallsModel<INPUT_PROMPT, PROMPT, PromptTemplateFullTextModel<PROMPT, MODEL_PROMPT, SETTINGS, MODEL>>

Inherited from

PromptTemplateTextStreamingModel.asToolCallsOrTextGenerationModel

Defined in

packages/modelfusion/src/model-function/generate-text/PromptTemplateTextGenerationModel.ts:96


doGenerateTexts

doGenerateTexts(prompt, options?): PromiseLike<{ rawResponse: unknown ; textGenerationResults: TextGenerationResult[] ; usage?: { completionTokens: number ; promptTokens: number ; totalTokens: number } }>

Parameters

NameType
promptPROMPT
options?FunctionCallOptions

Returns

PromiseLike<{ rawResponse: unknown ; textGenerationResults: TextGenerationResult[] ; usage?: { completionTokens: number ; promptTokens: number ; totalTokens: number } }>

Implementation of

TextStreamingModel.doGenerateTexts

Inherited from

PromptTemplateTextStreamingModel.doGenerateTexts

Defined in

packages/modelfusion/src/model-function/generate-text/PromptTemplateTextGenerationModel.ts:74


doGenerateToolCall

doGenerateToolCall(tool, prompt, options?): PromiseLike<{ rawResponse: unknown ; toolCall: null | { args: unknown ; id: string } ; usage?: { completionTokens: number ; promptTokens: number ; totalTokens: number } }>

Parameters

NameType
toolToolDefinition<string, unknown>
promptPROMPT
options?FunctionOptions

Returns

PromiseLike<{ rawResponse: unknown ; toolCall: null | { args: unknown ; id: string } ; usage?: { completionTokens: number ; promptTokens: number ; totalTokens: number } }>

Implementation of

ToolCallGenerationModel.doGenerateToolCall

Defined in

packages/modelfusion/src/model-function/generate-text/PromptTemplateFullTextModel.ts:38


doGenerateToolCalls

doGenerateToolCalls(tools, prompt, options?): PromiseLike<{ rawResponse: unknown ; text: null | string ; toolCalls: null | { args: unknown ; id: string ; name: string }[] ; usage?: { completionTokens: number ; promptTokens: number ; totalTokens: number } }>

Parameters

NameType
toolsToolDefinition<string, unknown>[]
promptPROMPT
options?FunctionOptions

Returns

PromiseLike<{ rawResponse: unknown ; text: null | string ; toolCalls: null | { args: unknown ; id: string ; name: string }[] ; usage?: { completionTokens: number ; promptTokens: number ; totalTokens: number } }>

Implementation of

ToolCallsGenerationModel.doGenerateToolCalls

Defined in

packages/modelfusion/src/model-function/generate-text/PromptTemplateFullTextModel.ts:53


doStreamText

doStreamText(prompt, options?): PromiseLike<AsyncIterable<Delta<unknown>>>

Parameters

NameType
promptPROMPT
options?FunctionCallOptions

Returns

PromiseLike<AsyncIterable<Delta<unknown>>>

Implementation of

TextStreamingModel.doStreamText

Inherited from

PromptTemplateTextStreamingModel.doStreamText

Defined in

packages/modelfusion/src/model-function/generate-text/PromptTemplateTextStreamingModel.ts:34


extractTextDelta

extractTextDelta(delta): undefined | string

Parameters

NameType
deltaunknown

Returns

undefined | string

Implementation of

TextStreamingModel.extractTextDelta

Inherited from

PromptTemplateTextStreamingModel.extractTextDelta

Defined in

packages/modelfusion/src/model-function/generate-text/PromptTemplateTextStreamingModel.ts:39


restoreGeneratedTexts

restoreGeneratedTexts(rawResponse): Object

Parameters

NameType
rawResponseunknown

Returns

Object

NameType
rawResponseunknown
textGenerationResultsTextGenerationResult[]
usage?{ completionTokens: number ; promptTokens: number ; totalTokens: number }
usage.completionTokensnumber
usage.promptTokensnumber
usage.totalTokensnumber

Implementation of

TextStreamingModel.restoreGeneratedTexts

Inherited from

PromptTemplateTextStreamingModel.restoreGeneratedTexts

Defined in

packages/modelfusion/src/model-function/generate-text/PromptTemplateTextGenerationModel.ts:79


withJsonOutput

withJsonOutput(schema): this

When possible, limit the output generation to the specified JSON schema, or super sets of it (e.g. JSON in general).

Parameters

NameType
schemaSchema<unknown> & JsonSchemaProducer

Returns

this

Implementation of

TextStreamingModel.withJsonOutput

Inherited from

PromptTemplateTextStreamingModel.withJsonOutput

Defined in

packages/modelfusion/src/model-function/generate-text/PromptTemplateTextStreamingModel.ts:52


withSettings

withSettings(additionalSettings): this

The withSettings method creates a new model with the same configuration as the original model, but with the specified settings changed.

Parameters

NameType
additionalSettingsPartial<SETTINGS>

Returns

this

Example

const model = new OpenAICompletionModel({
model: "gpt-3.5-turbo-instruct",
maxGenerationTokens: 500,
});

const modelWithMoreTokens = model.withSettings({
maxGenerationTokens: 1000,
});

Implementation of

ToolCallsGenerationModel.withSettings

Overrides

PromptTemplateTextStreamingModel.withSettings

Defined in

packages/modelfusion/src/model-function/generate-text/PromptTemplateFullTextModel.ts:69

Properties

model

Readonly model: MODEL

Inherited from

PromptTemplateTextStreamingModel.model

Defined in

packages/modelfusion/src/model-function/generate-text/PromptTemplateTextGenerationModel.ts:23


promptTemplate

Readonly promptTemplate: TextGenerationPromptTemplate<PROMPT, MODEL_PROMPT>

Inherited from

PromptTemplateTextStreamingModel.promptTemplate

Defined in

packages/modelfusion/src/model-function/generate-text/PromptTemplateTextGenerationModel.ts:24