Pular para o conteúdo principal

Class: Ollama

Unified language model interface

Hierarchy

Implements

Constructors

constructor

new Ollama(init): Ollama

Parameters

NameType
initPartial<Ollama> & { model: string ; modelMetadata?: Partial<LLMMetadata> }

Returns

Ollama

Overrides

BaseEmbedding.constructor

Defined in

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

Properties

additionalChatOptions

Optional additionalChatOptions: Record<string, unknown>

Defined in

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


baseURL

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

Defined in

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


contextWindow

contextWindow: number = 4096

Defined in

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


embedBatchSize

embedBatchSize: number = DEFAULT_EMBED_BATCH_SIZE

Inherited from

BaseEmbedding.embedBatchSize

Defined in

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


hasStreaming

Readonly hasStreaming: true

Defined in

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


model

model: string

Defined in

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


modelMetadata

Protected modelMetadata: Partial<LLMMetadata>

Defined in

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


requestTimeout

requestTimeout: number

Defined in

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


temperature

temperature: number = 0.7

Defined in

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


topP

topP: number = 0.9

Defined in

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

Accessors

metadata

get metadata(): LLMMetadata

Returns

LLMMetadata

Implementation of

LLM.metadata

Defined in

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

Methods

chat

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

Get a chat response from the LLM

Parameters

NameType
paramsLLMChatParamsStreaming

Returns

Promise<AsyncIterable<ChatResponseChunk>>

Implementation of

LLM.chat

Defined in

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

chat(params): Promise<ChatResponse>

Parameters

NameType
paramsLLMChatParamsNonStreaming

Returns

Promise<ChatResponse>

Implementation of

LLM.chat

Defined in

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


complete

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

Get a prompt completion from the LLM

Parameters

NameType
paramsLLMCompletionParamsStreaming

Returns

Promise<AsyncIterable<CompletionResponse>>

Implementation of

LLM.complete

Defined in

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

complete(params): Promise<CompletionResponse>

Parameters

NameType
paramsLLMCompletionParamsNonStreaming

Returns

Promise<CompletionResponse>

Implementation of

LLM.complete

Defined in

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


getEmbedding

getEmbedding(prompt): Promise<number[]>

Parameters

NameType
promptstring

Returns

Promise<number[]>

Defined in

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


getQueryEmbedding

getQueryEmbedding(query): Promise<number[]>

Parameters

NameType
querystring

Returns

Promise<number[]>

Overrides

BaseEmbedding.getQueryEmbedding

Defined in

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


getTextEmbedding

getTextEmbedding(text): Promise<number[]>

Parameters

NameType
textstring

Returns

Promise<number[]>

Overrides

BaseEmbedding.getTextEmbedding

Defined in

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


getTextEmbeddings

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

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

Parameters

NameType
textsstring[]

Returns

Promise<number[][]>

Inherited from

BaseEmbedding.getTextEmbeddings

Defined in

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


getTextEmbeddingsBatch

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

Get embeddings for a batch of texts

Parameters

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

Returns

Promise<number[][]>

Inherited from

BaseEmbedding.getTextEmbeddingsBatch

Defined in

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


similarity

similarity(embedding1, embedding2, mode?): number

Parameters

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

Returns

number

Inherited from

BaseEmbedding.similarity

Defined in

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


streamChat

streamChat<T>(stream, accessor): AsyncIterable<T>

Type parameters

Name
T

Parameters

NameType
streamReadableStream<Uint8Array>
accessor(data: any) => T

Returns

AsyncIterable<T>

Defined in

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


transform

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

Parameters

NameType
nodesBaseNode<Metadata>[]
_options?any

Returns

Promise<BaseNode<Metadata>[]>

Inherited from

BaseEmbedding.transform

Defined in

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