Skip to content

Commit

Permalink
Chore/LC v0.3 (#3517)
Browse files Browse the repository at this point in the history
* bump langchain version to 0.3, upgrades on all chat models

* update all docs loader to have documents and text output options

* fix pnpm lock file
  • Loading branch information
HenryHengZJ authored Nov 28, 2024
1 parent 126808b commit 940c8fd
Show file tree
Hide file tree
Showing 82 changed files with 2,364 additions and 1,531 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
},
"resolutions": {
"@google/generative-ai": "^0.15.0",
"@langchain/core": "0.2.18",
"@langchain/core": "0.3.18",
"@qdrant/openapi-typescript-fetch": "1.2.6",
"openai": "4.57.3",
"protobufjs": "7.4.0"
Expand Down
20 changes: 10 additions & 10 deletions packages/components/credentials/BaiduApi.credential.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { INodeParams, INodeCredential } from '../src/Interface'

class BaiduApi implements INodeCredential {
class BaiduQianfanApi implements INodeCredential {
label: string
name: string
version: number
inputs: INodeParams[]

constructor() {
this.label = 'Baidu API'
this.name = 'baiduApi'
this.version = 1.0
this.label = 'Baidu Qianfan API'
this.name = 'baiduQianfanApi'
this.version = 2.0
this.inputs = [
{
label: 'Baidu Api Key',
name: 'baiduApiKey',
type: 'password'
label: 'Qianfan Access Key',
name: 'qianfanAccessKey',
type: 'string'
},
{
label: 'Baidu Secret Key',
name: 'baiduSecretKey',
label: 'Qianfan Secret Key',
name: 'qianfanSecretKey',
type: 'password'
}
]
}
}

module.exports = { credClass: BaiduApi }
module.exports = { credClass: BaiduQianfanApi }
69 changes: 69 additions & 0 deletions packages/components/credentials/IBMWatsonx.credential.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { INodeParams, INodeCredential } from '../src/Interface'

class IBMWatsonxCredential implements INodeCredential {
label: string
name: string
version: number
description: string
inputs: INodeParams[]

constructor() {
this.label = 'IBM Watsonx'
this.name = 'ibmWatsonx'
this.version = 1.0
this.inputs = [
{
label: 'Version',
name: 'version',
type: 'string',
placeholder: 'YYYY-MM-DD'
},
{
label: 'Service URL',
name: 'serviceUrl',
type: 'string',
placeholder: '<SERVICE_URL>'
},
{
label: 'Project ID',
name: 'projectId',
type: 'string',
placeholder: '<PROJECT_ID>'
},
{
label: 'Watsonx AI Auth Type',
name: 'watsonxAIAuthType',
type: 'options',
options: [
{
label: 'IAM',
name: 'iam'
},
{
label: 'Bearer Token',
name: 'bearertoken'
}
],
default: 'iam'
},
{
label: 'Watsonx AI IAM API Key',
name: 'watsonxAIApikey',
type: 'password',
description: 'API Key for Watsonx AI when using IAM',
placeholder: '<YOUR-APIKEY>',
optional: true
},
{
label: 'Watsonx AI Bearer Token',
name: 'watsonxAIBearerToken',
type: 'password',
description: 'Bearer Token for Watsonx AI when using Bearer Token',
placeholder: '<YOUR-BEARER-TOKEN>',
optional: true
}
]
}
}

module.exports = { credClass: IBMWatsonxCredential }
24 changes: 24 additions & 0 deletions packages/components/credentials/XaiApi.credential.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { INodeParams, INodeCredential } from '../src/Interface'

class XaiApi implements INodeCredential {
label: string
name: string
version: number
description: string
inputs: INodeParams[]

constructor() {
this.label = 'Xai API'
this.name = 'xaiApi'
this.version = 1.0
this.inputs = [
{
label: 'X AI API Key',
name: 'xaiApiKey',
type: 'password'
}
]
}
}

module.exports = { credClass: XaiApi }
67 changes: 14 additions & 53 deletions packages/components/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -426,21 +426,8 @@
"name": "gemini-1.5-pro-002"
},
{
"label": "gemini-pro",
"name": "gemini-pro"
},
{
"label": "gemini-pro-vision",
"name": "gemini-pro-vision"
}
]
},
{
"name": "chatGooglePaLM",
"models": [
{
"label": "models/chat-bison-001",
"name": "models/chat-bison-001"
"label": "gemini-1.0-pro-latest (deprecated)",
"name": "gemini-1.0-pro-latest"
}
]
},
Expand All @@ -457,12 +444,20 @@
"name": "chatGoogleVertexAI",
"models": [
{
"label": "gemini-1.5-flash",
"name": "gemini-1.5-flash-preview-0514"
"label": "gemini-1.5-flash-002",
"name": "gemini-1.5-flash-002"
},
{
"label": "gemini-1.5-flash-001",
"name": "gemini-1.5-flash-001"
},
{
"label": "gemini-1.5-pro-002",
"name": "gemini-1.5-pro-002"
},
{
"label": "gemini-1.5-pro",
"name": "gemini-1.5-pro-preview-0409"
"label": "gemini-1.5-pro-001",
"name": "gemini-1.5-pro-001"
},
{
"label": "gemini-1.0-pro",
Expand Down Expand Up @@ -496,22 +491,6 @@
"label": "claude-3-haiku@20240307",
"name": "claude-3-haiku@20240307",
"description": "Fastest and most compact model for near-instant responsiveness"
},
{
"label": "chat-bison",
"name": "chat-bison"
},
{
"label": "codechat-bison",
"name": "codechat-bison"
},
{
"label": "chat-bison-32k",
"name": "chat-bison-32k"
},
{
"label": "codechat-bison-32k",
"name": "codechat-bison-32k"
}
]
},
Expand Down Expand Up @@ -1112,15 +1091,6 @@
}
]
},
{
"name": "GooglePaLM",
"models": [
{
"label": "models/text-bison-001",
"name": "models/text-bison-001"
}
]
},
{
"name": "googlevertexai",
"models": [
Expand Down Expand Up @@ -1267,15 +1237,6 @@
}
]
},
{
"name": "googlePaLMEmbeddings",
"models": [
{
"label": "models/embedding-gecko-001",
"name": "models/embedding-gecko-001"
}
]
},
{
"name": "googlevertexaiEmbeddings",
"models": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class ConversationalRetrievalToolAgent_Agents implements INode {
baseClasses: string[]
inputs: INodeParams[]
sessionId?: string
badge?: string

constructor(fields?: { sessionId?: string }) {
this.label = 'Conversational Retrieval Tool Agent'
Expand All @@ -50,7 +49,6 @@ class ConversationalRetrievalToolAgent_Agents implements INode {
this.icon = 'toolAgent.png'
this.description = `Agent that calls a vector store retrieval and uses Function Calling to pick the tools and args to call`
this.baseClasses = [this.type, ...getBaseClasses(AgentExecutor)]
this.badge = 'NEW'
this.inputs = [
{
label: 'Tools',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class AnthropicAgent_LlamaIndex_Agents implements INode {
tags: string[]
inputs: INodeParams[]
sessionId?: string
badge?: string

constructor(fields?: { sessionId?: string }) {
this.label = 'Anthropic Agent'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class OpenAIFunctionAgent_LlamaIndex_Agents implements INode {
tags: string[]
inputs: INodeParams[]
sessionId?: string
badge?: string

constructor(fields?: { sessionId?: string }) {
this.label = 'OpenAI Tool Agent'
Expand Down
2 changes: 1 addition & 1 deletion packages/components/nodes/agents/ToolAgent/ToolAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class ToolAgent_Agents implements INode {
baseClasses: string[]
inputs: INodeParams[]
sessionId?: string
badge?: string

constructor(fields?: { sessionId?: string }) {
this.label = 'Tool Agent'
Expand Down Expand Up @@ -191,6 +190,7 @@ class ToolAgent_Agents implements INode {
output = removeInvalidImageMarkdown(output)

// Claude 3 Opus tends to spit out <thinking>..</thinking> as well, discard that in final output
// https://docs.anthropic.com/en/docs/build-with-claude/tool-use#chain-of-thought
const regexPattern: RegExp = /<thinking>[\s\S]*?<\/thinking>/
const matches: RegExpMatchArray | null = output.match(regexPattern)
if (matches) {
Expand Down
1 change: 0 additions & 1 deletion packages/components/nodes/agents/XMLAgent/XMLAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class XMLAgent_Agents implements INode {
baseClasses: string[]
inputs: INodeParams[]
sessionId?: string
badge?: string

constructor(fields?: { sessionId?: string }) {
this.label = 'XML Agent'
Expand Down
24 changes: 16 additions & 8 deletions packages/components/nodes/chatmodels/AWSBedrock/AWSChatBedrock.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { BaseCache } from '@langchain/core/caches'
import { ICommonObject, IMultiModalOption, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { BedrockChat } from './FlowiseAWSChatBedrock'
import { getModels, getRegions, MODEL_TYPE } from '../../../src/modelLoader'
import { BedrockChatFields } from '@langchain/community/chat_models/bedrock'
import { ChatBedrockConverseInput, ChatBedrockConverse } from '@langchain/aws'
import { BedrockChat } from './FlowiseAWSChatBedrock'

/**
* @author Michael Connor <mlconnor@yahoo.com>
Expand All @@ -23,12 +23,12 @@ class AWSChatBedrock_ChatModels implements INode {
constructor() {
this.label = 'AWS ChatBedrock'
this.name = 'awsChatBedrock'
this.version = 5.0
this.version = 6.0
this.type = 'AWSChatBedrock'
this.icon = 'aws.svg'
this.category = 'Chat Models'
this.description = 'Wrapper around AWS Bedrock large language models that use the Chat endpoint'
this.baseClasses = [this.type, ...getBaseClasses(BedrockChat)]
this.description = 'Wrapper around AWS Bedrock large language models that use the Converse API'
this.baseClasses = [this.type, ...getBaseClasses(ChatBedrockConverse)]
this.credential = {
label: 'AWS Credential',
name: 'credential',
Expand Down Expand Up @@ -64,6 +64,14 @@ class AWSChatBedrock_ChatModels implements INode {
type: 'string',
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Temperature',
name: 'temperature',
Expand All @@ -89,7 +97,7 @@ class AWSChatBedrock_ChatModels implements INode {
name: 'allowImageUploads',
type: 'boolean',
description:
'Only works with claude-3-* models when image is being uploaded from chat. Compatible with LLMChain, Conversation Chain, ReAct Agent, Conversational Agent, Tool Agent',
'Allow image input. Refer to the <a href="https://docs.flowiseai.com/using-flowise/uploads#image" target="_blank">docs</a> for more details.',
default: false,
optional: true
}
Expand All @@ -115,7 +123,7 @@ class AWSChatBedrock_ChatModels implements INode {
const cache = nodeData.inputs?.cache as BaseCache
const streaming = nodeData.inputs?.streaming as boolean

const obj: BedrockChatFields = {
const obj: ChatBedrockConverseInput = {
region: iRegion,
model: customModel ? customModel : iModel,
maxTokens: parseInt(iMax_tokens_to_sample, 10),
Expand Down Expand Up @@ -153,7 +161,7 @@ class AWSChatBedrock_ChatModels implements INode {
}

const amazonBedrock = new BedrockChat(nodeData.id, obj)
if (obj.model?.includes('anthropic.claude-3')) amazonBedrock.setMultiModalOption(multiModalOption)
amazonBedrock.setMultiModalOption(multiModalOption)
return amazonBedrock
}
}
Expand Down
Loading

0 comments on commit 940c8fd

Please sign in to comment.