Chore/LC v0.3 (#3517)

* 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
This commit is contained in:
Henry Heng
2024-11-28 11:06:12 +00:00
committed by GitHub
parent 126808b62a
commit 940c8fd3b0
82 changed files with 2373 additions and 1540 deletions
@@ -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>
@@ -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',
@@ -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',
@@ -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
}
@@ -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),
@@ -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
}
}
@@ -1,5 +1,8 @@
import { BedrockChatFields, BedrockChat as LCBedrockChat } from '@langchain/community/chat_models/bedrock'
import { IVisionChatModal, IMultiModalOption } from '../../../src'
import { ChatBedrockConverse as LCBedrockChat, ChatBedrockConverseInput } from '@langchain/aws'
const DEFAULT_IMAGE_MODEL = 'anthropic.claude-3-haiku-20240307-v1:0'
const DEFAULT_IMAGE_MAX_TOKEN = 1024
export class BedrockChat extends LCBedrockChat implements IVisionChatModal {
configuredModel: string
@@ -7,7 +10,7 @@ export class BedrockChat extends LCBedrockChat implements IVisionChatModal {
multiModalOption: IMultiModalOption
id: string
constructor(id: string, fields: BedrockChatFields) {
constructor(id: string, fields: ChatBedrockConverseInput) {
super(fields)
this.id = id
this.configuredModel = fields?.model || ''
@@ -25,8 +28,8 @@ export class BedrockChat extends LCBedrockChat implements IVisionChatModal {
setVisionModel(): void {
if (!this.model.startsWith('claude-3')) {
this.model = 'anthropic.claude-3-haiku-20240307-v1:0'
this.maxTokens = this.configuredMaxToken ? this.configuredMaxToken : 1024
this.model = DEFAULT_IMAGE_MODEL
this.maxTokens = this.configuredMaxToken ? this.configuredMaxToken : DEFAULT_IMAGE_MAX_TOKEN
}
}
}
@@ -27,7 +27,7 @@ class AzureChatOpenAI_ChatModels implements INode {
constructor() {
this.label = 'Azure ChatOpenAI'
this.name = 'azureChatOpenAI'
this.version = 5.0
this.version = 6.0
this.type = 'AzureChatOpenAI'
this.icon = 'Azure.svg'
this.category = 'Chat Models'
@@ -69,6 +69,14 @@ class AzureChatOpenAI_ChatModels implements INode {
optional: true,
additionalParams: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Top Probability',
name: 'topP',
@@ -113,7 +121,7 @@ class AzureChatOpenAI_ChatModels implements INode {
name: 'allowImageUploads',
type: 'boolean',
description:
'Automatically uses gpt-4-vision-preview when image is being uploaded from chat. Only works 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
},
@@ -19,7 +19,7 @@ class ChatAlibabaTongyi_ChatModels implements INode {
constructor() {
this.label = 'ChatAlibabaTongyi'
this.name = 'chatAlibabaTongyi'
this.version = 1.0
this.version = 2.0
this.type = 'ChatAlibabaTongyi'
this.icon = 'alibaba-svgrepo-com.svg'
this.category = 'Chat Models'
@@ -51,6 +51,13 @@ class ChatAlibabaTongyi_ChatModels implements INode {
step: 0.1,
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true
}
]
}
@@ -59,12 +66,13 @@ class ChatAlibabaTongyi_ChatModels implements INode {
const cache = nodeData.inputs?.cache as BaseCache
const temperature = nodeData.inputs?.temperature as string
const modelName = nodeData.inputs?.modelName as string
const streaming = nodeData.inputs?.streaming as boolean
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const alibabaApiKey = getCredentialParam('alibabaApiKey', credentialData, nodeData)
const obj: Partial<ChatAlibabaTongyi> & BaseChatModelParams = {
streaming: true,
streaming: streaming ?? true,
alibabaApiKey,
model: modelName,
temperature: temperature ? parseFloat(temperature) : undefined
@@ -21,7 +21,7 @@ class ChatAnthropic_ChatModels implements INode {
constructor() {
this.label = 'ChatAnthropic'
this.name = 'chatAnthropic'
this.version = 6.0
this.version = 7.0
this.type = 'ChatAnthropic'
this.icon = 'Anthropic.svg'
this.category = 'Chat Models'
@@ -55,6 +55,14 @@ class ChatAnthropic_ChatModels implements INode {
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Max Tokens',
name: 'maxTokensToSample',
@@ -84,7 +92,7 @@ class ChatAnthropic_ChatModels implements INode {
name: 'allowImageUploads',
type: 'boolean',
description:
'Automatically uses claude-3-* models when image is being uploaded from chat. Only works 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
}
@@ -2,6 +2,9 @@ import { AnthropicInput, ChatAnthropic as LangchainChatAnthropic } from '@langch
import { type BaseChatModelParams } from '@langchain/core/language_models/chat_models'
import { IVisionChatModal, IMultiModalOption } from '../../../src'
const DEFAULT_IMAGE_MODEL = 'claude-3-5-haiku-latest'
const DEFAULT_IMAGE_MAX_TOKEN = 2048
export class ChatAnthropic extends LangchainChatAnthropic implements IVisionChatModal {
configuredModel: string
configuredMaxToken: number
@@ -27,8 +30,8 @@ export class ChatAnthropic extends LangchainChatAnthropic implements IVisionChat
setVisionModel(): void {
if (!this.modelName.startsWith('claude-3')) {
this.modelName = 'claude-3-haiku-20240307'
this.maxTokens = this.configuredMaxToken ? this.configuredMaxToken : 2048
this.modelName = DEFAULT_IMAGE_MODEL
this.maxTokens = this.configuredMaxToken ? this.configuredMaxToken : DEFAULT_IMAGE_MAX_TOKEN
}
}
}
@@ -1,5 +1,5 @@
import { BaseCache } from '@langchain/core/caches'
import { ChatBaiduWenxin } from '@langchain/community/chat_models/baiduwenxin'
import { ChatBaiduQianfan } from '@langchain/baidu-qianfan'
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
@@ -18,17 +18,17 @@ class ChatBaiduWenxin_ChatModels implements INode {
constructor() {
this.label = 'ChatBaiduWenxin'
this.name = 'chatBaiduWenxin'
this.version = 1.0
this.version = 2.0
this.type = 'ChatBaiduWenxin'
this.icon = 'baiduwenxin.svg'
this.category = 'Chat Models'
this.description = 'Wrapper around BaiduWenxin Chat Endpoints'
this.baseClasses = [this.type, ...getBaseClasses(ChatBaiduWenxin)]
this.baseClasses = [this.type, ...getBaseClasses(ChatBaiduQianfan)]
this.credential = {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['baiduApi']
credentialNames: ['baiduQianfanApi']
}
this.inputs = [
{
@@ -50,6 +50,13 @@ class ChatBaiduWenxin_ChatModels implements INode {
step: 0.1,
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true
}
]
}
@@ -58,21 +65,22 @@ class ChatBaiduWenxin_ChatModels implements INode {
const cache = nodeData.inputs?.cache as BaseCache
const temperature = nodeData.inputs?.temperature as string
const modelName = nodeData.inputs?.modelName as string
const streaming = nodeData.inputs?.streaming as boolean
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const baiduApiKey = getCredentialParam('baiduApiKey', credentialData, nodeData)
const baiduSecretKey = getCredentialParam('baiduSecretKey', credentialData, nodeData)
const qianfanAccessKey = getCredentialParam('qianfanAccessKey', credentialData, nodeData)
const qianfanSecretKey = getCredentialParam('qianfanSecretKey', credentialData, nodeData)
const obj: Partial<ChatBaiduWenxin> = {
streaming: true,
baiduApiKey,
baiduSecretKey,
const obj: Partial<ChatBaiduQianfan> = {
streaming: streaming ?? true,
qianfanAccessKey,
qianfanSecretKey,
modelName,
temperature: temperature ? parseFloat(temperature) : undefined
}
if (cache) obj.cache = cache
const model = new ChatBaiduWenxin(obj)
const model = new ChatBaiduQianfan(obj)
return model
}
}
@@ -19,11 +19,11 @@ class ChatCerebras_ChatModels implements INode {
constructor() {
this.label = 'ChatCerebras'
this.name = 'chatCerebras'
this.version = 1.0
this.version = 2.0
this.type = 'ChatCerebras'
this.icon = 'cerebras.png'
this.category = 'Chat Models'
this.description = 'Models available via Cerebras'
this.description = 'Wrapper around Cerebras Inference API'
this.baseClasses = [this.type, ...getBaseClasses(ChatOpenAI)]
this.credential = {
label: 'Connect Credential',
@@ -53,6 +53,14 @@ class ChatCerebras_ChatModels implements INode {
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Max Tokens',
name: 'maxTokens',
@@ -19,7 +19,7 @@ class ChatCohere_ChatModels implements INode {
constructor() {
this.label = 'ChatCohere'
this.name = 'chatCohere'
this.version = 1.0
this.version = 2.0
this.type = 'ChatCohere'
this.icon = 'Cohere.svg'
this.category = 'Chat Models'
@@ -52,6 +52,13 @@ class ChatCohere_ChatModels implements INode {
step: 0.1,
default: 0.7,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true
}
]
}
@@ -18,7 +18,7 @@ class ChatFireworks_ChatModels implements INode {
constructor() {
this.label = 'ChatFireworks'
this.name = 'chatFireworks'
this.version = 1.0
this.version = 2.0
this.type = 'ChatFireworks'
this.icon = 'Fireworks.png'
this.category = 'Chat Models'
@@ -51,6 +51,13 @@ class ChatFireworks_ChatModels implements INode {
step: 0.1,
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true
}
]
}
@@ -21,7 +21,7 @@ class GoogleGenerativeAI_ChatModels implements INode {
constructor() {
this.label = 'ChatGoogleGenerativeAI'
this.name = 'chatGoogleGenerativeAI'
this.version = 2.1
this.version = 3.0
this.type = 'ChatGoogleGenerativeAI'
this.icon = 'GoogleGemini.svg'
this.category = 'Chat Models'
@@ -47,7 +47,7 @@ class GoogleGenerativeAI_ChatModels implements INode {
name: 'modelName',
type: 'asyncOptions',
loadMethod: 'listModels',
default: 'gemini-pro'
default: 'gemini-1.5-flash-latest'
},
{
label: 'Custom Model Name',
@@ -65,6 +65,14 @@ class GoogleGenerativeAI_ChatModels implements INode {
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Max Output Tokens',
name: 'maxOutputTokens',
@@ -153,7 +161,7 @@ class GoogleGenerativeAI_ChatModels implements INode {
name: 'allowImageUploads',
type: 'boolean',
description:
'Automatically uses vision model when image is being uploaded from chat. Only works 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
}
@@ -26,6 +26,9 @@ import { isStructuredTool } from '@langchain/core/utils/function_calling'
import { zodToJsonSchema } from 'zod-to-json-schema'
import { BaseLanguageModelCallOptions } from '@langchain/core/language_models/base'
const DEFAULT_IMAGE_MAX_TOKEN = 8192
const DEFAULT_IMAGE_MODEL = 'gemini-1.5-flash-latest'
interface TokenUsage {
completionTokens?: number
promptTokens?: number
@@ -362,9 +365,9 @@ export class ChatGoogleGenerativeAI extends LangchainChatGoogleGenerativeAI impl
}
setVisionModel(): void {
if (this.modelName !== 'gemini-pro-vision' && this.modelName !== 'gemini-1.5-pro-latest') {
this.modelName = 'gemini-1.5-pro-latest'
this.maxOutputTokens = this.configuredMaxToken ? this.configuredMaxToken : 8192
if (this.modelName === 'gemini-1.0-pro-latest') {
this.modelName = DEFAULT_IMAGE_MODEL
this.maxOutputTokens = this.configuredMaxToken ? this.configuredMaxToken : DEFAULT_IMAGE_MAX_TOKEN
}
}
}
@@ -607,13 +610,13 @@ function convertResponseContentToChatGenerationChunk(
index: number
}
): ChatGenerationChunk | null {
if (!response.candidates || response.candidates.length === 0) {
if (!response || !response.candidates || response.candidates.length === 0) {
return null
}
const functionCalls = response.functionCalls()
const [candidate] = response.candidates
const { content, ...generationInfo } = candidate
const text = content?.parts[0]?.text ?? ''
const text = content?.parts?.[0]?.text ?? ''
const toolCallChunks: ToolCallChunk[] = []
if (functionCalls) {
@@ -1,128 +0,0 @@
import { ChatGooglePaLM, GooglePaLMChatInput } from '@langchain/community/chat_models/googlepalm'
import { BaseCache } from '@langchain/core/caches'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { getModels, MODEL_TYPE } from '../../../src/modelLoader'
class ChatGooglePaLM_ChatModels implements INode {
label: string
name: string
version: number
type: string
icon: string
category: string
description: string
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
constructor() {
this.label = 'ChatGooglePaLM'
this.name = 'chatGooglePaLM'
this.version = 3.0
this.type = 'ChatGooglePaLM'
this.icon = 'GooglePaLM.svg'
this.category = 'Chat Models'
this.description = 'Wrapper around Google MakerSuite PaLM large language models using the Chat endpoint'
this.baseClasses = [this.type, ...getBaseClasses(ChatGooglePaLM)]
this.credential = {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['googleMakerSuite']
}
this.inputs = [
{
label: 'Cache',
name: 'cache',
type: 'BaseCache',
optional: true
},
{
label: 'Model Name',
name: 'modelName',
type: 'asyncOptions',
loadMethod: 'listModels',
default: 'models/chat-bison-001'
},
{
label: 'Temperature',
name: 'temperature',
type: 'number',
step: 0.1,
default: 0.7,
optional: true,
description:
'Controls the randomness of the output.\n' +
'Values can range from [0.0,1.0], inclusive. A value closer to 1.0 ' +
'will produce responses that are more varied and creative, while ' +
'a value closer to 0.0 will typically result in more straightforward ' +
'responses from the model.'
},
{
label: 'Top Probability',
name: 'topP',
type: 'number',
step: 0.1,
optional: true,
additionalParams: true,
description:
'Top-p changes how the model selects tokens for output.\n' +
'Tokens are selected from most probable to least until ' +
'the sum of their probabilities equals the top-p value.\n' +
'For example, if tokens A, B, and C have a probability of .3, .2, and .1 ' +
'and the top-p value is .5, then the model will select either A or B ' +
'as the next token (using temperature).'
},
{
label: 'Top-k',
name: 'topK',
type: 'number',
step: 1,
optional: true,
additionalParams: true,
description:
'Top-k changes how the model selects tokens for output.\n' +
'A top-k of 1 means the selected token is the most probable among ' +
'all tokens in the model vocabulary (also called greedy decoding), ' +
'while a top-k of 3 means that the next token is selected from ' +
'among the 3 most probable tokens (using temperature).'
}
// 'The "examples" field should contain a list of pairs of strings to use as prior turns for this conversation.'
// NB: While 'examples:[]' exists in langchain.ts backend, it is unlikely to be actually used there, since ChatOpenAI doesn't support it
]
}
//@ts-ignore
loadMethods = {
async listModels(): Promise<INodeOptionsValue[]> {
return await getModels(MODEL_TYPE.CHAT, 'chatGooglePaLM')
}
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const modelName = nodeData.inputs?.modelName as string
const temperature = nodeData.inputs?.temperature as string
const topP = nodeData.inputs?.topP as string
const topK = nodeData.inputs?.topK as string
const cache = nodeData.inputs?.cache as BaseCache
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const googleMakerSuiteKey = getCredentialParam('googleMakerSuiteKey', credentialData, nodeData)
const obj: Partial<GooglePaLMChatInput> = {
modelName: modelName,
temperature: parseFloat(temperature),
apiKey: googleMakerSuiteKey
}
if (topP) obj.topP = parseFloat(topP)
if (topK) obj.topK = parseFloat(topK)
if (cache) obj.cache = cache
const model = new ChatGooglePaLM(obj)
return model
}
}
module.exports = { nodeClass: ChatGooglePaLM_ChatModels }
@@ -1 +0,0 @@
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M15.991 28.555c1.064 0 1.926-.624 1.926-1.394V15.074h-3.852v12.087c0 .77.862 1.394 1.926 1.394Z" fill="#F9AB00" stroke="#F9AB00"/><path d="M23.01 16.825a6.301 6.301 0 0 0-6.606-1.467c-.322.117-.39.525-.148.767l7.294 7.294a.61.61 0 0 0 1.01-.238 6.3 6.3 0 0 0-1.55-6.356Z" fill="#5BB974" stroke="#5BB974"/><path d="M8.516 16.825a6.301 6.301 0 0 1 6.606-1.467c.322.117.39.525.148.767l-7.294 7.294a.61.61 0 0 1-1.01-.238 6.3 6.3 0 0 1 1.55-6.356Z" fill="#129EAF" stroke="#129EAF"/><path d="M22.433 10.781c-2.856 0-5.314 1.726-6.419 4.204-.139.312.102.647.443.647h11.62a.681.681 0 0 0 .613-.984c-1.17-2.296-3.532-3.867-6.258-3.867Z" fill="#AF5CF7" stroke="#AF5CF7"/><path d="M17.05 7.486c-2.02 2.02-2.538 4.977-1.567 7.51.122.32.53.386.77.145l8.218-8.217a.681.681 0 0 0-.262-1.13c-2.453-.795-5.233-.235-7.16 1.692Z" fill="#FF8BCB" stroke="#FF8BCB"/><path d="M14.476 7.486c2.02 2.02 2.538 4.977 1.566 7.51-.122.32-.529.386-.77.145L7.055 6.924a.681.681 0 0 1 .262-1.13C9.769 5 12.549 5.56 14.476 7.486Z" fill="#FA7B17" stroke="#FA7B17"/><path d="M9.093 10.781c2.856 0 5.314 1.726 6.418 4.204.14.312-.1.647-.442.647H3.449a.681.681 0 0 1-.613-.984c1.17-2.296 3.532-3.867 6.257-3.867Z" fill="#4285F4" stroke="#4285F4"/></svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

@@ -1,9 +1,51 @@
import { BaseCache } from '@langchain/core/caches'
import { ChatVertexAI, ChatVertexAIInput } from '@langchain/google-vertexai'
import { ICommonObject, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
import { ChatVertexAI as LcChatVertexAI, ChatVertexAIInput } from '@langchain/google-vertexai'
import {
ICommonObject,
IMultiModalOption,
INode,
INodeData,
INodeOptionsValue,
INodeParams,
IVisionChatModal
} from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { getModels, MODEL_TYPE } from '../../../src/modelLoader'
const DEFAULT_IMAGE_MAX_TOKEN = 8192
const DEFAULT_IMAGE_MODEL = 'gemini-1.5-flash-latest'
class ChatVertexAI extends LcChatVertexAI implements IVisionChatModal {
configuredModel: string
configuredMaxToken: number
multiModalOption: IMultiModalOption
id: string
constructor(id: string, fields?: ChatVertexAIInput) {
// @ts-ignore
super(fields ?? {})
this.id = id
this.configuredModel = fields?.modelName || ''
this.configuredMaxToken = fields?.maxOutputTokens ?? 2048
}
revertToOriginalModel(): void {
this.modelName = this.configuredModel
this.maxOutputTokens = this.configuredMaxToken
}
setMultiModalOption(multiModalOption: IMultiModalOption): void {
this.multiModalOption = multiModalOption
}
setVisionModel(): void {
if (!this.modelName.startsWith('claude-3')) {
this.modelName = DEFAULT_IMAGE_MODEL
this.maxOutputTokens = this.configuredMaxToken ? this.configuredMaxToken : DEFAULT_IMAGE_MAX_TOKEN
}
}
}
class GoogleVertexAI_ChatModels implements INode {
label: string
name: string
@@ -19,7 +61,7 @@ class GoogleVertexAI_ChatModels implements INode {
constructor() {
this.label = 'ChatGoogleVertexAI'
this.name = 'chatGoogleVertexAI'
this.version = 4.0
this.version = 5.0
this.type = 'ChatGoogleVertexAI'
this.icon = 'GoogleVertex.svg'
this.category = 'Chat Models'
@@ -45,8 +87,7 @@ class GoogleVertexAI_ChatModels implements INode {
label: 'Model Name',
name: 'modelName',
type: 'asyncOptions',
loadMethod: 'listModels',
default: 'chat-bison'
loadMethod: 'listModels'
},
{
label: 'Temperature',
@@ -56,6 +97,23 @@ class GoogleVertexAI_ChatModels implements INode {
default: 0.9,
optional: true
},
{
label: 'Allow Image Uploads',
name: 'allowImageUploads',
type: 'boolean',
description:
'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
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Max Output Tokens',
name: 'maxOutputTokens',
@@ -120,10 +178,20 @@ class GoogleVertexAI_ChatModels implements INode {
const topP = nodeData.inputs?.topP as string
const cache = nodeData.inputs?.cache as BaseCache
const topK = nodeData.inputs?.topK as string
const streaming = nodeData.inputs?.streaming as boolean
const allowImageUploads = nodeData.inputs?.allowImageUploads as boolean
const multiModalOption: IMultiModalOption = {
image: {
allowImageUploads: allowImageUploads ?? false
}
}
const obj: ChatVertexAIInput = {
temperature: parseFloat(temperature),
model: modelName
model: modelName,
streaming: streaming ?? true
}
if (Object.keys(authOptions).length !== 0) obj.authOptions = authOptions
@@ -132,7 +200,9 @@ class GoogleVertexAI_ChatModels implements INode {
if (cache) obj.cache = cache
if (topK) obj.topK = parseFloat(topK)
const model = new ChatVertexAI(obj)
const model = new ChatVertexAI(nodeData.id, obj)
model.setMultiModalOption(multiModalOption)
return model
}
}
@@ -0,0 +1,120 @@
import { BaseCache } from '@langchain/core/caches'
import { ChatWatsonx, ChatWatsonxInput } from '@langchain/community/chat_models/ibm'
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
interface WatsonxAuth {
watsonxAIApikey?: string
watsonxAIBearerToken?: string
watsonxAIUsername?: string
watsonxAIPassword?: string
watsonxAIUrl?: string
watsonxAIAuthType?: string
}
class ChatIBMWatsonx_ChatModels implements INode {
label: string
name: string
version: number
type: string
icon: string
category: string
description: string
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
constructor() {
this.label = 'ChatIBMWatsonx'
this.name = 'chatIBMWatsonx'
this.version = 1.0
this.type = 'ChatIBMWatsonx'
this.icon = 'ibm.png'
this.category = 'Chat Models'
this.description = 'Wrapper around IBM watsonx.ai foundation models'
this.baseClasses = [this.type, ...getBaseClasses(ChatWatsonx)]
this.credential = {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['ibmWatsonx']
}
this.inputs = [
{
label: 'Cache',
name: 'cache',
type: 'BaseCache',
optional: true
},
{
label: 'Model',
name: 'modelName',
type: 'string',
placeholder: 'mistralai/mistral-large'
},
{
label: 'Temperature',
name: 'temperature',
type: 'number',
step: 0.1,
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Max Tokens',
name: 'maxTokens',
type: 'number',
step: 1,
optional: true,
additionalParams: true
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const cache = nodeData.inputs?.cache as BaseCache
const temperature = nodeData.inputs?.temperature as string
const modelName = nodeData.inputs?.modelName as string
const maxTokens = nodeData.inputs?.maxTokens as string
const streaming = nodeData.inputs?.streaming as boolean
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const version = getCredentialParam('version', credentialData, nodeData)
const serviceUrl = getCredentialParam('serviceUrl', credentialData, nodeData)
const projectId = getCredentialParam('projectId', credentialData, nodeData)
const watsonxAIAuthType = getCredentialParam('watsonxAIAuthType', credentialData, nodeData)
const watsonxAIApikey = getCredentialParam('watsonxAIApikey', credentialData, nodeData)
const watsonxAIBearerToken = getCredentialParam('watsonxAIBearerToken', credentialData, nodeData)
const auth = {
version,
serviceUrl,
projectId,
watsonxAIAuthType,
watsonxAIApikey,
watsonxAIBearerToken
}
const obj: ChatWatsonxInput & WatsonxAuth = {
...auth,
streaming: streaming ?? true,
model: modelName,
temperature: temperature ? parseFloat(temperature) : undefined
}
if (cache) obj.cache = cache
if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10)
const model = new ChatWatsonx(obj)
return model
}
}
module.exports = { nodeClass: ChatIBMWatsonx_ChatModels }
Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

@@ -19,7 +19,7 @@ class ChatLocalAI_ChatModels implements INode {
constructor() {
this.label = 'ChatLocalAI'
this.name = 'chatLocalAI'
this.version = 2.0
this.version = 3.0
this.type = 'ChatLocalAI'
this.icon = 'localai.png'
this.category = 'Chat Models'
@@ -59,6 +59,14 @@ class ChatLocalAI_ChatModels implements INode {
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Max Tokens',
name: 'maxTokens',
@@ -93,6 +101,8 @@ class ChatLocalAI_ChatModels implements INode {
const topP = nodeData.inputs?.topP as string
const timeout = nodeData.inputs?.timeout as string
const basePath = nodeData.inputs?.basePath as string
const streaming = nodeData.inputs?.streaming as boolean
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const localAIApiKey = getCredentialParam('localAIApiKey', credentialData, nodeData)
@@ -101,7 +111,8 @@ class ChatLocalAI_ChatModels implements INode {
const obj: Partial<OpenAIChatInput> & BaseLLMParams & { openAIApiKey?: string } = {
temperature: parseFloat(temperature),
modelName,
openAIApiKey: 'sk-'
openAIApiKey: 'sk-',
streaming: streaming ?? true
}
if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10)
@@ -19,7 +19,7 @@ class ChatMistral_ChatModels implements INode {
constructor() {
this.label = 'ChatMistralAI'
this.name = 'chatMistralAI'
this.version = 3.0
this.version = 4.0
this.type = 'ChatMistralAI'
this.icon = 'MistralAI.svg'
this.category = 'Chat Models'
@@ -55,6 +55,14 @@ class ChatMistral_ChatModels implements INode {
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Max Output Tokens',
name: 'maxOutputTokens',
@@ -20,7 +20,7 @@ class ChatOllama_ChatModels implements INode {
constructor() {
this.label = 'ChatOllama'
this.name = 'chatOllama'
this.version = 4.0
this.version = 5.0
this.type = 'ChatOllama'
this.icon = 'Ollama.svg'
this.category = 'Chat Models'
@@ -59,10 +59,19 @@ class ChatOllama_ChatModels implements INode {
label: 'Allow Image Uploads',
name: 'allowImageUploads',
type: 'boolean',
description: 'Allow image uploads for multimodal models. e.g. llama3.2-vision',
description:
'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
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'JSON Mode',
name: 'jsonMode',
@@ -223,13 +232,15 @@ class ChatOllama_ChatModels implements INode {
const tfsZ = nodeData.inputs?.tfsZ as string
const allowImageUploads = nodeData.inputs?.allowImageUploads as boolean
const jsonMode = nodeData.inputs?.jsonMode as boolean
const streaming = nodeData.inputs?.streaming as boolean
const cache = nodeData.inputs?.cache as BaseCache
const obj: ChatOllamaInput & BaseChatModelParams = {
baseUrl,
temperature: parseFloat(temperature),
model: modelName
model: modelName,
streaming: streaming ?? true
}
if (topP) obj.topP = parseFloat(topP)
@@ -23,7 +23,7 @@ class ChatOpenAI_ChatModels implements INode {
constructor() {
this.label = 'ChatOpenAI'
this.name = 'chatOpenAI'
this.version = 7.0
this.version = 8.0
this.type = 'ChatOpenAI'
this.icon = 'openai.svg'
this.category = 'Chat Models'
@@ -57,6 +57,14 @@ class ChatOpenAI_ChatModels implements INode {
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Max Tokens',
name: 'maxTokens',
@@ -132,7 +140,7 @@ class ChatOpenAI_ChatModels implements INode {
name: 'allowImageUploads',
type: 'boolean',
description:
'Automatically uses gpt-4-vision-preview when image is being uploaded from chat. Only works 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
},
@@ -33,9 +33,6 @@ export class ChatOpenAI extends LangchainChatOpenAI implements IVisionChatModal
}
setVisionModel(): void {
if (this.modelName !== 'gpt-4-turbo' && !this.modelName.includes('vision')) {
this.modelName = 'gpt-4-turbo'
this.maxTokens = this.configuredMaxToken ? this.configuredMaxToken : 1024
}
// pass
}
}
@@ -19,7 +19,7 @@ class ChatOpenAICustom_ChatModels implements INode {
constructor() {
this.label = 'ChatOpenAI Custom'
this.name = 'chatOpenAICustom'
this.version = 3.0
this.version = 4.0
this.type = 'ChatOpenAI-Custom'
this.icon = 'openai.svg'
this.category = 'Chat Models'
@@ -53,6 +53,14 @@ class ChatOpenAICustom_ChatModels implements INode {
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Max Tokens',
name: 'maxTokens',
@@ -18,7 +18,7 @@ class ChatTogetherAI_ChatModels implements INode {
constructor() {
this.label = 'ChatTogetherAI'
this.name = 'chatTogetherAI'
this.version = 1.0
this.version = 2.0
this.type = 'ChatTogetherAI'
this.icon = 'togetherai.png'
this.category = 'Chat Models'
@@ -51,6 +51,13 @@ class ChatTogetherAI_ChatModels implements INode {
step: 0.1,
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true
}
]
}
@@ -0,0 +1,105 @@
import { BaseCache } from '@langchain/core/caches'
import { ChatXAI, ChatXAIInput } from '@langchain/xai'
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
class ChatXAI_ChatModels implements INode {
label: string
name: string
version: number
type: string
icon: string
category: string
description: string
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]
constructor() {
this.label = 'ChatXAI'
this.name = 'chatXAI'
this.version = 1.0
this.type = 'ChatXAI'
this.icon = 'xai.png'
this.category = 'Chat Models'
this.description = 'Wrapper around Grok from XAI'
this.baseClasses = [this.type, ...getBaseClasses(ChatXAI)]
this.credential = {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['xaiApi']
}
this.inputs = [
{
label: 'Cache',
name: 'cache',
type: 'BaseCache',
optional: true
},
{
label: 'Model',
name: 'modelName',
type: 'string',
placeholder: 'grok-beta'
},
{
label: 'Temperature',
name: 'temperature',
type: 'number',
step: 0.1,
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true,
additionalParams: true
},
{
label: 'Max Tokens',
name: 'maxTokens',
type: 'number',
step: 1,
optional: true,
additionalParams: true
},
{
label: 'Max Tokens',
name: 'maxTokens',
type: 'number',
step: 1,
optional: true,
additionalParams: true
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const cache = nodeData.inputs?.cache as BaseCache
const temperature = nodeData.inputs?.temperature as string
const modelName = nodeData.inputs?.modelName as string
const maxTokens = nodeData.inputs?.maxTokens as string
const streaming = nodeData.inputs?.streaming as boolean
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const xaiApiKey = getCredentialParam('xaiApiKey', credentialData, nodeData)
const obj: ChatXAIInput = {
apiKey: xaiApiKey,
streaming: streaming ?? true,
model: modelName,
temperature: temperature ? parseFloat(temperature) : undefined
}
if (cache) obj.cache = cache
if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10)
const model = new ChatXAI(obj)
return model
}
}
module.exports = { nodeClass: ChatXAI_ChatModels }
Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

@@ -19,7 +19,7 @@ class Groq_ChatModels implements INode {
constructor() {
this.label = 'GroqChat'
this.name = 'groqChat'
this.version = 3.0
this.version = 4.0
this.type = 'GroqChat'
this.icon = 'groq.png'
this.category = 'Chat Models'
@@ -53,6 +53,13 @@ class Groq_ChatModels implements INode {
step: 0.1,
default: 0.9,
optional: true
},
{
label: 'Streaming',
name: 'streaming',
type: 'boolean',
default: true,
optional: true
}
]
}