Saltar al contenido principal

Class: OllamaEmbedding

OllamaEmbedding is an alias for Ollama that implements the BaseEmbedding interface.

Hierarchy

Implements

Constructors

constructor

new OllamaEmbedding(init): OllamaEmbedding

Parameters

NameType
initPartial<Ollama> & { model: string }

Returns

OllamaEmbedding

Inherited from

Ollama.constructor

Defined in

packages/core/src/llm/ollama.ts:40

Properties

additionalChatOptions

Optional additionalChatOptions: Record<string, unknown>

Inherited from

Ollama.additionalChatOptions

Defined in

packages/core/src/llm/ollama.ts:37


baseURL

baseURL: string = "http://127.0.0.1:11434"

Inherited from

Ollama.baseURL

Defined in

packages/core/src/llm/ollama.ts:32


callbackManager

Optional callbackManager: CallbackManager

Inherited from

Ollama.callbackManager

Defined in

packages/core/src/llm/ollama.ts:38


contextWindow

contextWindow: number = 4096

Inherited from

Ollama.contextWindow

Defined in

packages/core/src/llm/ollama.ts:35


embedBatchSize

embedBatchSize: number = DEFAULT_EMBED_BATCH_SIZE

Implementation of

BaseEmbedding.embedBatchSize

Inherited from

Ollama.embedBatchSize

Defined in

packages/core/src/embeddings/types.ts:8


hasStreaming

Readonly hasStreaming: true

Inherited from

Ollama.hasStreaming

Defined in

packages/core/src/llm/ollama.ts:28


model

model: string

Inherited from

Ollama.model

Defined in

packages/core/src/llm/ollama.ts:31


requestTimeout

requestTimeout: number

Inherited from

Ollama.requestTimeout

Defined in

packages/core/src/llm/ollama.ts:36


temperature

temperature: number = 0.7

Inherited from

Ollama.temperature

Defined in

packages/core/src/llm/ollama.ts:33


topP

topP: number = 0.9

Inherited from

Ollama.topP

Defined in

packages/core/src/llm/ollama.ts:34

Accessors

metadata

get metadata(): LLMMetadata

Returns

LLMMetadata

Inherited from

Ollama.metadata

Defined in

packages/core/src/llm/ollama.ts:51

Methods

chat

chat(params): Promise<AsyncIterable<ChatResponseChunk>>

Get a chat response from the LLM

Parameters

NameType
paramsLLMChatParamsStreaming

Returns

Promise<AsyncIterable<ChatResponseChunk>>

Inherited from

Ollama.chat

Defined in

packages/core/src/llm/ollama.ts:62

chat(params): Promise<ChatResponse>

Parameters

NameType
paramsLLMChatParamsNonStreaming

Returns

Promise<ChatResponse>

Inherited from

Ollama.chat

Defined in

packages/core/src/llm/ollama.ts:65


complete

complete(params): Promise<AsyncIterable<CompletionResponse>>

Get a prompt completion from the LLM

Parameters

NameType
paramsLLMCompletionParamsStreaming

Returns

Promise<AsyncIterable<CompletionResponse>>

Inherited from

Ollama.complete

Defined in

packages/core/src/llm/ollama.ts:138

complete(params): Promise<CompletionResponse>

Parameters

NameType
paramsLLMCompletionParamsNonStreaming

Returns

Promise<CompletionResponse>

Inherited from

Ollama.complete

Defined in

packages/core/src/llm/ollama.ts:141


getQueryEmbedding

getQueryEmbedding(query): Promise<number[]>

Parameters

NameType
querystring

Returns

Promise<number[]>

Implementation of

BaseEmbedding.getQueryEmbedding

Inherited from

Ollama.getQueryEmbedding

Defined in

packages/core/src/llm/ollama.ts:212


getTextEmbedding

getTextEmbedding(text): Promise<number[]>

Parameters

NameType
textstring

Returns

Promise<number[]>

Implementation of

BaseEmbedding.getTextEmbedding

Inherited from

Ollama.getTextEmbedding

Defined in

packages/core/src/llm/ollama.ts:208


getTextEmbeddings

getTextEmbeddings(texts): Promise<number[][]>

Optionally override this method to retrieve multiple embeddings in a single request

Parameters

NameType
textsstring[]

Returns

Promise<number[][]>

Implementation of

BaseEmbedding.getTextEmbeddings

Inherited from

Ollama.getTextEmbeddings

Defined in

packages/core/src/embeddings/types.ts:25


getTextEmbeddingsBatch

getTextEmbeddingsBatch(texts, options?): Promise<number[][]>

Get embeddings for a batch of texts

Parameters

NameType
textsstring[]
options?Object
options.logProgress?boolean

Returns

Promise<number[][]>

Implementation of

BaseEmbedding.getTextEmbeddingsBatch

Inherited from

Ollama.getTextEmbeddingsBatch

Defined in

packages/core/src/embeddings/types.ts:41


similarity

similarity(embedding1, embedding2, mode?): number

Parameters

NameTypeDefault value
embedding1number[]undefined
embedding2number[]undefined
modeSimilarityTypeSimilarityType.DEFAULT

Returns

number

Implementation of

BaseEmbedding.similarity

Inherited from

Ollama.similarity

Defined in

packages/core/src/embeddings/types.ts:10


tokens

tokens(messages): number

Calculates the number of tokens needed for the given chat messages

Parameters

NameType
messagesChatMessage[]

Returns

number

Inherited from

Ollama.tokens

Defined in

packages/core/src/llm/ollama.ts:181


transform

transform(nodes, _options?): Promise<BaseNode<Metadata>[]>

Parameters

NameType
nodesBaseNode<Metadata>[]
_options?any

Returns

Promise<BaseNode<Metadata>[]>

Implementation of

BaseEmbedding.transform

Inherited from

Ollama.transform

Defined in

packages/core/src/embeddings/types.ts:72