Class: Anthropic
Anthropic LLM implementation
Implements
Constructors
constructor
• new Anthropic(init?
)
Parameters
Name | Type |
---|---|
init? | Partial <Anthropic > |
Defined in
packages/core/src/llm/LLM.ts:670
Properties
apiKey
• Optional
apiKey: string
= undefined
Defined in
packages/core/src/llm/LLM.ts:663
callbackManager
• Optional
callbackManager: CallbackManager
Defined in
packages/core/src/llm/LLM.ts:668
hasStreaming
• hasStreaming: boolean
= true
Implementation of
Defined in
packages/core/src/llm/LLM.ts:654
maxRetries
• maxRetries: number
Defined in
packages/core/src/llm/LLM.ts:664
maxTokens
• Optional
maxTokens: number
Defined in
packages/core/src/llm/LLM.ts:660
model
• model: "claude-2"
| "claude-instant-1"
Defined in
packages/core/src/llm/LLM.ts:657
session
• session: AnthropicSession
Defined in
packages/core/src/llm/LLM.ts:666
temperature
• temperature: number
Defined in
packages/core/src/llm/LLM.ts:658
timeout
• Optional
timeout: number
Defined in
packages/core/src/llm/LLM.ts:665
topP
• topP: number
Defined in
packages/core/src/llm/LLM.ts:659
Accessors
metadata
• get
metadata(): Object
Returns
Object
Name | Type |
---|---|
contextWindow | number |
maxTokens | undefined | number |
model | "claude-2" | "claude-instant-1" |
temperature | number |
tokenizer | undefined |
topP | number |
Implementation of
Defined in
packages/core/src/llm/LLM.ts:694
Methods
chat
▸ chat<T
, R
>(messages
, parentEvent?
, streaming?
): Promise
<R
>
Get a chat response from the LLM
Type parameters
Name | Type |
---|---|
T | extends undefined | boolean = undefined |
R | T extends true ? AsyncGenerator <string , void , unknown > : ChatResponse |
Parameters
Name | Type | Description |
---|---|---|
messages | ChatMessage [] | 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
Defined in
packages/core/src/llm/LLM.ts:722
complete
▸ complete<T
, R
>(prompt
, parentEvent?
, streaming?
): Promise
<R
>
Get a prompt completion from the LLM
Type parameters
Name | Type |
---|---|
T | extends undefined | boolean = undefined |
R | T extends true ? AsyncGenerator <string , void , unknown > : ChatResponse |
Parameters
Name | Type | Description |
---|---|---|
prompt | string | the prompt to complete |
parentEvent? | Event | - |
streaming? | T | - |
Returns
Promise
<R
>
Implementation of
Defined in
packages/core/src/llm/LLM.ts:779
mapMessagesToPrompt
▸ mapMessagesToPrompt(messages
): string
Parameters
Name | Type |
---|---|
messages | ChatMessage [] |
Returns
string
Defined in
packages/core/src/llm/LLM.ts:705
streamChat
▸ Protected
streamChat(messages
, parentEvent?
): AsyncGenerator
<string
, void
, unknown
>
Parameters
Name | Type |
---|---|
messages | ChatMessage [] |
parentEvent? | Event |
Returns
AsyncGenerator
<string
, void
, unknown
>
Defined in
packages/core/src/llm/LLM.ts:754
streamComplete
▸ Protected
streamComplete(prompt
, parentEvent?
): AsyncGenerator
<string
, void
, unknown
>
Parameters
Name | Type |
---|---|
prompt | string |
parentEvent? | Event |
Returns
AsyncGenerator
<string
, void
, unknown
>
Defined in
packages/core/src/llm/LLM.ts:797
tokens
▸ tokens(messages
): number
Calculates the number of tokens needed for the given chat messages
Parameters
Name | Type |
---|---|
messages | ChatMessage [] |
Returns
number