mirror of
https://github.com/FlowiseAI/Flowise.git
synced 2026-10-12 02:02:17 +00:00
fix: check deny list in for certain chat models (#6589)
* fix: check deny list in for certain chat models * Update packages/components/nodes/chatmodels/ChatOllama/ChatOllama.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * Update packages/components/nodes/chatmodels/ChatCloudflareWorkersAI/ChatCloudflareWorkersAI.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * fix: review feedback --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
gemini-code-assist[bot]
parent
6c989ec860
commit
b98ff81b04
+2
@@ -1,6 +1,7 @@
|
||||
import { ChatCloudflareWorkersAI, type CloudflareWorkersAIInput } from '@langchain/cloudflare'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { checkDenyList } from '../../../src/httpSecurity'
|
||||
|
||||
class ChatCloudflareWorkersAI_ChatModels implements INode {
|
||||
label: string
|
||||
@@ -70,6 +71,7 @@ class ChatCloudflareWorkersAI_ChatModels implements INode {
|
||||
}
|
||||
|
||||
if (baseUrl) {
|
||||
await checkDenyList(baseUrl)
|
||||
obj.baseUrl = baseUrl
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -6,6 +6,7 @@ import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../
|
||||
import { getModels, MODEL_TYPE } from '../../../src/modelLoader'
|
||||
import { GoogleGenerativeAIChatInput } from '@langchain/google-genai'
|
||||
import { ChatGoogleGenerativeAI } from './FlowiseChatGoogleGenerativeAI'
|
||||
import { checkDenyList } from '../../../src/httpSecurity'
|
||||
|
||||
class GoogleGenerativeAI_ChatModels implements INode {
|
||||
label: string
|
||||
@@ -275,7 +276,10 @@ class GoogleGenerativeAI_ChatModels implements INode {
|
||||
if (topK) obj.topK = parseFloat(topK)
|
||||
if (cache) obj.cache = cache
|
||||
if (temperature) obj.temperature = parseFloat(temperature)
|
||||
if (baseUrl) obj.baseUrl = baseUrl
|
||||
if (baseUrl) {
|
||||
await checkDenyList(baseUrl)
|
||||
obj.baseUrl = baseUrl
|
||||
}
|
||||
if (thinkingLevel) {
|
||||
obj.thinkingConfig = {
|
||||
thinkingLevel: thinkingLevel,
|
||||
|
||||
@@ -4,6 +4,7 @@ import { BaseLLMParams } from '@langchain/core/language_models/llms'
|
||||
import { ICommonObject, IMultiModalOption, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { ChatOpenAI } from '../ChatOpenAI/FlowiseChatOpenAI'
|
||||
import { checkDenyList } from '../../../src/httpSecurity'
|
||||
|
||||
class ChatLitellm_ChatModels implements INode {
|
||||
label: string
|
||||
@@ -126,6 +127,7 @@ class ChatLitellm_ChatModels implements INode {
|
||||
}
|
||||
|
||||
if (basePath) {
|
||||
await checkDenyList(basePath)
|
||||
obj.configuration = {
|
||||
baseURL: basePath
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { ChatOpenAI, ChatOpenAIFields } from '@langchain/openai'
|
||||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { checkDenyList } from '../../../src/httpSecurity'
|
||||
|
||||
class ChatLocalAI_ChatModels implements INode {
|
||||
label: string
|
||||
@@ -123,7 +124,10 @@ class ChatLocalAI_ChatModels implements INode {
|
||||
obj.openAIApiKey = localAIApiKey
|
||||
obj.apiKey = localAIApiKey
|
||||
}
|
||||
if (basePath) obj.configuration = { baseURL: basePath }
|
||||
if (basePath) {
|
||||
await checkDenyList(basePath)
|
||||
obj.configuration = { baseURL: basePath }
|
||||
}
|
||||
|
||||
const model = new ChatOpenAI(obj)
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import { CallbackManager, CallbackManagerForLLMRun } from '@langchain/core/callb
|
||||
import { ChatResult } from '@langchain/core/outputs'
|
||||
import { FailedAttemptHandler } from '@langchain/core/utils/async_caller'
|
||||
import { getBaseClasses, INode, INodeData, INodeParams } from '../../../src'
|
||||
import { checkDenyList } from '../../../src/httpSecurity'
|
||||
|
||||
export interface ChatNemoGuardrailsCallOptions extends BaseChatModelCallOptions {
|
||||
/**
|
||||
@@ -109,6 +110,7 @@ class ChatNemoGuardrailsChatModel implements INode {
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const configurationId = nodeData.inputs?.configurationId
|
||||
const baseUrl = nodeData.inputs?.baseUrl
|
||||
if (baseUrl) await checkDenyList(baseUrl)
|
||||
const obj: Partial<ChatNemoGuardrailsInput> = {
|
||||
configurationId: configurationId,
|
||||
baseUrl: baseUrl
|
||||
|
||||
@@ -2,6 +2,7 @@ import { BaseCache } from '@langchain/core/caches'
|
||||
import { ChatOpenAI, ChatOpenAIFields } from '@langchain/openai'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { checkDenyList } from '../../../src/httpSecurity'
|
||||
|
||||
class ChatNvdiaNIM_ChatModels implements INode {
|
||||
label: string
|
||||
@@ -158,6 +159,8 @@ class ChatNvdiaNIM_ChatModels implements INode {
|
||||
}
|
||||
}
|
||||
|
||||
if (basePath) await checkDenyList(basePath)
|
||||
|
||||
if (basePath || parsedBaseOptions) {
|
||||
obj.configuration = {
|
||||
baseURL: basePath,
|
||||
|
||||
@@ -4,6 +4,7 @@ import { BaseCache } from '@langchain/core/caches'
|
||||
import { ICommonObject, IMultiModalOption, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { ChatOllama } from './FlowiseChatOllama'
|
||||
import { checkDenyList } from '../../../src/httpSecurity'
|
||||
|
||||
class ChatOllama_ChatModels implements INode {
|
||||
label: string
|
||||
@@ -252,8 +253,11 @@ class ChatOllama_ChatModels implements INode {
|
||||
|
||||
const cache = nodeData.inputs?.cache as BaseCache
|
||||
|
||||
const activeBaseUrl = baseUrl || 'http://localhost:11434'
|
||||
await checkDenyList(activeBaseUrl)
|
||||
|
||||
const obj: ChatOllamaInput & BaseChatModelParams = {
|
||||
baseUrl,
|
||||
baseUrl: activeBaseUrl,
|
||||
temperature: parseFloat(temperature),
|
||||
model: modelName,
|
||||
streaming: streaming ?? true
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { OllamaParams, Ollama } from 'llamaindex'
|
||||
import { checkDenyList } from '../../../src/httpSecurity'
|
||||
|
||||
class ChatOllama_LlamaIndex_ChatModels implements INode {
|
||||
label: string
|
||||
@@ -192,6 +193,8 @@ class ChatOllama_LlamaIndex_ChatModels implements INode {
|
||||
const stop = nodeData.inputs?.stop as string
|
||||
const tfsZ = nodeData.inputs?.tfsZ as string
|
||||
|
||||
if (baseUrl) await checkDenyList(baseUrl)
|
||||
|
||||
const obj: OllamaParams = {
|
||||
model: modelName,
|
||||
options: {},
|
||||
|
||||
@@ -2,6 +2,7 @@ import { ChatOpenAI, ChatOpenAIFields } from '@langchain/openai'
|
||||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { checkDenyList } from '../../../src/httpSecurity'
|
||||
|
||||
class ChatOpenAICustom_ChatModels implements INode {
|
||||
label: string
|
||||
@@ -160,6 +161,8 @@ class ChatOpenAICustom_ChatModels implements INode {
|
||||
}
|
||||
}
|
||||
|
||||
if (basePath) await checkDenyList(basePath)
|
||||
|
||||
if (basePath || parsedBaseOptions) {
|
||||
obj.configuration = {
|
||||
baseURL: basePath,
|
||||
|
||||
Reference in New Issue
Block a user