Skip to main content

Class: Anthropic

Anthropic LLM implementation

Hierarchy

  • BaseLLM

    Anthropic

Constructors

constructor

new Anthropic(init?): Anthropic

Parameters

NameType
init?Partial<Anthropic>

Returns

Anthropic

Overrides

BaseLLM.constructor

Defined in

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

Properties

apiKey

Optional apiKey: string = undefined

Defined in

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


callbackManager

Optional callbackManager: CallbackManager

Defined in

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


maxRetries

maxRetries: number

Defined in

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


maxTokens

Optional maxTokens: number

Defined in

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


model

model: "claude-3-opus" | "claude-3-sonnet" | "claude-3-haiku" | "claude-2.1" | "claude-instant-1.2"

Defined in

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


session

session: AnthropicSession

Defined in

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


temperature

temperature: number

Defined in

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


timeout

Optional timeout: number

Defined in

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


topP

topP: number

Defined in

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

Accessors

metadata

get metadata(): Object

Returns

Object

NameType
contextWindownumber
maxTokensundefined | number
model"claude-3-opus" | "claude-3-sonnet" | "claude-3-haiku" | "claude-2.1" | "claude-instant-1.2"
temperaturenumber
tokenizerundefined
topPnumber

Overrides

BaseLLM.metadata

Defined in

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

Methods

chat

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

Parameters

NameType
paramsLLMChatParamsStreaming

Returns

Promise<AsyncIterable<ChatResponseChunk>>

Overrides

BaseLLM.chat

Defined in

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

chat(params): Promise<ChatResponse>

Parameters

NameType
paramsLLMChatParamsNonStreaming

Returns

Promise<ChatResponse>

Overrides

BaseLLM.chat

Defined in

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


complete

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

Parameters

NameType
paramsLLMCompletionParamsStreaming

Returns

Promise<AsyncIterable<CompletionResponse>>

Inherited from

BaseLLM.complete

Defined in

packages/core/src/llm/base.ts:18

complete(params): Promise<CompletionResponse>

Parameters

NameType
paramsLLMCompletionParamsNonStreaming

Returns

Promise<CompletionResponse>

Inherited from

BaseLLM.complete

Defined in

packages/core/src/llm/base.ts:21


formatMessages

formatMessages(messages): { content: any = message.content; role: "user" | "assistant" = message.role }[]

Parameters

NameType
messagesChatMessage[]

Returns

{ content: any = message.content; role: "user" | "assistant" = message.role }[]

Defined in

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


getModelName

getModelName(model): string

Parameters

NameType
modelstring

Returns

string

Defined in

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


streamChat

streamChat(messages, parentEvent?, systemPrompt?): AsyncIterable<ChatResponseChunk>

Parameters

NameType
messagesChatMessage[]
parentEvent?Event
systemPrompt?null | string

Returns

AsyncIterable<ChatResponseChunk>

Defined in

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


tokens

tokens(messages): number

Parameters

NameType
messagesChatMessage[]

Returns

number

Overrides

BaseLLM.tokens

Defined in

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