Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ class ChatAnthropic_ChatModels implements INode {

const model = new ChatAnthropic(nodeData.id, obj)
model.setMultiModalOption(multiModalOption)
// Langchain sets topP to -1 by default, which is invalid for Claude Opus 4.5 and Claude Sonnet 4.5
if (model.topP === -1) {
model.topP = undefined
}

return model
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { MODEL_TYPE, getModels } from '../../../src/modelLoader'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { Anthropic } from 'llamaindex'
import { ChatAnthropic } from '@langchain/anthropic'

class ChatAnthropic_LlamaIndex_ChatModels implements INode {
label: string
Expand All @@ -24,7 +24,7 @@ class ChatAnthropic_LlamaIndex_ChatModels implements INode {
this.icon = 'Anthropic.svg'
this.category = 'Chat Models'
this.description = 'Wrapper around ChatAnthropic LLM specific for LlamaIndex'
this.baseClasses = [this.type, 'BaseChatModel_LlamaIndex', ...getBaseClasses(Anthropic)]
this.baseClasses = [this.type, 'BaseChatModel_LlamaIndex', ...getBaseClasses(ChatAnthropic)]
this.tags = ['LlamaIndex']
this.credential = {
label: 'Connect Credential',
Expand Down Expand Up @@ -76,23 +76,23 @@ class ChatAnthropic_LlamaIndex_ChatModels implements INode {

async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const temperature = nodeData.inputs?.temperature as string
const modelName = nodeData.inputs?.modelName as 'claude-3-opus' | 'claude-3-sonnet' | 'claude-2.1' | 'claude-instant-1.2'
const modelName = nodeData.inputs?.modelName as string
const maxTokensToSample = nodeData.inputs?.maxTokensToSample as string
const topP = nodeData.inputs?.topP as string

const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const anthropicApiKey = getCredentialParam('anthropicApiKey', credentialData, nodeData)

const obj: Partial<Anthropic> = {
const obj: Partial<ChatAnthropic> = {
temperature: parseFloat(temperature),
model: modelName,
apiKey: anthropicApiKey
anthropicApiKey: anthropicApiKey
}

if (maxTokensToSample) obj.maxTokens = parseInt(maxTokensToSample, 10)
if (topP) obj.topP = parseFloat(topP)

const model = new Anthropic(obj)
const model = new ChatAnthropic(obj)
return model
}
}
Expand Down
Loading