Ana içeriğe geç

Class: Anthropic

Anthropic LLM implementation

Implements

Constructors

constructor

new Anthropic(init?)

Parameters

NameType
init?Partial<Anthropic>

Defined in

packages/core/src/llm/LLM.ts:669

Properties

apiKey

Optional apiKey: string = undefined

Defined in

packages/core/src/llm/LLM.ts:662


callbackManager

Optional callbackManager: CallbackManager

Defined in

packages/core/src/llm/LLM.ts:667


hasStreaming

hasStreaming: boolean = true

Implementation of

LLM.hasStreaming

Defined in

packages/core/src/llm/LLM.ts:653


maxRetries

maxRetries: number

Defined in

packages/core/src/llm/LLM.ts:663


maxTokens

Optional maxTokens: number

Defined in

packages/core/src/llm/LLM.ts:659


model

model: "claude-2" | "claude-instant-1"

Defined in

packages/core/src/llm/LLM.ts:656


session

session: AnthropicSession

Defined in

packages/core/src/llm/LLM.ts:665


temperature

temperature: number

Defined in

packages/core/src/llm/LLM.ts:657


timeout

Optional timeout: number

Defined in

packages/core/src/llm/LLM.ts:664


topP

topP: number

Defined in

packages/core/src/llm/LLM.ts:658

Accessors

metadata

get metadata(): Object

Returns

Object

NameType
contextWindownumber
maxTokensundefined | number
model"claude-2" | "claude-instant-1"
temperaturenumber
tokenizerundefined
topPnumber

Implementation of

LLM.metadata

Defined in

packages/core/src/llm/LLM.ts:693

Methods

chat

chat<T, R>(messages, parentEvent?, streaming?): Promise<R>

Get a chat response from the LLM

Type parameters

NameType
Textends undefined | boolean = undefined
RT extends true ? AsyncGenerator<string, void, unknown> : ChatResponse

Parameters

NameTypeDescription
messagesChatMessage[]The return type of chat() and complete() are set by the "streaming" parameter being set to True.
parentEvent?Event-
streaming?T-

Returns

Promise<R>

Implementation of

LLM.chat

Defined in

packages/core/src/llm/LLM.ts:721


complete

complete<T, R>(prompt, parentEvent?, streaming?): Promise<R>

Get a prompt completion from the LLM

Type parameters

NameType
Textends undefined | boolean = undefined
RT extends true ? AsyncGenerator<string, void, unknown> : ChatResponse

Parameters

NameTypeDescription
promptstringthe prompt to complete
parentEvent?Event-
streaming?T-

Returns

Promise<R>

Implementation of

LLM.complete

Defined in

packages/core/src/llm/LLM.ts:778


mapMessagesToPrompt

mapMessagesToPrompt(messages): string

Parameters

NameType
messagesChatMessage[]

Returns

string

Defined in

packages/core/src/llm/LLM.ts:704


streamChat

Protected streamChat(messages, parentEvent?): AsyncGenerator<string, void, unknown>

Parameters

NameType
messagesChatMessage[]
parentEvent?Event

Returns

AsyncGenerator<string, void, unknown>

Defined in

packages/core/src/llm/LLM.ts:753


streamComplete

Protected streamComplete(prompt, parentEvent?): AsyncGenerator<string, void, unknown>

Parameters

NameType
promptstring
parentEvent?Event

Returns

AsyncGenerator<string, void, unknown>

Defined in

packages/core/src/llm/LLM.ts:796


tokens

tokens(messages): number

Calculates the number of tokens needed for the given chat messages

Parameters

NameType
messagesChatMessage[]

Returns

number

Implementation of

LLM.tokens

Defined in

packages/core/src/llm/LLM.ts:689