Skip to main content

Class: OpenAICompatibleTextEmbeddingModel

Abstract text embedding model that calls an API that is compatible with the OpenAI embedding API.

See

https://platform.openai.com/docs/api-reference/embeddings

Hierarchy

Implements

Accessors

dimensions

get dimensions(): undefined | number

The size of the embedding vector.

Returns

undefined | number

Implementation of

EmbeddingModel.dimensions

Defined in

packages/modelfusion/src/model-provider/openai-compatible/OpenAICompatibleTextEmbeddingModel.ts:37


maxValuesPerCall

get maxValuesPerCall(): number

Limit of how many values can be sent in a single API call.

Returns

number

Implementation of

EmbeddingModel.maxValuesPerCall

Inherited from

AbstractOpenAITextEmbeddingModel.maxValuesPerCall

Defined in

packages/modelfusion/src/model-provider/openai/AbstractOpenAITextEmbeddingModel.ts:38


modelInformation

get modelInformation(): ModelInformation

Returns

ModelInformation

Implementation of

EmbeddingModel.modelInformation

Inherited from

AbstractOpenAITextEmbeddingModel.modelInformation

Defined in

packages/modelfusion/src/model-function/AbstractModel.ts:17


modelName

get modelName(): string

Returns

string

Overrides

AbstractOpenAITextEmbeddingModel.modelName

Defined in

packages/modelfusion/src/model-provider/openai-compatible/OpenAICompatibleTextEmbeddingModel.ts:33


provider

get provider(): OpenAICompatibleProviderName

Returns

OpenAICompatibleProviderName

Overrides

AbstractOpenAITextEmbeddingModel.provider

Defined in

packages/modelfusion/src/model-provider/openai-compatible/OpenAICompatibleTextEmbeddingModel.ts:27


settingsForEvent

get settingsForEvent(): Partial<OpenAICompatibleTextEmbeddingModelSettings>

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

Returns

Partial<OpenAICompatibleTextEmbeddingModelSettings>

Implementation of

EmbeddingModel.settingsForEvent

Overrides

AbstractOpenAITextEmbeddingModel.settingsForEvent

Defined in

packages/modelfusion/src/model-provider/openai-compatible/OpenAICompatibleTextEmbeddingModel.ts:41

Constructors

constructor

new OpenAICompatibleTextEmbeddingModel(settings): OpenAICompatibleTextEmbeddingModel

Parameters

NameType
settingsOpenAICompatibleTextEmbeddingModelSettings

Returns

OpenAICompatibleTextEmbeddingModel

Overrides

AbstractOpenAITextEmbeddingModel.constructor

Defined in

packages/modelfusion/src/model-provider/openai-compatible/OpenAICompatibleTextEmbeddingModel.ts:23

Methods

callAPI

callAPI(texts, callOptions): Promise<{ data: { embedding: number[] ; index: number ; object: "embedding" }[] ; model: string ; object: "list" ; usage?: { prompt_tokens: number ; total_tokens: number } }>

Parameters

NameType
textsstring[]
callOptionsFunctionCallOptions

Returns

Promise<{ data: { embedding: number[] ; index: number ; object: "embedding" }[] ; model: string ; object: "list" ; usage?: { prompt_tokens: number ; total_tokens: number } }>

Inherited from

AbstractOpenAITextEmbeddingModel.callAPI

Defined in

packages/modelfusion/src/model-provider/openai/AbstractOpenAITextEmbeddingModel.ts:44


doEmbedValues

doEmbedValues(texts, callOptions): Promise<{ embeddings: number[][] ; rawResponse: { data: { embedding: number[] ; index: number ; object: "embedding" }[] ; model: string ; object: "list" ; usage?: { prompt_tokens: number ; total_tokens: number } } }>

Parameters

NameType
textsstring[]
callOptionsFunctionCallOptions

Returns

Promise<{ embeddings: number[][] ; rawResponse: { data: { embedding: number[] ; index: number ; object: "embedding" }[] ; model: string ; object: "list" ; usage?: { prompt_tokens: number ; total_tokens: number } } }>

Implementation of

EmbeddingModel.doEmbedValues

Inherited from

AbstractOpenAITextEmbeddingModel.doEmbedValues

Defined in

packages/modelfusion/src/model-provider/openai/AbstractOpenAITextEmbeddingModel.ts:80


withSettings

withSettings(additionalSettings): OpenAICompatibleTextEmbeddingModel

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

Parameters

NameType
additionalSettingsOpenAICompatibleTextEmbeddingModelSettings

Returns

OpenAICompatibleTextEmbeddingModel

Example

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

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

Implementation of

EmbeddingModel.withSettings

Overrides

AbstractOpenAITextEmbeddingModel.withSettings

Defined in

packages/modelfusion/src/model-provider/openai-compatible/OpenAICompatibleTextEmbeddingModel.ts:47

Properties

isParallelizable

Readonly isParallelizable: true

True if the model can handle multiple embedding calls in parallel.

Implementation of

EmbeddingModel.isParallelizable

Inherited from

AbstractOpenAITextEmbeddingModel.isParallelizable

Defined in

packages/modelfusion/src/model-provider/openai/AbstractOpenAITextEmbeddingModel.ts:42


settings

Readonly settings: OpenAICompatibleTextEmbeddingModelSettings

Implementation of

EmbeddingModel.settings

Inherited from

AbstractOpenAITextEmbeddingModel.settings

Defined in

packages/modelfusion/src/model-function/AbstractModel.ts:7