Merge branch 'main' into FEATURE/Vision
# Conflicts: # packages/server/src/database/migrations/mysql/index.ts # packages/server/src/database/migrations/postgres/index.ts # packages/server/src/database/migrations/sqlite/index.ts
|
|
@ -138,6 +138,7 @@ Flowise support different environment variables to configure your instance. You
|
|||
| DATABASE_USER | Database username (When DATABASE_TYPE is not sqlite) | String | |
|
||||
| DATABASE_PASSWORD | Database password (When DATABASE_TYPE is not sqlite) | String | |
|
||||
| DATABASE_NAME | Database name (When DATABASE_TYPE is not sqlite) | String | |
|
||||
| DATABASE_SSL | Database connection overssl (When DATABASE_TYPE is postgre) | Boolean | false |
|
||||
| SECRETKEY_PATH | Location where encryption key (used to encrypt/decrypt credentials) is saved | String | `your-path/Flowise/packages/server` |
|
||||
| FLOWISE_SECRETKEY_OVERWRITE | Encryption key to be used instead of the key stored in SECRETKEY_PATH | String |
|
||||
|
||||
|
|
|
|||
16
LICENSE.md
|
|
@ -2,22 +2,6 @@
|
|||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
Flowise is governed by the Apache License 2.0, with additional terms and conditions outlined below:
|
||||
|
||||
Flowise can be used for commercial purposes for "backend-as-a-service" for your applications or as a development platform for enterprises. However, under specific conditions, you must reach out to the project's administrators to secure a commercial license:
|
||||
|
||||
a. Multi-tenant SaaS service: Unless you have explicit written authorization from Flowise, you may not utilize the Flowise source code to operate a multi-tenant SaaS service that closely resembles the Flowise cloud-based services.
|
||||
b. Logo and copyright information: While using Flowise in commercial application, you are prohibited from removing or altering the LOGO or copyright information displayed in the Flowise console and UI.
|
||||
|
||||
For inquiries regarding licensing matters, please contact hello@flowiseai.com via email.
|
||||
|
||||
Contributors are required to consent to the following terms related to their contributed code:
|
||||
|
||||
a. The project maintainers have the authority to modify the open-source agreement to be more stringent or lenient.
|
||||
b. Contributed code can be used for commercial purposes, including Flowise's cloud-based services.
|
||||
|
||||
All other rights and restrictions are in accordance with the Apache License 2.0.
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ LOG_PATH=/root/.flowise/logs
|
|||
# DATABASE_NAME="flowise"
|
||||
# DATABASE_USER=""
|
||||
# DATABASE_PASSWORD=""
|
||||
# DATABASE_SSL=true
|
||||
|
||||
# FLOWISE_USERNAME=user
|
||||
# FLOWISE_PASSWORD=1234
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ services:
|
|||
- DATABASE_NAME=${DATABASE_NAME}
|
||||
- DATABASE_USER=${DATABASE_USER}
|
||||
- DATABASE_PASSWORD=${DATABASE_PASSWORD}
|
||||
- DATABASE_SSL=${DATABASE_SSL}
|
||||
- APIKEY_PATH=${APIKEY_PATH}
|
||||
- SECRETKEY_PATH=${SECRETKEY_PATH}
|
||||
- FLOWISE_SECRETKEY_OVERWRITE=${FLOWISE_SECRETKEY_OVERWRITE}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "flowise",
|
||||
"version": "1.4.7",
|
||||
"version": "1.4.9",
|
||||
"private": true,
|
||||
"homepage": "https://flowiseai.com",
|
||||
"workspaces": [
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import fetch from 'node-fetch'
|
|||
import { flatten, uniqWith, isEqual } from 'lodash'
|
||||
import { zodToJsonSchema } from 'zod-to-json-schema'
|
||||
import { AnalyticHandler } from '../../../src/handler'
|
||||
import { Moderation, checkInputs, streamResponse } from '../../moderation/Moderation'
|
||||
import { formatResponse } from '../../outputparsers/OutputParserHelpers'
|
||||
|
||||
class OpenAIAssistant_Agents implements INode {
|
||||
label: string
|
||||
|
|
@ -24,7 +26,7 @@ class OpenAIAssistant_Agents implements INode {
|
|||
constructor() {
|
||||
this.label = 'OpenAI Assistant'
|
||||
this.name = 'openAIAssistant'
|
||||
this.version = 2.0
|
||||
this.version = 3.0
|
||||
this.type = 'OpenAIAssistant'
|
||||
this.category = 'Agents'
|
||||
this.icon = 'assistant.svg'
|
||||
|
|
@ -43,6 +45,14 @@ class OpenAIAssistant_Agents implements INode {
|
|||
type: 'Tool',
|
||||
list: true
|
||||
},
|
||||
{
|
||||
label: 'Input Moderation',
|
||||
description: 'Detect text that could generate harmful output and prevent it from being sent to the language model',
|
||||
name: 'inputModeration',
|
||||
type: 'Moderation',
|
||||
optional: true,
|
||||
list: true
|
||||
},
|
||||
{
|
||||
label: 'Disable File Download',
|
||||
name: 'disableFileDownload',
|
||||
|
|
@ -133,6 +143,20 @@ class OpenAIAssistant_Agents implements INode {
|
|||
const appDataSource = options.appDataSource as DataSource
|
||||
const databaseEntities = options.databaseEntities as IDatabaseEntity
|
||||
const disableFileDownload = nodeData.inputs?.disableFileDownload as boolean
|
||||
const moderations = nodeData.inputs?.inputModeration as Moderation[]
|
||||
const isStreaming = options.socketIO && options.socketIOClientId
|
||||
const socketIO = isStreaming ? options.socketIO : undefined
|
||||
const socketIOClientId = isStreaming ? options.socketIOClientId : ''
|
||||
|
||||
if (moderations && moderations.length > 0) {
|
||||
try {
|
||||
input = await checkInputs(moderations, input)
|
||||
} catch (e) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 500))
|
||||
streamResponse(isStreaming, e.message, socketIO, socketIOClientId)
|
||||
return formatResponse(e.message)
|
||||
}
|
||||
}
|
||||
|
||||
let tools = nodeData.inputs?.tools
|
||||
tools = flatten(tools)
|
||||
|
|
@ -249,7 +273,12 @@ class OpenAIAssistant_Agents implements INode {
|
|||
const actions: ICommonObject[] = []
|
||||
run.required_action.submit_tool_outputs.tool_calls.forEach((item) => {
|
||||
const functionCall = item.function
|
||||
const args = JSON.parse(functionCall.arguments)
|
||||
let args = {}
|
||||
try {
|
||||
args = JSON.parse(functionCall.arguments)
|
||||
} catch (e) {
|
||||
console.error('Error parsing arguments, default to empty object')
|
||||
}
|
||||
actions.push({
|
||||
tool: functionCall.name,
|
||||
toolInput: args,
|
||||
|
|
@ -264,31 +293,50 @@ class OpenAIAssistant_Agents implements INode {
|
|||
|
||||
// Start tool analytics
|
||||
const toolIds = await analyticHandlers.onToolStart(tool.name, actions[i].toolInput, parentIds)
|
||||
if (options.socketIO && options.socketIOClientId)
|
||||
options.socketIO.to(options.socketIOClientId).emit('tool', tool.name)
|
||||
|
||||
const toolOutput = await tool.call(actions[i].toolInput)
|
||||
|
||||
// End tool analytics
|
||||
await analyticHandlers.onToolEnd(toolIds, toolOutput)
|
||||
|
||||
submitToolOutputs.push({
|
||||
tool_call_id: actions[i].toolCallId,
|
||||
output: toolOutput
|
||||
})
|
||||
usedTools.push({
|
||||
tool: tool.name,
|
||||
toolInput: actions[i].toolInput,
|
||||
toolOutput
|
||||
})
|
||||
try {
|
||||
const toolOutput = await tool.call(actions[i].toolInput, undefined, undefined, threadId)
|
||||
await analyticHandlers.onToolEnd(toolIds, toolOutput)
|
||||
submitToolOutputs.push({
|
||||
tool_call_id: actions[i].toolCallId,
|
||||
output: toolOutput
|
||||
})
|
||||
usedTools.push({
|
||||
tool: tool.name,
|
||||
toolInput: actions[i].toolInput,
|
||||
toolOutput
|
||||
})
|
||||
} catch (e) {
|
||||
await analyticHandlers.onToolEnd(toolIds, e)
|
||||
console.error('Error executing tool', e)
|
||||
clearInterval(timeout)
|
||||
reject(
|
||||
new Error(
|
||||
`Error processing thread: ${state}, Thread ID: ${threadId}, Run ID: ${runId}, Tool: ${tool.name}`
|
||||
)
|
||||
)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (submitToolOutputs.length) {
|
||||
await openai.beta.threads.runs.submitToolOutputs(threadId, runId, {
|
||||
tool_outputs: submitToolOutputs
|
||||
})
|
||||
resolve(state)
|
||||
} else {
|
||||
await openai.beta.threads.runs.cancel(threadId, runId)
|
||||
resolve('requires_action_retry')
|
||||
const newRun = await openai.beta.threads.runs.retrieve(threadId, runId)
|
||||
const newStatus = newRun?.status
|
||||
|
||||
try {
|
||||
if (submitToolOutputs.length && newStatus === 'requires_action') {
|
||||
await openai.beta.threads.runs.submitToolOutputs(threadId, runId, {
|
||||
tool_outputs: submitToolOutputs
|
||||
})
|
||||
resolve(state)
|
||||
} else {
|
||||
await openai.beta.threads.runs.cancel(threadId, runId)
|
||||
resolve('requires_action_retry')
|
||||
}
|
||||
} catch (e) {
|
||||
clearInterval(timeout)
|
||||
reject(new Error(`Error submitting tool outputs: ${state}, Thread ID: ${threadId}, Run ID: ${runId}`))
|
||||
}
|
||||
}
|
||||
} else if (state === 'cancelled' || state === 'expired' || state === 'failed') {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,17 @@
|
|||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { initializeAgentExecutorWithOptions, AgentExecutor } from 'langchain/agents'
|
||||
import { getBaseClasses, mapChatHistory } from '../../../src/utils'
|
||||
import { BaseLanguageModel } from 'langchain/base_language'
|
||||
import { FlowiseMemory, ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { AgentExecutor as LCAgentExecutor, AgentExecutorInput } from 'langchain/agents'
|
||||
import { ChainValues, AgentStep, AgentFinish, AgentAction, BaseMessage, FunctionMessage, AIMessage } from 'langchain/schema'
|
||||
import { OutputParserException } from 'langchain/schema/output_parser'
|
||||
import { CallbackManagerForChainRun } from 'langchain/callbacks'
|
||||
import { formatToOpenAIFunction } from 'langchain/tools'
|
||||
import { ToolInputParsingException, Tool } from '@langchain/core/tools'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { flatten } from 'lodash'
|
||||
import { BaseChatMemory } from 'langchain/memory'
|
||||
import { RunnableSequence } from 'langchain/schema/runnable'
|
||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||
import { ChatPromptTemplate, MessagesPlaceholder } from 'langchain/prompts'
|
||||
import { ChatOpenAI } from 'langchain/chat_models/openai'
|
||||
import { OpenAIFunctionsAgentOutputParser } from 'langchain/agents/openai/output_parser'
|
||||
|
||||
class OpenAIFunctionAgent_Agents implements INode {
|
||||
label: string
|
||||
|
|
@ -16,8 +23,9 @@ class OpenAIFunctionAgent_Agents implements INode {
|
|||
category: string
|
||||
baseClasses: string[]
|
||||
inputs: INodeParams[]
|
||||
sessionId?: string
|
||||
|
||||
constructor() {
|
||||
constructor(fields: { sessionId?: string }) {
|
||||
this.label = 'OpenAI Function Agent'
|
||||
this.name = 'openAIFunctionAgent'
|
||||
this.version = 3.0
|
||||
|
|
@ -25,7 +33,7 @@ class OpenAIFunctionAgent_Agents implements INode {
|
|||
this.category = 'Agents'
|
||||
this.icon = 'function.svg'
|
||||
this.description = `An agent that uses Function Calling to pick the tool and args to call`
|
||||
this.baseClasses = [this.type, ...getBaseClasses(AgentExecutor)]
|
||||
this.baseClasses = [this.type, ...getBaseClasses(LCAgentExecutor)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Allowed Tools',
|
||||
|
|
@ -52,54 +60,324 @@ class OpenAIFunctionAgent_Agents implements INode {
|
|||
additionalParams: true
|
||||
}
|
||||
]
|
||||
this.sessionId = fields?.sessionId
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const model = nodeData.inputs?.model as BaseLanguageModel
|
||||
const memory = nodeData.inputs?.memory as BaseChatMemory
|
||||
const systemMessage = nodeData.inputs?.systemMessage as string
|
||||
const memory = nodeData.inputs?.memory as FlowiseMemory
|
||||
|
||||
let tools = nodeData.inputs?.tools
|
||||
tools = flatten(tools)
|
||||
|
||||
const executor = await initializeAgentExecutorWithOptions(tools, model, {
|
||||
agentType: 'openai-functions',
|
||||
verbose: process.env.DEBUG === 'true' ? true : false,
|
||||
agentArgs: {
|
||||
prefix: systemMessage ?? `You are a helpful AI assistant.`
|
||||
}
|
||||
})
|
||||
const executor = prepareAgent(nodeData, this.sessionId)
|
||||
if (memory) executor.memory = memory
|
||||
|
||||
return executor
|
||||
}
|
||||
|
||||
async run(nodeData: INodeData, input: string, options: ICommonObject): Promise<string> {
|
||||
const executor = nodeData.instance as AgentExecutor
|
||||
const memory = nodeData.inputs?.memory as BaseChatMemory
|
||||
const memory = nodeData.inputs?.memory as FlowiseMemory
|
||||
|
||||
if (options && options.chatHistory) {
|
||||
const chatHistoryClassName = memory.chatHistory.constructor.name
|
||||
// Only replace when its In-Memory
|
||||
if (chatHistoryClassName && chatHistoryClassName === 'ChatMessageHistory') {
|
||||
memory.chatHistory = mapChatHistory(options)
|
||||
executor.memory = memory
|
||||
}
|
||||
}
|
||||
|
||||
;(executor.memory as any).returnMessages = true // Return true for BaseChatModel
|
||||
const executor = prepareAgent(nodeData, this.sessionId)
|
||||
|
||||
const loggerHandler = new ConsoleCallbackHandler(options.logger)
|
||||
const callbacks = await additionalCallbacks(nodeData, options)
|
||||
|
||||
let res: ChainValues = {}
|
||||
|
||||
if (options.socketIO && options.socketIOClientId) {
|
||||
const handler = new CustomChainHandler(options.socketIO, options.socketIOClientId)
|
||||
const result = await executor.run(input, [loggerHandler, handler, ...callbacks])
|
||||
return result
|
||||
res = await executor.invoke({ input }, { callbacks: [loggerHandler, handler, ...callbacks] })
|
||||
} else {
|
||||
const result = await executor.run(input, [loggerHandler, ...callbacks])
|
||||
return result
|
||||
res = await executor.invoke({ input }, { callbacks: [loggerHandler, ...callbacks] })
|
||||
}
|
||||
|
||||
await memory.addChatMessages(
|
||||
[
|
||||
{
|
||||
text: input,
|
||||
type: 'userMessage'
|
||||
},
|
||||
{
|
||||
text: res?.output,
|
||||
type: 'apiMessage'
|
||||
}
|
||||
],
|
||||
this.sessionId
|
||||
)
|
||||
|
||||
return res?.output
|
||||
}
|
||||
}
|
||||
|
||||
const formatAgentSteps = (steps: AgentStep[]): BaseMessage[] =>
|
||||
steps.flatMap(({ action, observation }) => {
|
||||
if ('messageLog' in action && action.messageLog !== undefined) {
|
||||
const log = action.messageLog as BaseMessage[]
|
||||
return log.concat(new FunctionMessage(observation, action.tool))
|
||||
} else {
|
||||
return [new AIMessage(action.log)]
|
||||
}
|
||||
})
|
||||
|
||||
const prepareAgent = (nodeData: INodeData, sessionId?: string) => {
|
||||
const model = nodeData.inputs?.model as ChatOpenAI
|
||||
const memory = nodeData.inputs?.memory as FlowiseMemory
|
||||
const systemMessage = nodeData.inputs?.systemMessage as string
|
||||
let tools = nodeData.inputs?.tools
|
||||
tools = flatten(tools)
|
||||
const memoryKey = memory.memoryKey ? memory.memoryKey : 'chat_history'
|
||||
const inputKey = memory.inputKey ? memory.inputKey : 'input'
|
||||
|
||||
const prompt = ChatPromptTemplate.fromMessages([
|
||||
['ai', systemMessage ? systemMessage : `You are a helpful AI assistant.`],
|
||||
new MessagesPlaceholder(memoryKey),
|
||||
['human', `{${inputKey}}`],
|
||||
new MessagesPlaceholder('agent_scratchpad')
|
||||
])
|
||||
|
||||
const modelWithFunctions = model.bind({
|
||||
functions: [...tools.map((tool: any) => formatToOpenAIFunction(tool))]
|
||||
})
|
||||
|
||||
const runnableAgent = RunnableSequence.from([
|
||||
{
|
||||
[inputKey]: (i: { input: string; steps: AgentStep[] }) => i.input,
|
||||
agent_scratchpad: (i: { input: string; steps: AgentStep[] }) => formatAgentSteps(i.steps),
|
||||
[memoryKey]: async (_: { input: string; steps: AgentStep[] }) => {
|
||||
const messages = (await memory.getChatMessages(sessionId, true)) as BaseMessage[]
|
||||
return messages ?? []
|
||||
}
|
||||
},
|
||||
prompt,
|
||||
modelWithFunctions,
|
||||
new OpenAIFunctionsAgentOutputParser()
|
||||
])
|
||||
|
||||
const executor = AgentExecutor.fromAgentAndTools({
|
||||
agent: runnableAgent,
|
||||
tools,
|
||||
sessionId
|
||||
})
|
||||
|
||||
return executor
|
||||
}
|
||||
|
||||
type AgentExecutorOutput = ChainValues
|
||||
|
||||
class AgentExecutor extends LCAgentExecutor {
|
||||
sessionId?: string
|
||||
|
||||
static fromAgentAndTools(fields: AgentExecutorInput & { sessionId?: string }): AgentExecutor {
|
||||
const newInstance = new AgentExecutor(fields)
|
||||
if (fields.sessionId) newInstance.sessionId = fields.sessionId
|
||||
return newInstance
|
||||
}
|
||||
|
||||
shouldContinueIteration(iterations: number): boolean {
|
||||
return this.maxIterations === undefined || iterations < this.maxIterations
|
||||
}
|
||||
|
||||
async _call(inputs: ChainValues, runManager?: CallbackManagerForChainRun): Promise<AgentExecutorOutput> {
|
||||
const toolsByName = Object.fromEntries(this.tools.map((t) => [t.name.toLowerCase(), t]))
|
||||
|
||||
const steps: AgentStep[] = []
|
||||
let iterations = 0
|
||||
|
||||
const getOutput = async (finishStep: AgentFinish): Promise<AgentExecutorOutput> => {
|
||||
const { returnValues } = finishStep
|
||||
const additional = await this.agent.prepareForOutput(returnValues, steps)
|
||||
|
||||
if (this.returnIntermediateSteps) {
|
||||
return { ...returnValues, intermediateSteps: steps, ...additional }
|
||||
}
|
||||
await runManager?.handleAgentEnd(finishStep)
|
||||
return { ...returnValues, ...additional }
|
||||
}
|
||||
|
||||
while (this.shouldContinueIteration(iterations)) {
|
||||
let output
|
||||
try {
|
||||
output = await this.agent.plan(steps, inputs, runManager?.getChild())
|
||||
} catch (e) {
|
||||
if (e instanceof OutputParserException) {
|
||||
let observation
|
||||
let text = e.message
|
||||
if (this.handleParsingErrors === true) {
|
||||
if (e.sendToLLM) {
|
||||
observation = e.observation
|
||||
text = e.llmOutput ?? ''
|
||||
} else {
|
||||
observation = 'Invalid or incomplete response'
|
||||
}
|
||||
} else if (typeof this.handleParsingErrors === 'string') {
|
||||
observation = this.handleParsingErrors
|
||||
} else if (typeof this.handleParsingErrors === 'function') {
|
||||
observation = this.handleParsingErrors(e)
|
||||
} else {
|
||||
throw e
|
||||
}
|
||||
output = {
|
||||
tool: '_Exception',
|
||||
toolInput: observation,
|
||||
log: text
|
||||
} as AgentAction
|
||||
} else {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
// Check if the agent has finished
|
||||
if ('returnValues' in output) {
|
||||
return getOutput(output)
|
||||
}
|
||||
|
||||
let actions: AgentAction[]
|
||||
if (Array.isArray(output)) {
|
||||
actions = output as AgentAction[]
|
||||
} else {
|
||||
actions = [output as AgentAction]
|
||||
}
|
||||
|
||||
const newSteps = await Promise.all(
|
||||
actions.map(async (action) => {
|
||||
await runManager?.handleAgentAction(action)
|
||||
const tool = action.tool === '_Exception' ? new ExceptionTool() : toolsByName[action.tool?.toLowerCase()]
|
||||
let observation
|
||||
try {
|
||||
// here we need to override Tool call method to include sessionId as parameter
|
||||
observation = tool
|
||||
? // @ts-ignore
|
||||
await tool.call(action.toolInput, runManager?.getChild(), undefined, this.sessionId)
|
||||
: `${action.tool} is not a valid tool, try another one.`
|
||||
} catch (e) {
|
||||
if (e instanceof ToolInputParsingException) {
|
||||
if (this.handleParsingErrors === true) {
|
||||
observation = 'Invalid or incomplete tool input. Please try again.'
|
||||
} else if (typeof this.handleParsingErrors === 'string') {
|
||||
observation = this.handleParsingErrors
|
||||
} else if (typeof this.handleParsingErrors === 'function') {
|
||||
observation = this.handleParsingErrors(e)
|
||||
} else {
|
||||
throw e
|
||||
}
|
||||
observation = await new ExceptionTool().call(observation, runManager?.getChild())
|
||||
return { action, observation: observation ?? '' }
|
||||
}
|
||||
}
|
||||
return { action, observation: observation ?? '' }
|
||||
})
|
||||
)
|
||||
|
||||
steps.push(...newSteps)
|
||||
|
||||
const lastStep = steps[steps.length - 1]
|
||||
const lastTool = toolsByName[lastStep.action.tool?.toLowerCase()]
|
||||
|
||||
if (lastTool?.returnDirect) {
|
||||
return getOutput({
|
||||
returnValues: { [this.agent.returnValues[0]]: lastStep.observation },
|
||||
log: ''
|
||||
})
|
||||
}
|
||||
|
||||
iterations += 1
|
||||
}
|
||||
|
||||
const finish = await this.agent.returnStoppedResponse(this.earlyStoppingMethod, steps, inputs)
|
||||
|
||||
return getOutput(finish)
|
||||
}
|
||||
|
||||
async _takeNextStep(
|
||||
nameToolMap: Record<string, Tool>,
|
||||
inputs: ChainValues,
|
||||
intermediateSteps: AgentStep[],
|
||||
runManager?: CallbackManagerForChainRun
|
||||
): Promise<AgentFinish | AgentStep[]> {
|
||||
let output
|
||||
try {
|
||||
output = await this.agent.plan(intermediateSteps, inputs, runManager?.getChild())
|
||||
} catch (e) {
|
||||
if (e instanceof OutputParserException) {
|
||||
let observation
|
||||
let text = e.message
|
||||
if (this.handleParsingErrors === true) {
|
||||
if (e.sendToLLM) {
|
||||
observation = e.observation
|
||||
text = e.llmOutput ?? ''
|
||||
} else {
|
||||
observation = 'Invalid or incomplete response'
|
||||
}
|
||||
} else if (typeof this.handleParsingErrors === 'string') {
|
||||
observation = this.handleParsingErrors
|
||||
} else if (typeof this.handleParsingErrors === 'function') {
|
||||
observation = this.handleParsingErrors(e)
|
||||
} else {
|
||||
throw e
|
||||
}
|
||||
output = {
|
||||
tool: '_Exception',
|
||||
toolInput: observation,
|
||||
log: text
|
||||
} as AgentAction
|
||||
} else {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
if ('returnValues' in output) {
|
||||
return output
|
||||
}
|
||||
|
||||
let actions: AgentAction[]
|
||||
if (Array.isArray(output)) {
|
||||
actions = output as AgentAction[]
|
||||
} else {
|
||||
actions = [output as AgentAction]
|
||||
}
|
||||
|
||||
const result: AgentStep[] = []
|
||||
for (const agentAction of actions) {
|
||||
let observation = ''
|
||||
if (runManager) {
|
||||
await runManager?.handleAgentAction(agentAction)
|
||||
}
|
||||
if (agentAction.tool in nameToolMap) {
|
||||
const tool = nameToolMap[agentAction.tool]
|
||||
try {
|
||||
// here we need to override Tool call method to include sessionId as parameter
|
||||
// @ts-ignore
|
||||
observation = await tool.call(agentAction.toolInput, runManager?.getChild(), undefined, this.sessionId)
|
||||
} catch (e) {
|
||||
if (e instanceof ToolInputParsingException) {
|
||||
if (this.handleParsingErrors === true) {
|
||||
observation = 'Invalid or incomplete tool input. Please try again.'
|
||||
} else if (typeof this.handleParsingErrors === 'string') {
|
||||
observation = this.handleParsingErrors
|
||||
} else if (typeof this.handleParsingErrors === 'function') {
|
||||
observation = this.handleParsingErrors(e)
|
||||
} else {
|
||||
throw e
|
||||
}
|
||||
observation = await new ExceptionTool().call(observation, runManager?.getChild())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
observation = `${agentAction.tool} is not a valid tool, try another available tool: ${Object.keys(nameToolMap).join(', ')}`
|
||||
}
|
||||
result.push({
|
||||
action: agentAction,
|
||||
observation
|
||||
})
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
class ExceptionTool extends Tool {
|
||||
name = '_Exception'
|
||||
|
||||
description = 'Exception tool'
|
||||
|
||||
async _call(query: string) {
|
||||
return query
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1 @@
|
|||
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M9.95804 14.1159C9.95804 14.4567 9.99488 14.733 10.0594 14.9357C10.133 15.1383 10.2251 15.3593 10.3541 15.5988C10.4001 15.6725 10.4186 15.7462 10.4186 15.8107C10.4186 15.9028 10.3633 15.9949 10.2436 16.087L9.6633 16.4738C9.58041 16.5291 9.49751 16.5567 9.42383 16.5567C9.33172 16.5567 9.23962 16.5107 9.14751 16.4278C9.01857 16.2896 8.90804 16.1422 8.81593 15.9949C8.72383 15.8383 8.63172 15.6633 8.53041 15.4514C7.81199 16.2988 6.90935 16.7225 5.82251 16.7225C5.04883 16.7225 4.43172 16.5014 3.98041 16.0593C3.52909 15.6172 3.29883 15.0278 3.29883 14.2909C3.29883 13.508 3.57514 12.8725 4.13699 12.3935C4.69883 11.9146 5.44488 11.6751 6.39357 11.6751C6.70672 11.6751 7.02909 11.7028 7.36988 11.7488C7.71067 11.7949 8.06067 11.8685 8.42909 11.9514V11.2791C8.42909 10.5791 8.28172 10.0909 7.9962 9.80539C7.70146 9.51986 7.20409 9.3817 6.49488 9.3817C6.17251 9.3817 5.84093 9.41855 5.50014 9.50144C5.15935 9.58434 4.82778 9.68565 4.50541 9.8146C4.35804 9.87907 4.24751 9.91591 4.18304 9.93434C4.11857 9.95276 4.07251 9.96197 4.03567 9.96197C3.90672 9.96197 3.84225 9.86986 3.84225 9.67644V9.22512C3.84225 9.07776 3.86067 8.96723 3.90672 8.90276C3.95278 8.83828 4.03567 8.77381 4.16462 8.70934C4.48699 8.54355 4.87383 8.40539 5.32514 8.29486C5.77646 8.17512 6.25541 8.11986 6.76199 8.11986C7.85804 8.11986 8.65936 8.36855 9.17515 8.86591C9.68172 9.36328 9.93962 10.1185 9.93962 11.1317V14.1159H9.95804ZM6.21857 15.5159C6.52251 15.5159 6.83567 15.4607 7.16725 15.3501C7.49883 15.2396 7.79357 15.037 8.04225 14.7607C8.18962 14.5857 8.30014 14.3922 8.35541 14.1712C8.41067 13.9501 8.44751 13.683 8.44751 13.3699V12.983C8.18041 12.9185 7.89488 12.8633 7.60014 12.8264C7.30541 12.7896 7.01988 12.7712 6.73436 12.7712C6.11725 12.7712 5.66593 12.8909 5.36199 13.1396C5.05804 13.3883 4.91067 13.7383 4.91067 14.1988C4.91067 14.6317 5.0212 14.9541 5.25146 15.1751C5.47251 15.4054 5.79488 15.5159 6.21857 15.5159ZM13.6146 16.5107C13.4488 16.5107 13.3383 16.483 13.2646 16.4185C13.1909 16.3633 13.1265 16.2343 13.0712 16.0593L10.9067 8.9396C10.8515 8.75539 10.8238 8.63565 10.8238 8.57118C10.8238 8.42381 10.8975 8.34091 11.0449 8.34091H11.9475C12.1225 8.34091 12.2423 8.36855 12.3067 8.43302C12.3804 8.48828 12.4357 8.61723 12.4909 8.79223L14.0383 14.8896L15.4751 8.79223C15.5212 8.60802 15.5765 8.48828 15.6501 8.43302C15.7238 8.37776 15.8528 8.34091 16.0186 8.34091H16.7554C16.9304 8.34091 17.0501 8.36855 17.1238 8.43302C17.1975 8.48828 17.262 8.61723 17.2988 8.79223L18.7541 14.9633L20.3475 8.79223C20.4028 8.60802 20.4673 8.48828 20.5317 8.43302C20.6054 8.37776 20.7251 8.34091 20.8909 8.34091H21.7475C21.8949 8.34091 21.9778 8.4146 21.9778 8.57118C21.9778 8.61723 21.9686 8.66328 21.9594 8.71855C21.9501 8.77381 21.9317 8.84749 21.8949 8.94881L19.6751 16.0685C19.6199 16.2528 19.5554 16.3725 19.4817 16.4278C19.408 16.483 19.2883 16.5199 19.1317 16.5199H18.3396C18.1646 16.5199 18.0449 16.4922 17.9712 16.4278C17.8975 16.3633 17.833 16.2435 17.7962 16.0593L16.3686 10.1185L14.9501 16.0501C14.9041 16.2343 14.8488 16.3541 14.7751 16.4185C14.7015 16.483 14.5725 16.5107 14.4067 16.5107H13.6146ZM25.4501 16.7593C24.9712 16.7593 24.4923 16.7041 24.0317 16.5935C23.5712 16.483 23.212 16.3633 22.9725 16.2251C22.8251 16.1422 22.7238 16.0501 22.687 15.9672C22.6501 15.8843 22.6317 15.7922 22.6317 15.7093V15.2396C22.6317 15.0462 22.7054 14.9541 22.8436 14.9541C22.8988 14.9541 22.9541 14.9633 23.0094 14.9817C23.0646 15.0001 23.1475 15.037 23.2396 15.0738C23.5528 15.212 23.8936 15.3225 24.2528 15.3962C24.6212 15.4699 24.9804 15.5067 25.3488 15.5067C25.9291 15.5067 26.3804 15.4054 26.6936 15.2028C27.0067 15.0001 27.1725 14.7054 27.1725 14.3278C27.1725 14.0699 27.0896 13.858 26.9238 13.683C26.758 13.508 26.4449 13.3514 25.9936 13.2041L24.658 12.7896C23.9857 12.5778 23.4883 12.2646 23.1844 11.8501C22.8804 11.4449 22.7238 10.9935 22.7238 10.5146C22.7238 10.1278 22.8067 9.78697 22.9725 9.49223C23.1383 9.19749 23.3594 8.9396 23.6357 8.73697C23.912 8.52512 24.2251 8.36855 24.5936 8.25802C24.962 8.14749 25.3488 8.10144 25.7541 8.10144C25.9567 8.10144 26.1686 8.11065 26.3712 8.13828C26.583 8.16591 26.7765 8.20276 26.9699 8.2396C27.1541 8.28565 27.3291 8.3317 27.4949 8.38697C27.6607 8.44223 27.7896 8.49749 27.8817 8.55276C28.0107 8.62644 28.1028 8.70012 28.158 8.78302C28.2133 8.8567 28.2409 8.95802 28.2409 9.08697V9.51986C28.2409 9.71328 28.1673 9.8146 28.0291 9.8146C27.9554 9.8146 27.8357 9.77776 27.6791 9.70407C27.1541 9.4646 26.5646 9.34486 25.9107 9.34486C25.3857 9.34486 24.9712 9.42776 24.6857 9.60276C24.4001 9.77776 24.2528 10.0449 24.2528 10.4225C24.2528 10.6804 24.3449 10.9014 24.5291 11.0764C24.7133 11.2514 25.0541 11.4264 25.5423 11.583L26.8501 11.9975C27.5133 12.2093 27.9923 12.5041 28.2778 12.8817C28.5633 13.2593 28.7015 13.6922 28.7015 14.1712C28.7015 14.5672 28.6186 14.9264 28.462 15.2396C28.2962 15.5528 28.0751 15.8291 27.7896 16.0501C27.5041 16.2804 27.1633 16.4462 26.7673 16.5659C26.3528 16.6949 25.9199 16.7593 25.4501 16.7593Z" fill="#252F3E"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M27.191 21.2357C24.1607 23.4739 19.7581 24.662 15.9725 24.662C10.6673 24.662 5.88702 22.7002 2.27649 19.4397C1.99097 19.1818 2.24886 18.8318 2.58965 19.0344C6.49492 21.3002 11.312 22.6726 16.2949 22.6726C19.6568 22.6726 23.3502 21.9726 26.7489 20.5357C27.2554 20.3054 27.6883 20.8673 27.191 21.2357Z" fill="#FF9900"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M28.4527 19.7989C28.0659 19.3015 25.8922 19.5594 24.9067 19.6791C24.6119 19.716 24.5659 19.4581 24.833 19.2647C26.5645 18.0489 29.4106 18.3989 29.7422 18.8041C30.0738 19.2186 29.6501 22.0647 28.029 23.4278C27.7803 23.6397 27.5409 23.5291 27.6514 23.2528C28.0198 22.341 28.8396 20.287 28.4527 19.7989Z" fill="#FF9900"/>
|
||||
</svg>
|
||||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 21c1.67 1.77 5.491 3 9.757 3 2.788 0 5.386-.525 7.317-1.383L25 21.65" stroke="#F90" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="m23 20 3 1.074L25.4 24" stroke="#F90" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M24.564 9.44C23.677 8.76 21 8.633 21 10.796c0 2.396 4 .77 4 3.294 0 1.898-2.67 2.501-4 1.264M14 9v7l2-4 2 4V9" stroke="#252F3E" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M7.053 8.597H8.21a2.526 2.526 0 0 1 2.526 2.526v4.842" stroke="#252F3E" stroke-width="2" stroke-linecap="round"/><circle cx="8.632" cy="13.86" stroke="#252F3E" stroke-width="2" r="2.105"/></svg>
|
||||
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 753 B |
|
|
@ -1 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="96px" height="96px"><path fill="#035bda" d="M46 40L29.317 10.852 22.808 23.96 34.267 37.24 13 39.655zM13.092 18.182L2 36.896 11.442 35.947 28.033 5.678z"/></svg>
|
||||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M11.946 5H19l-7.322 22.216a1.15 1.15 0 0 1-.41.568c-.19.14-.42.216-.656.216H5.123a1.11 1.11 0 0 1-.513-.127 1.132 1.132 0 0 1-.4-.352 1.165 1.165 0 0 1-.151-1.038l6.822-20.7a1.15 1.15 0 0 1 .41-.567c.19-.14.42-.216.655-.216Z" fill="#0A5FAB"/><path d="M22.334 20H11.502c-.1 0-.2.031-.282.09a.52.52 0 0 0-.185.241.545.545 0 0 0 .125.576l6.96 6.786c.203.197.47.307.747.307H25l-2.666-8Z" fill="#0078D4"/><path d="M21.035 5.782a1.149 1.149 0 0 0-.415-.566A1.128 1.128 0 0 0 19.957 5H12c.238 0 .47.076.663.216.193.14.338.338.414.566l6.906 20.7a1.16 1.16 0 0 1-.558 1.391 1.12 1.12 0 0 1-.52.127h7.959a1.127 1.127 0 0 0 .923-.48 1.159 1.159 0 0 0 .153-1.038l-6.905-20.7Z" fill="#2C9DE3"/></svg>
|
||||
|
Before Width: | Height: | Size: 229 B After Width: | Height: | Size: 771 B |
|
|
@ -1,7 +1,6 @@
|
|||
import { OpenAIBaseInput } from 'langchain/dist/types/openai-types'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { AzureOpenAIInput, ChatOpenAI } from 'langchain/chat_models/openai'
|
||||
import { AzureOpenAIInput, ChatOpenAI, OpenAIChatInput } from 'langchain/chat_models/openai'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
import { BaseLLMParams } from 'langchain/llms/base'
|
||||
|
||||
|
|
@ -123,7 +122,7 @@ class AzureChatOpenAI_ChatModels implements INode {
|
|||
const azureOpenAIApiDeploymentName = getCredentialParam('azureOpenAIApiDeploymentName', credentialData, nodeData)
|
||||
const azureOpenAIApiVersion = getCredentialParam('azureOpenAIApiVersion', credentialData, nodeData)
|
||||
|
||||
const obj: Partial<AzureOpenAIInput> & BaseLLMParams & Partial<OpenAIBaseInput> = {
|
||||
const obj: Partial<AzureOpenAIInput> & BaseLLMParams & Partial<OpenAIChatInput> = {
|
||||
temperature: parseFloat(temperature),
|
||||
modelName,
|
||||
azureOpenAIApiKey,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class Bittensor_ChatModels implements INode {
|
|||
this.name = 'NIBittensorChatModel'
|
||||
this.version = 2.0
|
||||
this.type = 'BittensorChat'
|
||||
this.icon = 'logo.png'
|
||||
this.icon = 'NIBittensor.svg'
|
||||
this.category = 'Chat Models'
|
||||
this.description = 'Wrapper around Bittensor subnet 1 large language models'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(NIBittensorChatModel)]
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18.64 25.698V29H8l1.61-6.25a9.81 9.81 0 0 0-.045-4.5C9.027 15.808 8 15.394 8 10.824c.01-2.35.916-4.601 2.517-6.256C12.12 2.913 14.285 1.989 16.54 2c2.254.01 4.412.955 5.999 2.625 1.587 1.67 2.472 3.93 2.462 6.28V12l2 4h-2v4.208a3.821 3.821 0 0 1-1.08 2.373 3.531 3.531 0 0 1-2.306 1.054c-.165.01-.375.004-.606-.012-1.242-.085-2.367.83-2.367 2.075Z" fill="#000" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M21 13h-2l-1-2m3-1-1-2h-4m-3 1 2 4m-1 6 3-3h4" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
||||
|
After Width: | Height: | Size: 666 B |
|
Before Width: | Height: | Size: 24 KiB |
|
|
@ -0,0 +1 @@
|
|||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="16" cy="16" r="14" fill="#CC9B7A"/><path d="m10 21 4.5-10L19 21m-7.2-2.857h5.4M18.5 11 23 21" stroke="#1F1F1E" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
||||
|
After Width: | Height: | Size: 269 B |
|
|
@ -21,7 +21,7 @@ class ChatAnthropic_ChatModels implements INode {
|
|||
this.name = 'chatAnthropic'
|
||||
this.version = 3.0
|
||||
this.type = 'ChatAnthropic'
|
||||
this.icon = 'chatAnthropic.png'
|
||||
this.icon = 'Anthropic.svg'
|
||||
this.category = 'Chat Models'
|
||||
this.description = 'Wrapper around ChatAnthropic large language models that use the Chat endpoint'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(ChatAnthropic)]
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 57 KiB |
|
|
@ -20,7 +20,7 @@ class GoogleGenerativeAI_ChatModels implements INode {
|
|||
this.name = 'chatGoogleGenerativeAI'
|
||||
this.version = 1.0
|
||||
this.type = 'ChatGoogleGenerativeAI'
|
||||
this.icon = 'gemini.png'
|
||||
this.icon = 'GoogleGemini.svg'
|
||||
this.category = 'Chat Models'
|
||||
this.description = 'Wrapper around Google Gemini large language models that use the Chat endpoint'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(ChatGoogleGenerativeAI)]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<mask id="mask0_42_15021" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="4" y="4" width="24" height="24">
|
||||
<path d="M16.9976 4.93059C16.9611 4.40651 16.5253 4 16 4C15.4747 4 15.0389 4.40651 15.0024 4.93059L14.951 5.66926C14.6048 10.645 10.645 14.6048 5.66926 14.951L4.93059 15.0024C4.40651 15.0389 4 15.4747 4 16C4 16.5253 4.40651 16.9611 4.93059 16.9976L5.66926 17.049C10.645 17.3952 14.6048 21.355 14.951 26.3307L15.0024 27.0694C15.0389 27.5935 15.4747 28 16 28C16.5253 28 16.9611 27.5935 16.9976 27.0694L17.049 26.3307C17.3952 21.355 21.355 17.3952 26.3307 17.049L27.0694 16.9976C27.5935 16.9611 28 16.5253 28 16C28 15.4747 27.5935 15.0389 27.0694 15.0024L26.3307 14.951C21.355 14.6048 17.3952 10.645 17.049 5.66926L16.9976 4.93059Z" fill="black"/>
|
||||
</mask>
|
||||
<g mask="url(#mask0_42_15021)">
|
||||
<path d="M16.9976 4.93059C16.9611 4.40651 16.5253 4 16 4C15.4747 4 15.0389 4.40651 15.0024 4.93059L14.951 5.66926C14.6048 10.645 10.645 14.6048 5.66926 14.951L4.93059 15.0024C4.40651 15.0389 4 15.4747 4 16C4 16.5253 4.40651 16.9611 4.93059 16.9976L5.66926 17.049C10.645 17.3952 14.6048 21.355 14.951 26.3307L15.0024 27.0694C15.0389 27.5935 15.4747 28 16 28C16.5253 28 16.9611 27.5935 16.9976 27.0694L17.049 26.3307C17.3952 21.355 21.355 17.3952 26.3307 17.049L27.0694 16.9976C27.5935 16.9611 28 16.5253 28 16C28 15.4747 27.5935 15.0389 27.0694 15.0024L26.3307 14.951C21.355 14.6048 17.3952 10.645 17.049 5.66926L16.9976 4.93059Z" fill="white"/>
|
||||
<g filter="url(#filter0_f_42_15021)">
|
||||
<circle cx="10.4616" cy="13.2307" r="8.30769" fill="#77B6E5"/>
|
||||
</g>
|
||||
<g filter="url(#filter1_f_42_15021)">
|
||||
<circle cx="16" cy="22.4615" r="8.30769" fill="#1E90C9"/>
|
||||
</g>
|
||||
<g filter="url(#filter2_f_42_15021)">
|
||||
<ellipse cx="21.5385" cy="10.4615" rx="10.1538" ry="8.30769" fill="#E9E5DF"/>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="filter0_f_42_15021" x="-7.84613" y="-5.07697" width="36.6154" height="36.6154" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
||||
<feGaussianBlur stdDeviation="5" result="effect1_foregroundBlur_42_15021"/>
|
||||
</filter>
|
||||
<filter id="filter1_f_42_15021" x="-0.307678" y="6.15381" width="32.6154" height="32.6154" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
||||
<feGaussianBlur stdDeviation="4" result="effect1_foregroundBlur_42_15021"/>
|
||||
</filter>
|
||||
<filter id="filter2_f_42_15021" x="3.38464" y="-5.84619" width="36.3077" height="32.6154" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
||||
<feGaussianBlur stdDeviation="4" result="effect1_foregroundBlur_42_15021"/>
|
||||
</filter>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 56 KiB |
|
|
@ -20,7 +20,7 @@ class ChatGooglePaLM_ChatModels implements INode {
|
|||
this.name = 'chatGooglePaLM'
|
||||
this.version = 2.0
|
||||
this.type = 'ChatGooglePaLM'
|
||||
this.icon = 'Google_PaLM_Logo.svg'
|
||||
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)]
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
<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>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
|
|
@ -1,67 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 27.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Standard_product_icon__x28_1:1_x29_"
|
||||
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="192px" height="192px"
|
||||
viewBox="0 0 192 192" enable-background="new 0 0 192 192" xml:space="preserve">
|
||||
<symbol id="material_x5F_product_x5F_standard_x5F_icon_x5F_keylines_00000077318920148093339210000006245950728745084294_" viewBox="-96 -96 192 192">
|
||||
<g opacity="0.4">
|
||||
<defs>
|
||||
<path id="SVGID_1_" opacity="0.4" d="M-96,96V-96H96V96H-96z"/>
|
||||
</defs>
|
||||
<clipPath id="SVGID_00000071517564283228984050000017848131202901217410_">
|
||||
<use xlink:href="#SVGID_1_" overflow="visible"/>
|
||||
</clipPath>
|
||||
<g clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)">
|
||||
<g>
|
||||
<path d="M95.75,95.75v-191.5h-191.5v191.5H95.75 M96,96H-96V-96H96V96L96,96z"/>
|
||||
</g>
|
||||
<circle fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" cx="0" cy="0" r="64"/>
|
||||
</g>
|
||||
|
||||
<circle clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)" fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" cx="0" cy="0" r="88"/>
|
||||
|
||||
<path clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)" fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" d="
|
||||
M64,76H-64c-6.6,0-12-5.4-12-12V-64c0-6.6,5.4-12,12-12H64c6.6,0,12,5.4,12,12V64C76,70.6,70.6,76,64,76z"/>
|
||||
|
||||
<path clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)" fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" d="
|
||||
M52,88H-52c-6.6,0-12-5.4-12-12V-76c0-6.6,5.4-12,12-12H52c6.6,0,12,5.4,12,12V76C64,82.6,58.6,88,52,88z"/>
|
||||
|
||||
<path clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)" fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" d="
|
||||
M76,64H-76c-6.6,0-12-5.4-12-12V-52c0-6.6,5.4-12,12-12H76c6.6,0,12,5.4,12,12V52C88,58.6,82.6,64,76,64z"/>
|
||||
</g>
|
||||
</symbol>
|
||||
<rect id="bounding_box_1_" display="none" fill="none" width="192" height="192"/>
|
||||
<g id="art_layer">
|
||||
<g>
|
||||
<path fill="#F9AB00" d="M96,181.92L96,181.92c6.63,0,12-5.37,12-12v-104H84v104C84,176.55,89.37,181.92,96,181.92z"/>
|
||||
<g>
|
||||
<path fill="#5BB974" d="M143.81,103.87C130.87,90.94,111.54,88.32,96,96l51.37,51.37c2.12,2.12,5.77,1.28,6.67-1.57
|
||||
C158.56,131.49,155.15,115.22,143.81,103.87z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#129EAF" d="M48.19,103.87C61.13,90.94,80.46,88.32,96,96l-51.37,51.37c-2.12,2.12-5.77,1.28-6.67-1.57
|
||||
C33.44,131.49,36.85,115.22,48.19,103.87z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#AF5CF7" d="M140,64c-20.44,0-37.79,13.4-44,32h81.24c3.33,0,5.55-3.52,4.04-6.49C173.56,74.36,157.98,64,140,64z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#FF8BCB" d="M104.49,42.26C90.03,56.72,87.24,78.45,96,96l57.45-57.45c2.36-2.36,1.44-6.42-1.73-7.45
|
||||
C135.54,25.85,117.2,29.55,104.49,42.26z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#FA7B17" d="M87.51,42.26C101.97,56.72,104.76,78.45,96,96L38.55,38.55c-2.36-2.36-1.44-6.42,1.73-7.45
|
||||
C56.46,25.85,74.8,29.55,87.51,42.26z"/>
|
||||
</g>
|
||||
<g>
|
||||
<g>
|
||||
<path fill="#4285F4" d="M52,64c20.44,0,37.79,13.4,44,32H14.76c-3.33,0-5.55-3.52-4.04-6.49C18.44,74.36,34.02,64,52,64z"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="keylines" display="none">
|
||||
|
||||
<use xlink:href="#material_x5F_product_x5F_standard_x5F_icon_x5F_keylines_00000077318920148093339210000006245950728745084294_" width="192" height="192" id="material_x5F_product_x5F_standard_x5F_icon_x5F_keylines" x="-96" y="-96" transform="matrix(1 0 0 -1 96 96)" display="inline" overflow="visible"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 3.6 KiB |
|
|
@ -21,7 +21,7 @@ class GoogleVertexAI_ChatModels implements INode {
|
|||
this.name = 'chatGoogleVertexAI'
|
||||
this.version = 2.0
|
||||
this.type = 'ChatGoogleVertexAI'
|
||||
this.icon = 'vertexai.svg'
|
||||
this.icon = 'GoogleVertex.svg'
|
||||
this.category = 'Chat Models'
|
||||
this.description = 'Wrapper around VertexAI large language models that use the Chat endpoint'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(ChatGoogleVertexAI)]
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8 6.5V4m4 10.5V12m4 4.5V14m4-2.5V9m4 .5V7m-8 19.5 9-6.5m-9 6.5L7 20" stroke="#4285F4" stroke-width="2" stroke-linecap="round"/><circle cx="16" cy="26" r="2" fill="#fff" stroke="#4285F4" stroke-width="2"/><circle cx="8" cy="16" r="1" fill="#4285F4"/><circle cx="12" cy="18" r="1" fill="#4285F4"/><circle cx="16" cy="20" r="1" fill="#4285F4"/><circle cx="1" cy="1" r="1" transform="matrix(-1 0 0 1 25 15)" fill="#4285F4"/><circle cx="1" cy="1" r="1" transform="matrix(-1 0 0 1 21 17)" fill="#4285F4"/><circle cx="8" cy="13" r="1" fill="#4285F4"/><circle cx="20" cy="15" r="1" fill="#4285F4"/><circle cx="24" cy="13" r="1" fill="#4285F4"/><circle cx="12" cy="9" r="1" fill="#4285F4"/><circle cx="16" cy="11" r="1" fill="#4285F4"/><circle cx="8" cy="10" r="1" fill="#4285F4"/><circle cx="12" cy="6" r="1" fill="#4285F4"/><circle cx="16" cy="8" r="1" fill="#4285F4"/><circle cx="20" cy="6" r="1" fill="#4285F4"/><circle cx="24" cy="4" r="1" fill="#4285F4"/></svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
|
|
@ -1,2 +0,0 @@
|
|||
<!-- from https://cloud.google.com/icons-->
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24px" height="24px"><path d="M20,13.89A.77.77,0,0,0,19,13.73l-7,5.14v.22a.72.72,0,1,1,0,1.43v0a.74.74,0,0,0,.45-.15l7.41-5.47A.76.76,0,0,0,20,13.89Z" style="fill:#669df6"/><path d="M12,20.52a.72.72,0,0,1,0-1.43h0v-.22L5,13.73a.76.76,0,0,0-1,.16.74.74,0,0,0,.16,1l7.41,5.47a.73.73,0,0,0,.44.15v0Z" style="fill:#aecbfa"/><path d="M12,18.34a1.47,1.47,0,1,0,1.47,1.47A1.47,1.47,0,0,0,12,18.34Zm0,2.18a.72.72,0,1,1,.72-.71A.71.71,0,0,1,12,20.52Z" style="fill:#4285f4"/><path d="M6,6.11a.76.76,0,0,1-.75-.75V3.48a.76.76,0,1,1,1.51,0V5.36A.76.76,0,0,1,6,6.11Z" style="fill:#aecbfa"/><circle cx="5.98" cy="12" r="0.76" style="fill:#aecbfa"/><circle cx="5.98" cy="9.79" r="0.76" style="fill:#aecbfa"/><circle cx="5.98" cy="7.57" r="0.76" style="fill:#aecbfa"/><path d="M18,8.31a.76.76,0,0,1-.75-.76V5.67a.75.75,0,1,1,1.5,0V7.55A.75.75,0,0,1,18,8.31Z" style="fill:#4285f4"/><circle cx="18.02" cy="12.01" r="0.76" style="fill:#4285f4"/><circle cx="18.02" cy="9.76" r="0.76" style="fill:#4285f4"/><circle cx="18.02" cy="3.48" r="0.76" style="fill:#4285f4"/><path d="M12,15a.76.76,0,0,1-.75-.75V12.34a.76.76,0,0,1,1.51,0v1.89A.76.76,0,0,1,12,15Z" style="fill:#669df6"/><circle cx="12" cy="16.45" r="0.76" style="fill:#669df6"/><circle cx="12" cy="10.14" r="0.76" style="fill:#669df6"/><circle cx="12" cy="7.92" r="0.76" style="fill:#669df6"/><path d="M15,10.54a.76.76,0,0,1-.75-.75V7.91a.76.76,0,1,1,1.51,0V9.79A.76.76,0,0,1,15,10.54Z" style="fill:#4285f4"/><circle cx="15.01" cy="5.69" r="0.76" style="fill:#4285f4"/><circle cx="15.01" cy="14.19" r="0.76" style="fill:#4285f4"/><circle cx="15.01" cy="11.97" r="0.76" style="fill:#4285f4"/><circle cx="8.99" cy="14.19" r="0.76" style="fill:#aecbfa"/><circle cx="8.99" cy="7.92" r="0.76" style="fill:#aecbfa"/><circle cx="8.99" cy="5.69" r="0.76" style="fill:#aecbfa"/><path d="M9,12.73A.76.76,0,0,1,8.24,12V10.1a.75.75,0,1,1,1.5,0V12A.75.75,0,0,1,9,12.73Z" style="fill:#aecbfa"/></svg>
|
||||
|
Before Width: | Height: | Size: 2.0 KiB |
|
|
@ -20,7 +20,7 @@ class ChatHuggingFace_ChatModels implements INode {
|
|||
this.name = 'chatHuggingFace'
|
||||
this.version = 2.0
|
||||
this.type = 'ChatHuggingFace'
|
||||
this.icon = 'huggingface.png'
|
||||
this.icon = 'HuggingFace.svg'
|
||||
this.category = 'Chat Models'
|
||||
this.description = 'Wrapper around HuggingFace large language models'
|
||||
this.baseClasses = [this.type, 'BaseChatModel', ...getBaseClasses(HuggingFaceInference)]
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#HuggingFace__a)"><circle cx="16" cy="15" r="13" fill="#FFD21E" stroke="#FF9D00" stroke-width="2"/><path d="M13 9a2 2 0 1 0-4 0m14 0a2 2 0 1 0-4 0m3 4c-1.466 1.246-3.61 2.031-6 2.031s-4.534-.785-6-2.031" stroke="#32343D" stroke-width="2" stroke-linecap="round"/><path d="m18.85 20.18.541-2.227a1.14 1.14 0 0 1 2.235.311l.02 1.899 3.14-3.484a1.144 1.144 0 1 1 1.619 1.618l-2.697 2.9 3.506-3.505a1.144 1.144 0 1 1 1.618 1.618l-3.506 3.506 2.532-2.323c.446-.447 1.066-.551 1.513-.105a1.144 1.144 0 0 1 0 1.618l-.845.846c.415-.318.953-.198 1.345.194a1.089 1.089 0 0 1-.078 1.61l-1.722 1.467-3.503 2.586a3.689 3.689 0 0 1-.631.376 4.273 4.273 0 0 1-4.838-.846l-.408-.408c-1.249-1.249-1.317-3.049-.679-4.695l.159-.41a5.12 5.12 0 0 0 .244-.832l.435-1.713Zm-5.901 0-.542-2.227a1.14 1.14 0 0 0-2.235.311l-.02 1.899-3.14-3.484a1.144 1.144 0 1 0-1.618 1.618l2.696 2.9-3.505-3.505a1.144 1.144 0 1 0-1.618 1.618l3.505 3.506-2.531-2.323c-.447-.447-1.067-.551-1.514-.105a1.144 1.144 0 0 0 0 1.618l.845.846c-.414-.318-.953-.198-1.345.194a1.089 1.089 0 0 0 .078 1.61l1.723 1.467 3.502 2.586c.198.146.41.272.631.376a4.273 4.273 0 0 0 4.839-.846l.407-.408c1.25-1.249 1.318-3.049.68-4.695l-.16-.41a5.14 5.14 0 0 1-.244-.832l-.434-1.713Z" fill="#FFD21E" stroke="#FF9D00" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><circle cx="7" cy="12" r="1" fill="#FFAD03"/><circle cx="25" cy="12" r="1" fill="#FFAD03"/></g><defs><clipPath id="HuggingFace__a"><path fill="#fff" d="M0 0h32v32H0z"/></clipPath></defs></svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 118 KiB |
|
|
@ -20,7 +20,7 @@ class ChatMistral_ChatModels implements INode {
|
|||
this.name = 'chatMistralAI'
|
||||
this.version = 1.0
|
||||
this.type = 'ChatMistralAI'
|
||||
this.icon = 'mistralai.png'
|
||||
this.icon = 'MistralAI.svg'
|
||||
this.category = 'Chat Models'
|
||||
this.description = 'Wrapper around Mistral large language models that use the Chat endpoint'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(ChatMistralAI)]
|
||||
|
|
@ -124,13 +124,13 @@ class ChatMistral_ChatModels implements INode {
|
|||
const safeMode = nodeData.inputs?.safeMode as boolean
|
||||
const randomSeed = nodeData.inputs?.safeMode as string
|
||||
const overrideEndpoint = nodeData.inputs?.overrideEndpoint as string
|
||||
// Waiting fix from langchain + mistral to enable streaming - https://github.com/mistralai/client-js/issues/18
|
||||
|
||||
const streaming = nodeData.inputs?.streaming as boolean
|
||||
const cache = nodeData.inputs?.cache as BaseCache
|
||||
|
||||
const obj: ChatMistralAIInput = {
|
||||
apiKey: apiKey,
|
||||
modelName: modelName
|
||||
modelName: modelName,
|
||||
streaming: streaming ?? true
|
||||
}
|
||||
|
||||
if (maxOutputTokens) obj.maxTokens = parseInt(maxOutputTokens, 10)
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5 6H4v19.5h1m8-7.5v3h1m7-11.5V6h1m-5 7.5V10h1" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><mask id="MistralAI__a" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="5" y="6" width="22" height="20"><path d="M5 6v19.5h5v-8h4V21h4v-3.5h4V25h5V6h-4.5v4H18v3.5h-4v-4h-4V6H5Z" fill="#FD7000"/></mask><g mask="url(#MistralAI__a)"><path fill="#FFCD00" d="M4 6h25v4H4z"/></g><mask id="MistralAI__b" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="5" y="6" width="22" height="20"><path d="M5 6v19.5h5v-8h4V21h4v-3.5h4V25h5V6h-4.5v4H18v3.5h-4v-4h-4V6H5Z" fill="#FD7000"/></mask><g mask="url(#MistralAI__b)"><path fill="#FFA200" d="M4 10h25v4H4z"/></g><mask id="MistralAI__c" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="5" y="6" width="22" height="20"><path d="M5 6v19.5h5v-8h4V21h4v-3.5h4V25h5V6h-4.5v4H18v3.5h-4v-4h-4V6H5Z" fill="#FD7000"/></mask><g mask="url(#MistralAI__c)"><path fill="#FF6E00" d="M4 14h25v4H4z"/></g><mask id="MistralAI__d" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="5" y="6" width="22" height="20"><path d="M5 6v19.5h5v-8h4V21h4v-3.5h4V25h5V6h-4.5v4H18v3.5h-4v-4h-4V6H5Z" fill="#FD7000"/></mask><g mask="url(#MistralAI__d)"><path fill="#FF4A09" d="M4 18h25v4H4z"/></g><mask id="MistralAI__e" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="5" y="6" width="22" height="20"><path d="M5 6v19.5h5v-8h4V21h4v-3.5h4V25h5V6h-4.5v4H18v3.5h-4v-4h-4V6H5Z" fill="#FD7000"/></mask><g mask="url(#MistralAI__e)"><path fill="#FE060F" d="M4 22h25v4H4z"/></g><path d="M21 18v7h1" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M5 6v19.5h5v-8h4V21h4v-3.5h4V25h5V6h-4.5v4H18v3.5h-4v-4h-4V6H5Z" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 4.4 KiB |
|
|
@ -1,8 +1,7 @@
|
|||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { ChatOllama } from 'langchain/chat_models/ollama'
|
||||
import { ChatOllama, ChatOllamaInput } from 'langchain/chat_models/ollama'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
import { OllamaInput } from 'langchain/dist/util/ollama'
|
||||
import { BaseLLMParams } from 'langchain/llms/base'
|
||||
|
||||
class ChatOllama_ChatModels implements INode {
|
||||
|
|
@ -22,7 +21,7 @@ class ChatOllama_ChatModels implements INode {
|
|||
this.name = 'chatOllama'
|
||||
this.version = 2.0
|
||||
this.type = 'ChatOllama'
|
||||
this.icon = 'ollama.png'
|
||||
this.icon = 'Ollama.svg'
|
||||
this.category = 'Chat Models'
|
||||
this.description = 'Chat completion using open-source LLM on Ollama'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(ChatOllama)]
|
||||
|
|
@ -209,7 +208,7 @@ class ChatOllama_ChatModels implements INode {
|
|||
|
||||
const cache = nodeData.inputs?.cache as BaseCache
|
||||
|
||||
const obj: OllamaInput & BaseLLMParams = {
|
||||
const obj: ChatOllamaInput & BaseLLMParams = {
|
||||
baseUrl,
|
||||
temperature: parseFloat(temperature),
|
||||
model: modelName
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7 27.5c0-1.273.388-2.388.97-3-.582-.612-.97-1.727-.97-3 0-1.293.4-2.422.996-3.028A4.818 4.818 0 0 1 7 15.5c0-2.485 1.79-4.5 4-4.5l.1.001a5.002 5.002 0 0 1 9.8 0L21 11c2.21 0 4 2.015 4 4.5 0 1.139-.376 2.18-.996 2.972.595.606.996 1.735.996 3.028 0 1.273-.389 2.388-.97 3 .581.612.97 1.727.97 3" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M9.5 11C9.167 8.5 9 4 11 4c1.5 0 1.667 2.667 2 4m9.5 3c.333-2.5.5-7-1.5-7-1.5 0-1.667 2.667-2 4" stroke="#000" stroke-width="2" stroke-linecap="round"/><circle cx="11" cy="15" r="1" fill="#000"/><circle cx="21" cy="15" r="1" fill="#000"/><path d="M13 17c0-2 2-2.5 3-2.5s3 .5 3 2.5-2 2.5-3 2.5-3-.5-3-2.5Z" stroke="#000" stroke-width="2" stroke-linecap="round"/></svg>
|
||||
|
After Width: | Height: | Size: 834 B |
|
Before Width: | Height: | Size: 7.3 KiB |
|
|
@ -20,7 +20,7 @@ class Airtable_DocumentLoaders implements INode {
|
|||
constructor() {
|
||||
this.label = 'Airtable'
|
||||
this.name = 'airtable'
|
||||
this.version = 1.0
|
||||
this.version = 2.0
|
||||
this.type = 'Document'
|
||||
this.icon = 'airtable.svg'
|
||||
this.category = 'Document Loaders'
|
||||
|
|
@ -55,6 +55,15 @@ class Airtable_DocumentLoaders implements INode {
|
|||
description:
|
||||
'If your table URL looks like: https://airtable.com/app11RobdGoX0YNsC/tblJdmvbrgizbYICO/viw9UrP77Id0CE4ee, tblJdmvbrgizbYICO is the table id'
|
||||
},
|
||||
{
|
||||
label: 'View Id',
|
||||
name: 'viewId',
|
||||
type: 'string',
|
||||
placeholder: 'viw9UrP77Id0CE4ee',
|
||||
description:
|
||||
'If your view URL looks like: https://airtable.com/app11RobdGoX0YNsC/tblJdmvbrgizbYICO/viw9UrP77Id0CE4ee, viw9UrP77Id0CE4ee is the view id',
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Return All',
|
||||
name: 'returnAll',
|
||||
|
|
@ -83,6 +92,7 @@ class Airtable_DocumentLoaders implements INode {
|
|||
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||
const baseId = nodeData.inputs?.baseId as string
|
||||
const tableId = nodeData.inputs?.tableId as string
|
||||
const viewId = nodeData.inputs?.viewId as string
|
||||
const returnAll = nodeData.inputs?.returnAll as boolean
|
||||
const limit = nodeData.inputs?.limit as string
|
||||
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
|
||||
|
|
@ -94,6 +104,7 @@ class Airtable_DocumentLoaders implements INode {
|
|||
const airtableOptions: AirtableLoaderParams = {
|
||||
baseId,
|
||||
tableId,
|
||||
viewId,
|
||||
returnAll,
|
||||
accessToken,
|
||||
limit: limit ? parseInt(limit, 10) : 100
|
||||
|
|
@ -133,6 +144,7 @@ interface AirtableLoaderParams {
|
|||
baseId: string
|
||||
tableId: string
|
||||
accessToken: string
|
||||
viewId?: string
|
||||
limit?: number
|
||||
returnAll?: boolean
|
||||
}
|
||||
|
|
@ -153,16 +165,19 @@ class AirtableLoader extends BaseDocumentLoader {
|
|||
|
||||
public readonly tableId: string
|
||||
|
||||
public readonly viewId?: string
|
||||
|
||||
public readonly accessToken: string
|
||||
|
||||
public readonly limit: number
|
||||
|
||||
public readonly returnAll: boolean
|
||||
|
||||
constructor({ baseId, tableId, accessToken, limit = 100, returnAll = false }: AirtableLoaderParams) {
|
||||
constructor({ baseId, tableId, viewId, accessToken, limit = 100, returnAll = false }: AirtableLoaderParams) {
|
||||
super()
|
||||
this.baseId = baseId
|
||||
this.tableId = tableId
|
||||
this.viewId = viewId
|
||||
this.accessToken = accessToken
|
||||
this.limit = limit
|
||||
this.returnAll = returnAll
|
||||
|
|
@ -203,7 +218,7 @@ class AirtableLoader extends BaseDocumentLoader {
|
|||
}
|
||||
|
||||
private async loadLimit(): Promise<Document[]> {
|
||||
const params = { maxRecords: this.limit }
|
||||
const params = { maxRecords: this.limit, view: this.viewId }
|
||||
const data = await this.fetchAirtableData(`https://api.airtable.com/v0/${this.baseId}/${this.tableId}`, params)
|
||||
if (data.records.length === 0) {
|
||||
return []
|
||||
|
|
@ -212,7 +227,7 @@ class AirtableLoader extends BaseDocumentLoader {
|
|||
}
|
||||
|
||||
private async loadAll(): Promise<Document[]> {
|
||||
const params: ICommonObject = { pageSize: 100 }
|
||||
const params: ICommonObject = { pageSize: 100, view: this.viewId }
|
||||
let data: AirtableLoaderResponse
|
||||
let returnPages: AirtableLoaderPage[] = []
|
||||
|
||||
|
|
|
|||
|
|
@ -66,6 +66,10 @@ class NotionDB_DocumentLoaders implements INode {
|
|||
auth: notionIntegrationToken
|
||||
},
|
||||
id: databaseId,
|
||||
callerOptions: {
|
||||
maxConcurrency: 64 // Default value
|
||||
},
|
||||
propertiesAsHeader: true, // Prepends a front matter header of the page properties to the page contents
|
||||
type: 'database'
|
||||
}
|
||||
const loader = new NotionAPILoader(obj)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class S3_DocumentLoaders implements INode {
|
|||
constructor() {
|
||||
this.label = 'S3'
|
||||
this.name = 'S3'
|
||||
this.version = 1.0
|
||||
this.version = 2.0
|
||||
this.type = 'Document'
|
||||
this.icon = 's3.svg'
|
||||
this.category = 'Document Loaders'
|
||||
|
|
@ -113,12 +113,62 @@ class S3_DocumentLoaders implements INode {
|
|||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'NarrativeText Only',
|
||||
name: 'narrativeTextOnly',
|
||||
label: 'Element Type',
|
||||
name: 'elementType',
|
||||
description:
|
||||
'Only load documents with NarrativeText metadata from Unstructured. See how Unstructured partition data <a target="_blank" href="https://unstructured-io.github.io/unstructured/bricks/partition.html#">here</a>',
|
||||
default: true,
|
||||
type: 'boolean',
|
||||
'Unstructured partition document into different types, select the types to return. If not selected, all types will be returned',
|
||||
type: 'multiOptions',
|
||||
options: [
|
||||
{
|
||||
label: 'FigureCaption',
|
||||
name: 'FigureCaption'
|
||||
},
|
||||
{
|
||||
label: 'NarrativeText',
|
||||
name: 'NarrativeText'
|
||||
},
|
||||
{
|
||||
label: 'ListItem',
|
||||
name: 'ListItem'
|
||||
},
|
||||
{
|
||||
label: 'Title',
|
||||
name: 'Title'
|
||||
},
|
||||
{
|
||||
label: 'Address',
|
||||
name: 'Address'
|
||||
},
|
||||
{
|
||||
label: 'Table',
|
||||
name: 'Table'
|
||||
},
|
||||
{
|
||||
label: 'PageBreak',
|
||||
name: 'PageBreak'
|
||||
},
|
||||
{
|
||||
label: 'Header',
|
||||
name: 'Header'
|
||||
},
|
||||
{
|
||||
label: 'Footer',
|
||||
name: 'Footer'
|
||||
},
|
||||
{
|
||||
label: 'UncategorizedText',
|
||||
name: 'UncategorizedText'
|
||||
},
|
||||
{
|
||||
label: 'Image',
|
||||
name: 'Image'
|
||||
},
|
||||
{
|
||||
label: 'Formula',
|
||||
name: 'Formula'
|
||||
}
|
||||
],
|
||||
default: [],
|
||||
optional: true,
|
||||
additionalParams: true
|
||||
},
|
||||
|
|
@ -138,7 +188,7 @@ class S3_DocumentLoaders implements INode {
|
|||
const unstructuredAPIUrl = nodeData.inputs?.unstructuredAPIUrl as string
|
||||
const unstructuredAPIKey = nodeData.inputs?.unstructuredAPIKey as string
|
||||
const metadata = nodeData.inputs?.metadata
|
||||
const narrativeTextOnly = nodeData.inputs?.narrativeTextOnly as boolean
|
||||
const elementType = nodeData.inputs?.elementType as string
|
||||
|
||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||
const accessKeyId = getCredentialParam('awsKey', credentialData, nodeData)
|
||||
|
|
@ -169,6 +219,15 @@ class S3_DocumentLoaders implements INode {
|
|||
}
|
||||
}
|
||||
|
||||
let elementTypes: string[] = []
|
||||
if (elementType) {
|
||||
try {
|
||||
elementTypes = JSON.parse(elementType)
|
||||
} catch (e) {
|
||||
elementTypes = []
|
||||
}
|
||||
}
|
||||
|
||||
loader.load = async () => {
|
||||
const tempDir = fsDefault.mkdtempSync(path.join(os.tmpdir(), 's3fileloader-'))
|
||||
|
||||
|
|
@ -235,10 +294,10 @@ class S3_DocumentLoaders implements INode {
|
|||
}
|
||||
}
|
||||
})
|
||||
return narrativeTextOnly ? finaldocs.filter((doc) => doc.metadata.category === 'NarrativeText') : finaldocs
|
||||
return elementTypes.length ? finaldocs.filter((doc) => elementTypes.includes(doc.metadata.category)) : finaldocs
|
||||
}
|
||||
|
||||
return narrativeTextOnly ? docs.filter((doc) => doc.metadata.category === 'NarrativeText') : docs
|
||||
return elementTypes.length ? docs.filter((doc) => elementTypes.includes(doc.metadata.category)) : docs
|
||||
}
|
||||
}
|
||||
module.exports = { nodeClass: S3_DocumentLoaders }
|
||||
|
|
|
|||
|
|
@ -1,5 +1 @@
|
|||
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M9.95804 14.1159C9.95804 14.4567 9.99488 14.733 10.0594 14.9357C10.133 15.1383 10.2251 15.3593 10.3541 15.5988C10.4001 15.6725 10.4186 15.7462 10.4186 15.8107C10.4186 15.9028 10.3633 15.9949 10.2436 16.087L9.6633 16.4738C9.58041 16.5291 9.49751 16.5567 9.42383 16.5567C9.33172 16.5567 9.23962 16.5107 9.14751 16.4278C9.01857 16.2896 8.90804 16.1422 8.81593 15.9949C8.72383 15.8383 8.63172 15.6633 8.53041 15.4514C7.81199 16.2988 6.90935 16.7225 5.82251 16.7225C5.04883 16.7225 4.43172 16.5014 3.98041 16.0593C3.52909 15.6172 3.29883 15.0278 3.29883 14.2909C3.29883 13.508 3.57514 12.8725 4.13699 12.3935C4.69883 11.9146 5.44488 11.6751 6.39357 11.6751C6.70672 11.6751 7.02909 11.7028 7.36988 11.7488C7.71067 11.7949 8.06067 11.8685 8.42909 11.9514V11.2791C8.42909 10.5791 8.28172 10.0909 7.9962 9.80539C7.70146 9.51986 7.20409 9.3817 6.49488 9.3817C6.17251 9.3817 5.84093 9.41855 5.50014 9.50144C5.15935 9.58434 4.82778 9.68565 4.50541 9.8146C4.35804 9.87907 4.24751 9.91591 4.18304 9.93434C4.11857 9.95276 4.07251 9.96197 4.03567 9.96197C3.90672 9.96197 3.84225 9.86986 3.84225 9.67644V9.22512C3.84225 9.07776 3.86067 8.96723 3.90672 8.90276C3.95278 8.83828 4.03567 8.77381 4.16462 8.70934C4.48699 8.54355 4.87383 8.40539 5.32514 8.29486C5.77646 8.17512 6.25541 8.11986 6.76199 8.11986C7.85804 8.11986 8.65936 8.36855 9.17515 8.86591C9.68172 9.36328 9.93962 10.1185 9.93962 11.1317V14.1159H9.95804ZM6.21857 15.5159C6.52251 15.5159 6.83567 15.4607 7.16725 15.3501C7.49883 15.2396 7.79357 15.037 8.04225 14.7607C8.18962 14.5857 8.30014 14.3922 8.35541 14.1712C8.41067 13.9501 8.44751 13.683 8.44751 13.3699V12.983C8.18041 12.9185 7.89488 12.8633 7.60014 12.8264C7.30541 12.7896 7.01988 12.7712 6.73436 12.7712C6.11725 12.7712 5.66593 12.8909 5.36199 13.1396C5.05804 13.3883 4.91067 13.7383 4.91067 14.1988C4.91067 14.6317 5.0212 14.9541 5.25146 15.1751C5.47251 15.4054 5.79488 15.5159 6.21857 15.5159ZM13.6146 16.5107C13.4488 16.5107 13.3383 16.483 13.2646 16.4185C13.1909 16.3633 13.1265 16.2343 13.0712 16.0593L10.9067 8.9396C10.8515 8.75539 10.8238 8.63565 10.8238 8.57118C10.8238 8.42381 10.8975 8.34091 11.0449 8.34091H11.9475C12.1225 8.34091 12.2423 8.36855 12.3067 8.43302C12.3804 8.48828 12.4357 8.61723 12.4909 8.79223L14.0383 14.8896L15.4751 8.79223C15.5212 8.60802 15.5765 8.48828 15.6501 8.43302C15.7238 8.37776 15.8528 8.34091 16.0186 8.34091H16.7554C16.9304 8.34091 17.0501 8.36855 17.1238 8.43302C17.1975 8.48828 17.262 8.61723 17.2988 8.79223L18.7541 14.9633L20.3475 8.79223C20.4028 8.60802 20.4673 8.48828 20.5317 8.43302C20.6054 8.37776 20.7251 8.34091 20.8909 8.34091H21.7475C21.8949 8.34091 21.9778 8.4146 21.9778 8.57118C21.9778 8.61723 21.9686 8.66328 21.9594 8.71855C21.9501 8.77381 21.9317 8.84749 21.8949 8.94881L19.6751 16.0685C19.6199 16.2528 19.5554 16.3725 19.4817 16.4278C19.408 16.483 19.2883 16.5199 19.1317 16.5199H18.3396C18.1646 16.5199 18.0449 16.4922 17.9712 16.4278C17.8975 16.3633 17.833 16.2435 17.7962 16.0593L16.3686 10.1185L14.9501 16.0501C14.9041 16.2343 14.8488 16.3541 14.7751 16.4185C14.7015 16.483 14.5725 16.5107 14.4067 16.5107H13.6146ZM25.4501 16.7593C24.9712 16.7593 24.4923 16.7041 24.0317 16.5935C23.5712 16.483 23.212 16.3633 22.9725 16.2251C22.8251 16.1422 22.7238 16.0501 22.687 15.9672C22.6501 15.8843 22.6317 15.7922 22.6317 15.7093V15.2396C22.6317 15.0462 22.7054 14.9541 22.8436 14.9541C22.8988 14.9541 22.9541 14.9633 23.0094 14.9817C23.0646 15.0001 23.1475 15.037 23.2396 15.0738C23.5528 15.212 23.8936 15.3225 24.2528 15.3962C24.6212 15.4699 24.9804 15.5067 25.3488 15.5067C25.9291 15.5067 26.3804 15.4054 26.6936 15.2028C27.0067 15.0001 27.1725 14.7054 27.1725 14.3278C27.1725 14.0699 27.0896 13.858 26.9238 13.683C26.758 13.508 26.4449 13.3514 25.9936 13.2041L24.658 12.7896C23.9857 12.5778 23.4883 12.2646 23.1844 11.8501C22.8804 11.4449 22.7238 10.9935 22.7238 10.5146C22.7238 10.1278 22.8067 9.78697 22.9725 9.49223C23.1383 9.19749 23.3594 8.9396 23.6357 8.73697C23.912 8.52512 24.2251 8.36855 24.5936 8.25802C24.962 8.14749 25.3488 8.10144 25.7541 8.10144C25.9567 8.10144 26.1686 8.11065 26.3712 8.13828C26.583 8.16591 26.7765 8.20276 26.9699 8.2396C27.1541 8.28565 27.3291 8.3317 27.4949 8.38697C27.6607 8.44223 27.7896 8.49749 27.8817 8.55276C28.0107 8.62644 28.1028 8.70012 28.158 8.78302C28.2133 8.8567 28.2409 8.95802 28.2409 9.08697V9.51986C28.2409 9.71328 28.1673 9.8146 28.0291 9.8146C27.9554 9.8146 27.8357 9.77776 27.6791 9.70407C27.1541 9.4646 26.5646 9.34486 25.9107 9.34486C25.3857 9.34486 24.9712 9.42776 24.6857 9.60276C24.4001 9.77776 24.2528 10.0449 24.2528 10.4225C24.2528 10.6804 24.3449 10.9014 24.5291 11.0764C24.7133 11.2514 25.0541 11.4264 25.5423 11.583L26.8501 11.9975C27.5133 12.2093 27.9923 12.5041 28.2778 12.8817C28.5633 13.2593 28.7015 13.6922 28.7015 14.1712C28.7015 14.5672 28.6186 14.9264 28.462 15.2396C28.2962 15.5528 28.0751 15.8291 27.7896 16.0501C27.5041 16.2804 27.1633 16.4462 26.7673 16.5659C26.3528 16.6949 25.9199 16.7593 25.4501 16.7593Z" fill="#252F3E"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M27.191 21.2357C24.1607 23.4739 19.7581 24.662 15.9725 24.662C10.6673 24.662 5.88702 22.7002 2.27649 19.4397C1.99097 19.1818 2.24886 18.8318 2.58965 19.0344C6.49492 21.3002 11.312 22.6726 16.2949 22.6726C19.6568 22.6726 23.3502 21.9726 26.7489 20.5357C27.2554 20.3054 27.6883 20.8673 27.191 21.2357Z" fill="#FF9900"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M28.4527 19.7989C28.0659 19.3015 25.8922 19.5594 24.9067 19.6791C24.6119 19.716 24.5659 19.4581 24.833 19.2647C26.5645 18.0489 29.4106 18.3989 29.7422 18.8041C30.0738 19.2186 29.6501 22.0647 28.029 23.4278C27.7803 23.6397 27.5409 23.5291 27.6514 23.2528C28.0198 22.341 28.8396 20.287 28.4527 19.7989Z" fill="#FF9900"/>
|
||||
</svg>
|
||||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 21c1.67 1.77 5.491 3 9.757 3 2.788 0 5.386-.525 7.317-1.383L25 21.65" stroke="#F90" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="m23 20 3 1.074L25.4 24" stroke="#F90" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M24.564 9.44C23.677 8.76 21 8.633 21 10.796c0 2.396 4 .77 4 3.294 0 1.898-2.67 2.501-4 1.264M14 9v7l2-4 2 4V9" stroke="#252F3E" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M7.053 8.597H8.21a2.526 2.526 0 0 1 2.526 2.526v4.842" stroke="#252F3E" stroke-width="2" stroke-linecap="round"/><circle cx="8.632" cy="13.86" stroke="#252F3E" stroke-width="2" r="2.105"/></svg>
|
||||
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 753 B |
|
|
@ -1 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="96px" height="96px"><path fill="#035bda" d="M46 40L29.317 10.852 22.808 23.96 34.267 37.24 13 39.655zM13.092 18.182L2 36.896 11.442 35.947 28.033 5.678z"/></svg>
|
||||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M11.946 5H19l-7.322 22.216a1.15 1.15 0 0 1-.41.568c-.19.14-.42.216-.656.216H5.123a1.11 1.11 0 0 1-.513-.127 1.132 1.132 0 0 1-.4-.352 1.165 1.165 0 0 1-.151-1.038l6.822-20.7a1.15 1.15 0 0 1 .41-.567c.19-.14.42-.216.655-.216Z" fill="#0A5FAB"/><path d="M22.334 20H11.502c-.1 0-.2.031-.282.09a.52.52 0 0 0-.185.241.545.545 0 0 0 .125.576l6.96 6.786c.203.197.47.307.747.307H25l-2.666-8Z" fill="#0078D4"/><path d="M21.035 5.782a1.149 1.149 0 0 0-.415-.566A1.128 1.128 0 0 0 19.957 5H12c.238 0 .47.076.663.216.193.14.338.338.414.566l6.906 20.7a1.16 1.16 0 0 1-.558 1.391 1.12 1.12 0 0 1-.52.127h7.959a1.127 1.127 0 0 0 .923-.48 1.159 1.159 0 0 0 .153-1.038l-6.905-20.7Z" fill="#2C9DE3"/></svg>
|
||||
|
Before Width: | Height: | Size: 229 B After Width: | Height: | Size: 771 B |
|
|
@ -0,0 +1 @@
|
|||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M11.776 18.304c.64 0 1.92-.032 3.712-.768 2.08-.864 6.176-2.4 9.152-4 2.08-1.12 2.976-2.592 2.976-4.576 0-2.72-2.208-4.96-4.96-4.96h-11.52A7.143 7.143 0 0 0 4 11.136c0 3.936 3.008 7.168 7.776 7.168Z" fill="#39594D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M13.728 23.2c0-1.92 1.152-3.68 2.944-4.416l3.616-1.504C23.968 15.776 28 18.464 28 22.432A5.572 5.572 0 0 1 22.432 28h-3.936c-2.624 0-4.768-2.144-4.768-4.8Z" fill="#D18EE2"/><path d="M8.128 19.232A4.138 4.138 0 0 0 4 23.36v.544C4 26.144 5.856 28 8.128 28a4.138 4.138 0 0 0 4.128-4.128v-.544c-.032-2.24-1.856-4.096-4.128-4.096Z" fill="#FF7759"/></svg>
|
||||
|
After Width: | Height: | Size: 738 B |
|
|
@ -19,7 +19,7 @@ class CohereEmbedding_Embeddings implements INode {
|
|||
this.name = 'cohereEmbeddings'
|
||||
this.version = 1.0
|
||||
this.type = 'CohereEmbeddings'
|
||||
this.icon = 'cohere.png'
|
||||
this.icon = 'Cohere.svg'
|
||||
this.category = 'Embeddings'
|
||||
this.description = 'Cohere API to generate embeddings for a given text'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(CohereEmbeddings)]
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 7.7 KiB |
|
|
@ -0,0 +1,34 @@
|
|||
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<mask id="mask0_42_15021" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="4" y="4" width="24" height="24">
|
||||
<path d="M16.9976 4.93059C16.9611 4.40651 16.5253 4 16 4C15.4747 4 15.0389 4.40651 15.0024 4.93059L14.951 5.66926C14.6048 10.645 10.645 14.6048 5.66926 14.951L4.93059 15.0024C4.40651 15.0389 4 15.4747 4 16C4 16.5253 4.40651 16.9611 4.93059 16.9976L5.66926 17.049C10.645 17.3952 14.6048 21.355 14.951 26.3307L15.0024 27.0694C15.0389 27.5935 15.4747 28 16 28C16.5253 28 16.9611 27.5935 16.9976 27.0694L17.049 26.3307C17.3952 21.355 21.355 17.3952 26.3307 17.049L27.0694 16.9976C27.5935 16.9611 28 16.5253 28 16C28 15.4747 27.5935 15.0389 27.0694 15.0024L26.3307 14.951C21.355 14.6048 17.3952 10.645 17.049 5.66926L16.9976 4.93059Z" fill="black"/>
|
||||
</mask>
|
||||
<g mask="url(#mask0_42_15021)">
|
||||
<path d="M16.9976 4.93059C16.9611 4.40651 16.5253 4 16 4C15.4747 4 15.0389 4.40651 15.0024 4.93059L14.951 5.66926C14.6048 10.645 10.645 14.6048 5.66926 14.951L4.93059 15.0024C4.40651 15.0389 4 15.4747 4 16C4 16.5253 4.40651 16.9611 4.93059 16.9976L5.66926 17.049C10.645 17.3952 14.6048 21.355 14.951 26.3307L15.0024 27.0694C15.0389 27.5935 15.4747 28 16 28C16.5253 28 16.9611 27.5935 16.9976 27.0694L17.049 26.3307C17.3952 21.355 21.355 17.3952 26.3307 17.049L27.0694 16.9976C27.5935 16.9611 28 16.5253 28 16C28 15.4747 27.5935 15.0389 27.0694 15.0024L26.3307 14.951C21.355 14.6048 17.3952 10.645 17.049 5.66926L16.9976 4.93059Z" fill="white"/>
|
||||
<g filter="url(#filter0_f_42_15021)">
|
||||
<circle cx="10.4616" cy="13.2307" r="8.30769" fill="#77B6E5"/>
|
||||
</g>
|
||||
<g filter="url(#filter1_f_42_15021)">
|
||||
<circle cx="16" cy="22.4615" r="8.30769" fill="#1E90C9"/>
|
||||
</g>
|
||||
<g filter="url(#filter2_f_42_15021)">
|
||||
<ellipse cx="21.5385" cy="10.4615" rx="10.1538" ry="8.30769" fill="#E9E5DF"/>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="filter0_f_42_15021" x="-7.84613" y="-5.07697" width="36.6154" height="36.6154" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
||||
<feGaussianBlur stdDeviation="5" result="effect1_foregroundBlur_42_15021"/>
|
||||
</filter>
|
||||
<filter id="filter1_f_42_15021" x="-0.307678" y="6.15381" width="32.6154" height="32.6154" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
||||
<feGaussianBlur stdDeviation="4" result="effect1_foregroundBlur_42_15021"/>
|
||||
</filter>
|
||||
<filter id="filter2_f_42_15021" x="3.38464" y="-5.84619" width="36.3077" height="32.6154" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
||||
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
|
||||
<feBlend mode="normal" in="SourceGraphic" in2="BackgroundImageFix" result="shape"/>
|
||||
<feGaussianBlur stdDeviation="4" result="effect1_foregroundBlur_42_15021"/>
|
||||
</filter>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.0 KiB |
|
|
@ -20,7 +20,7 @@ class GoogleGenerativeAIEmbedding_Embeddings implements INode {
|
|||
this.name = 'googleGenerativeAiEmbeddings'
|
||||
this.version = 1.0
|
||||
this.type = 'GoogleGenerativeAiEmbeddings'
|
||||
this.icon = 'gemini.png'
|
||||
this.icon = 'GoogleGemini.svg'
|
||||
this.category = 'Embeddings'
|
||||
this.description = 'Google Generative API to generate embeddings for a given text'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(GoogleGenerativeAIEmbeddings)]
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 56 KiB |
|
|
@ -0,0 +1 @@
|
|||
<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>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
|
|
@ -19,7 +19,7 @@ class GooglePaLMEmbedding_Embeddings implements INode {
|
|||
this.name = 'googlePaLMEmbeddings'
|
||||
this.version = 1.0
|
||||
this.type = 'GooglePaLMEmbeddings'
|
||||
this.icon = 'Google_PaLM_Logo.svg'
|
||||
this.icon = 'GooglePaLM.svg'
|
||||
this.category = 'Embeddings'
|
||||
this.description = 'Google MakerSuite PaLM API to generate embeddings for a given text'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(GooglePaLMEmbeddings)]
|
||||
|
|
|
|||
|
|
@ -1,67 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 27.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Standard_product_icon__x28_1:1_x29_"
|
||||
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="192px" height="192px"
|
||||
viewBox="0 0 192 192" enable-background="new 0 0 192 192" xml:space="preserve">
|
||||
<symbol id="material_x5F_product_x5F_standard_x5F_icon_x5F_keylines_00000077318920148093339210000006245950728745084294_" viewBox="-96 -96 192 192">
|
||||
<g opacity="0.4">
|
||||
<defs>
|
||||
<path id="SVGID_1_" opacity="0.4" d="M-96,96V-96H96V96H-96z"/>
|
||||
</defs>
|
||||
<clipPath id="SVGID_00000071517564283228984050000017848131202901217410_">
|
||||
<use xlink:href="#SVGID_1_" overflow="visible"/>
|
||||
</clipPath>
|
||||
<g clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)">
|
||||
<g>
|
||||
<path d="M95.75,95.75v-191.5h-191.5v191.5H95.75 M96,96H-96V-96H96V96L96,96z"/>
|
||||
</g>
|
||||
<circle fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" cx="0" cy="0" r="64"/>
|
||||
</g>
|
||||
|
||||
<circle clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)" fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" cx="0" cy="0" r="88"/>
|
||||
|
||||
<path clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)" fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" d="
|
||||
M64,76H-64c-6.6,0-12-5.4-12-12V-64c0-6.6,5.4-12,12-12H64c6.6,0,12,5.4,12,12V64C76,70.6,70.6,76,64,76z"/>
|
||||
|
||||
<path clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)" fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" d="
|
||||
M52,88H-52c-6.6,0-12-5.4-12-12V-76c0-6.6,5.4-12,12-12H52c6.6,0,12,5.4,12,12V76C64,82.6,58.6,88,52,88z"/>
|
||||
|
||||
<path clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)" fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" d="
|
||||
M76,64H-76c-6.6,0-12-5.4-12-12V-52c0-6.6,5.4-12,12-12H76c6.6,0,12,5.4,12,12V52C88,58.6,82.6,64,76,64z"/>
|
||||
</g>
|
||||
</symbol>
|
||||
<rect id="bounding_box_1_" display="none" fill="none" width="192" height="192"/>
|
||||
<g id="art_layer">
|
||||
<g>
|
||||
<path fill="#F9AB00" d="M96,181.92L96,181.92c6.63,0,12-5.37,12-12v-104H84v104C84,176.55,89.37,181.92,96,181.92z"/>
|
||||
<g>
|
||||
<path fill="#5BB974" d="M143.81,103.87C130.87,90.94,111.54,88.32,96,96l51.37,51.37c2.12,2.12,5.77,1.28,6.67-1.57
|
||||
C158.56,131.49,155.15,115.22,143.81,103.87z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#129EAF" d="M48.19,103.87C61.13,90.94,80.46,88.32,96,96l-51.37,51.37c-2.12,2.12-5.77,1.28-6.67-1.57
|
||||
C33.44,131.49,36.85,115.22,48.19,103.87z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#AF5CF7" d="M140,64c-20.44,0-37.79,13.4-44,32h81.24c3.33,0,5.55-3.52,4.04-6.49C173.56,74.36,157.98,64,140,64z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#FF8BCB" d="M104.49,42.26C90.03,56.72,87.24,78.45,96,96l57.45-57.45c2.36-2.36,1.44-6.42-1.73-7.45
|
||||
C135.54,25.85,117.2,29.55,104.49,42.26z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#FA7B17" d="M87.51,42.26C101.97,56.72,104.76,78.45,96,96L38.55,38.55c-2.36-2.36-1.44-6.42,1.73-7.45
|
||||
C56.46,25.85,74.8,29.55,87.51,42.26z"/>
|
||||
</g>
|
||||
<g>
|
||||
<g>
|
||||
<path fill="#4285F4" d="M52,64c20.44,0,37.79,13.4,44,32H14.76c-3.33,0-5.55-3.52-4.04-6.49C18.44,74.36,34.02,64,52,64z"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="keylines" display="none">
|
||||
|
||||
<use xlink:href="#material_x5F_product_x5F_standard_x5F_icon_x5F_keylines_00000077318920148093339210000006245950728745084294_" width="192" height="192" id="material_x5F_product_x5F_standard_x5F_icon_x5F_keylines" x="-96" y="-96" transform="matrix(1 0 0 -1 96 96)" display="inline" overflow="visible"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 3.6 KiB |
|
|
@ -0,0 +1 @@
|
|||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8 6.5V4m4 10.5V12m4 4.5V14m4-2.5V9m4 .5V7m-8 19.5 9-6.5m-9 6.5L7 20" stroke="#4285F4" stroke-width="2" stroke-linecap="round"/><circle cx="16" cy="26" r="2" fill="#fff" stroke="#4285F4" stroke-width="2"/><circle cx="8" cy="16" r="1" fill="#4285F4"/><circle cx="12" cy="18" r="1" fill="#4285F4"/><circle cx="16" cy="20" r="1" fill="#4285F4"/><circle cx="1" cy="1" r="1" transform="matrix(-1 0 0 1 25 15)" fill="#4285F4"/><circle cx="1" cy="1" r="1" transform="matrix(-1 0 0 1 21 17)" fill="#4285F4"/><circle cx="8" cy="13" r="1" fill="#4285F4"/><circle cx="20" cy="15" r="1" fill="#4285F4"/><circle cx="24" cy="13" r="1" fill="#4285F4"/><circle cx="12" cy="9" r="1" fill="#4285F4"/><circle cx="16" cy="11" r="1" fill="#4285F4"/><circle cx="8" cy="10" r="1" fill="#4285F4"/><circle cx="12" cy="6" r="1" fill="#4285F4"/><circle cx="16" cy="8" r="1" fill="#4285F4"/><circle cx="20" cy="6" r="1" fill="#4285F4"/><circle cx="24" cy="4" r="1" fill="#4285F4"/></svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
|
|
@ -20,7 +20,7 @@ class GoogleVertexAIEmbedding_Embeddings implements INode {
|
|||
this.name = 'googlevertexaiEmbeddings'
|
||||
this.version = 1.0
|
||||
this.type = 'GoogleVertexAIEmbeddings'
|
||||
this.icon = 'vertexai.svg'
|
||||
this.icon = 'GoogleVertex.svg'
|
||||
this.category = 'Embeddings'
|
||||
this.description = 'Google vertexAI API to generate embeddings for a given text'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(GoogleVertexAIEmbeddings)]
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
<!-- from https://cloud.google.com/icons-->
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24px" height="24px"><path d="M20,13.89A.77.77,0,0,0,19,13.73l-7,5.14v.22a.72.72,0,1,1,0,1.43v0a.74.74,0,0,0,.45-.15l7.41-5.47A.76.76,0,0,0,20,13.89Z" style="fill:#669df6"/><path d="M12,20.52a.72.72,0,0,1,0-1.43h0v-.22L5,13.73a.76.76,0,0,0-1,.16.74.74,0,0,0,.16,1l7.41,5.47a.73.73,0,0,0,.44.15v0Z" style="fill:#aecbfa"/><path d="M12,18.34a1.47,1.47,0,1,0,1.47,1.47A1.47,1.47,0,0,0,12,18.34Zm0,2.18a.72.72,0,1,1,.72-.71A.71.71,0,0,1,12,20.52Z" style="fill:#4285f4"/><path d="M6,6.11a.76.76,0,0,1-.75-.75V3.48a.76.76,0,1,1,1.51,0V5.36A.76.76,0,0,1,6,6.11Z" style="fill:#aecbfa"/><circle cx="5.98" cy="12" r="0.76" style="fill:#aecbfa"/><circle cx="5.98" cy="9.79" r="0.76" style="fill:#aecbfa"/><circle cx="5.98" cy="7.57" r="0.76" style="fill:#aecbfa"/><path d="M18,8.31a.76.76,0,0,1-.75-.76V5.67a.75.75,0,1,1,1.5,0V7.55A.75.75,0,0,1,18,8.31Z" style="fill:#4285f4"/><circle cx="18.02" cy="12.01" r="0.76" style="fill:#4285f4"/><circle cx="18.02" cy="9.76" r="0.76" style="fill:#4285f4"/><circle cx="18.02" cy="3.48" r="0.76" style="fill:#4285f4"/><path d="M12,15a.76.76,0,0,1-.75-.75V12.34a.76.76,0,0,1,1.51,0v1.89A.76.76,0,0,1,12,15Z" style="fill:#669df6"/><circle cx="12" cy="16.45" r="0.76" style="fill:#669df6"/><circle cx="12" cy="10.14" r="0.76" style="fill:#669df6"/><circle cx="12" cy="7.92" r="0.76" style="fill:#669df6"/><path d="M15,10.54a.76.76,0,0,1-.75-.75V7.91a.76.76,0,1,1,1.51,0V9.79A.76.76,0,0,1,15,10.54Z" style="fill:#4285f4"/><circle cx="15.01" cy="5.69" r="0.76" style="fill:#4285f4"/><circle cx="15.01" cy="14.19" r="0.76" style="fill:#4285f4"/><circle cx="15.01" cy="11.97" r="0.76" style="fill:#4285f4"/><circle cx="8.99" cy="14.19" r="0.76" style="fill:#aecbfa"/><circle cx="8.99" cy="7.92" r="0.76" style="fill:#aecbfa"/><circle cx="8.99" cy="5.69" r="0.76" style="fill:#aecbfa"/><path d="M9,12.73A.76.76,0,0,1,8.24,12V10.1a.75.75,0,1,1,1.5,0V12A.75.75,0,0,1,9,12.73Z" style="fill:#aecbfa"/></svg>
|
||||
|
Before Width: | Height: | Size: 2.0 KiB |
|
|
@ -0,0 +1 @@
|
|||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#HuggingFace__a)"><circle cx="16" cy="15" r="13" fill="#FFD21E" stroke="#FF9D00" stroke-width="2"/><path d="M13 9a2 2 0 1 0-4 0m14 0a2 2 0 1 0-4 0m3 4c-1.466 1.246-3.61 2.031-6 2.031s-4.534-.785-6-2.031" stroke="#32343D" stroke-width="2" stroke-linecap="round"/><path d="m18.85 20.18.541-2.227a1.14 1.14 0 0 1 2.235.311l.02 1.899 3.14-3.484a1.144 1.144 0 1 1 1.619 1.618l-2.697 2.9 3.506-3.505a1.144 1.144 0 1 1 1.618 1.618l-3.506 3.506 2.532-2.323c.446-.447 1.066-.551 1.513-.105a1.144 1.144 0 0 1 0 1.618l-.845.846c.415-.318.953-.198 1.345.194a1.089 1.089 0 0 1-.078 1.61l-1.722 1.467-3.503 2.586a3.689 3.689 0 0 1-.631.376 4.273 4.273 0 0 1-4.838-.846l-.408-.408c-1.249-1.249-1.317-3.049-.679-4.695l.159-.41a5.12 5.12 0 0 0 .244-.832l.435-1.713Zm-5.901 0-.542-2.227a1.14 1.14 0 0 0-2.235.311l-.02 1.899-3.14-3.484a1.144 1.144 0 1 0-1.618 1.618l2.696 2.9-3.505-3.505a1.144 1.144 0 1 0-1.618 1.618l3.505 3.506-2.531-2.323c-.447-.447-1.067-.551-1.514-.105a1.144 1.144 0 0 0 0 1.618l.845.846c-.414-.318-.953-.198-1.345.194a1.089 1.089 0 0 0 .078 1.61l1.723 1.467 3.502 2.586c.198.146.41.272.631.376a4.273 4.273 0 0 0 4.839-.846l.407-.408c1.25-1.249 1.318-3.049.68-4.695l-.16-.41a5.14 5.14 0 0 1-.244-.832l-.434-1.713Z" fill="#FFD21E" stroke="#FF9D00" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><circle cx="7" cy="12" r="1" fill="#FFAD03"/><circle cx="25" cy="12" r="1" fill="#FFAD03"/></g><defs><clipPath id="HuggingFace__a"><path fill="#fff" d="M0 0h32v32H0z"/></clipPath></defs></svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
|
|
@ -19,7 +19,7 @@ class HuggingFaceInferenceEmbedding_Embeddings implements INode {
|
|||
this.name = 'huggingFaceInferenceEmbeddings'
|
||||
this.version = 1.0
|
||||
this.type = 'HuggingFaceInferenceEmbeddings'
|
||||
this.icon = 'huggingface.png'
|
||||
this.icon = 'HuggingFace.svg'
|
||||
this.category = 'Embeddings'
|
||||
this.description = 'HuggingFace Inference API to generate embeddings for a given text'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(HuggingFaceInferenceEmbeddings)]
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 118 KiB |
|
|
@ -0,0 +1 @@
|
|||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5 6H4v19.5h1m8-7.5v3h1m7-11.5V6h1m-5 7.5V10h1" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><mask id="MistralAI__a" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="5" y="6" width="22" height="20"><path d="M5 6v19.5h5v-8h4V21h4v-3.5h4V25h5V6h-4.5v4H18v3.5h-4v-4h-4V6H5Z" fill="#FD7000"/></mask><g mask="url(#MistralAI__a)"><path fill="#FFCD00" d="M4 6h25v4H4z"/></g><mask id="MistralAI__b" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="5" y="6" width="22" height="20"><path d="M5 6v19.5h5v-8h4V21h4v-3.5h4V25h5V6h-4.5v4H18v3.5h-4v-4h-4V6H5Z" fill="#FD7000"/></mask><g mask="url(#MistralAI__b)"><path fill="#FFA200" d="M4 10h25v4H4z"/></g><mask id="MistralAI__c" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="5" y="6" width="22" height="20"><path d="M5 6v19.5h5v-8h4V21h4v-3.5h4V25h5V6h-4.5v4H18v3.5h-4v-4h-4V6H5Z" fill="#FD7000"/></mask><g mask="url(#MistralAI__c)"><path fill="#FF6E00" d="M4 14h25v4H4z"/></g><mask id="MistralAI__d" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="5" y="6" width="22" height="20"><path d="M5 6v19.5h5v-8h4V21h4v-3.5h4V25h5V6h-4.5v4H18v3.5h-4v-4h-4V6H5Z" fill="#FD7000"/></mask><g mask="url(#MistralAI__d)"><path fill="#FF4A09" d="M4 18h25v4H4z"/></g><mask id="MistralAI__e" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="5" y="6" width="22" height="20"><path d="M5 6v19.5h5v-8h4V21h4v-3.5h4V25h5V6h-4.5v4H18v3.5h-4v-4h-4V6H5Z" fill="#FD7000"/></mask><g mask="url(#MistralAI__e)"><path fill="#FE060F" d="M4 22h25v4H4z"/></g><path d="M21 18v7h1" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M5 6v19.5h5v-8h4V21h4v-3.5h4V25h5V6h-4.5v4H18v3.5h-4v-4h-4V6H5Z" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
|
|
@ -19,7 +19,7 @@ class MistralEmbedding_Embeddings implements INode {
|
|||
this.name = 'mistralAI Embeddings'
|
||||
this.version = 1.0
|
||||
this.type = 'MistralAIEmbeddings'
|
||||
this.icon = 'mistralai.png'
|
||||
this.icon = 'MistralAI.svg'
|
||||
this.category = 'Embeddings'
|
||||
this.description = 'MistralAI API to generate embeddings for a given text'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(MistralAIEmbeddings)]
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 4.4 KiB |
|
|
@ -0,0 +1 @@
|
|||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7 27.5c0-1.273.388-2.388.97-3-.582-.612-.97-1.727-.97-3 0-1.293.4-2.422.996-3.028A4.818 4.818 0 0 1 7 15.5c0-2.485 1.79-4.5 4-4.5l.1.001a5.002 5.002 0 0 1 9.8 0L21 11c2.21 0 4 2.015 4 4.5 0 1.139-.376 2.18-.996 2.972.595.606.996 1.735.996 3.028 0 1.273-.389 2.388-.97 3 .581.612.97 1.727.97 3" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M9.5 11C9.167 8.5 9 4 11 4c1.5 0 1.667 2.667 2 4m9.5 3c.333-2.5.5-7-1.5-7-1.5 0-1.667 2.667-2 4" stroke="#000" stroke-width="2" stroke-linecap="round"/><circle cx="11" cy="15" r="1" fill="#000"/><circle cx="21" cy="15" r="1" fill="#000"/><path d="M13 17c0-2 2-2.5 3-2.5s3 .5 3 2.5-2 2.5-3 2.5-3-.5-3-2.5Z" stroke="#000" stroke-width="2" stroke-linecap="round"/></svg>
|
||||
|
After Width: | Height: | Size: 834 B |
|
|
@ -1,7 +1,7 @@
|
|||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { OllamaInput } from 'langchain/llms/ollama'
|
||||
import { OllamaEmbeddings } from 'langchain/embeddings/ollama'
|
||||
import { OllamaInput } from 'langchain/dist/util/ollama'
|
||||
|
||||
class OllamaEmbedding_Embeddings implements INode {
|
||||
label: string
|
||||
|
|
@ -20,7 +20,7 @@ class OllamaEmbedding_Embeddings implements INode {
|
|||
this.name = 'ollamaEmbedding'
|
||||
this.version = 1.0
|
||||
this.type = 'OllamaEmbeddings'
|
||||
this.icon = 'ollama.png'
|
||||
this.icon = 'Ollama.svg'
|
||||
this.category = 'Embeddings'
|
||||
this.description = 'Generate embeddings for a given text using open source model on Ollama'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(OllamaEmbeddings)]
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 7.3 KiB |
|
|
@ -1,5 +1 @@
|
|||
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M9.95804 14.1159C9.95804 14.4567 9.99488 14.733 10.0594 14.9357C10.133 15.1383 10.2251 15.3593 10.3541 15.5988C10.4001 15.6725 10.4186 15.7462 10.4186 15.8107C10.4186 15.9028 10.3633 15.9949 10.2436 16.087L9.6633 16.4738C9.58041 16.5291 9.49751 16.5567 9.42383 16.5567C9.33172 16.5567 9.23962 16.5107 9.14751 16.4278C9.01857 16.2896 8.90804 16.1422 8.81593 15.9949C8.72383 15.8383 8.63172 15.6633 8.53041 15.4514C7.81199 16.2988 6.90935 16.7225 5.82251 16.7225C5.04883 16.7225 4.43172 16.5014 3.98041 16.0593C3.52909 15.6172 3.29883 15.0278 3.29883 14.2909C3.29883 13.508 3.57514 12.8725 4.13699 12.3935C4.69883 11.9146 5.44488 11.6751 6.39357 11.6751C6.70672 11.6751 7.02909 11.7028 7.36988 11.7488C7.71067 11.7949 8.06067 11.8685 8.42909 11.9514V11.2791C8.42909 10.5791 8.28172 10.0909 7.9962 9.80539C7.70146 9.51986 7.20409 9.3817 6.49488 9.3817C6.17251 9.3817 5.84093 9.41855 5.50014 9.50144C5.15935 9.58434 4.82778 9.68565 4.50541 9.8146C4.35804 9.87907 4.24751 9.91591 4.18304 9.93434C4.11857 9.95276 4.07251 9.96197 4.03567 9.96197C3.90672 9.96197 3.84225 9.86986 3.84225 9.67644V9.22512C3.84225 9.07776 3.86067 8.96723 3.90672 8.90276C3.95278 8.83828 4.03567 8.77381 4.16462 8.70934C4.48699 8.54355 4.87383 8.40539 5.32514 8.29486C5.77646 8.17512 6.25541 8.11986 6.76199 8.11986C7.85804 8.11986 8.65936 8.36855 9.17515 8.86591C9.68172 9.36328 9.93962 10.1185 9.93962 11.1317V14.1159H9.95804ZM6.21857 15.5159C6.52251 15.5159 6.83567 15.4607 7.16725 15.3501C7.49883 15.2396 7.79357 15.037 8.04225 14.7607C8.18962 14.5857 8.30014 14.3922 8.35541 14.1712C8.41067 13.9501 8.44751 13.683 8.44751 13.3699V12.983C8.18041 12.9185 7.89488 12.8633 7.60014 12.8264C7.30541 12.7896 7.01988 12.7712 6.73436 12.7712C6.11725 12.7712 5.66593 12.8909 5.36199 13.1396C5.05804 13.3883 4.91067 13.7383 4.91067 14.1988C4.91067 14.6317 5.0212 14.9541 5.25146 15.1751C5.47251 15.4054 5.79488 15.5159 6.21857 15.5159ZM13.6146 16.5107C13.4488 16.5107 13.3383 16.483 13.2646 16.4185C13.1909 16.3633 13.1265 16.2343 13.0712 16.0593L10.9067 8.9396C10.8515 8.75539 10.8238 8.63565 10.8238 8.57118C10.8238 8.42381 10.8975 8.34091 11.0449 8.34091H11.9475C12.1225 8.34091 12.2423 8.36855 12.3067 8.43302C12.3804 8.48828 12.4357 8.61723 12.4909 8.79223L14.0383 14.8896L15.4751 8.79223C15.5212 8.60802 15.5765 8.48828 15.6501 8.43302C15.7238 8.37776 15.8528 8.34091 16.0186 8.34091H16.7554C16.9304 8.34091 17.0501 8.36855 17.1238 8.43302C17.1975 8.48828 17.262 8.61723 17.2988 8.79223L18.7541 14.9633L20.3475 8.79223C20.4028 8.60802 20.4673 8.48828 20.5317 8.43302C20.6054 8.37776 20.7251 8.34091 20.8909 8.34091H21.7475C21.8949 8.34091 21.9778 8.4146 21.9778 8.57118C21.9778 8.61723 21.9686 8.66328 21.9594 8.71855C21.9501 8.77381 21.9317 8.84749 21.8949 8.94881L19.6751 16.0685C19.6199 16.2528 19.5554 16.3725 19.4817 16.4278C19.408 16.483 19.2883 16.5199 19.1317 16.5199H18.3396C18.1646 16.5199 18.0449 16.4922 17.9712 16.4278C17.8975 16.3633 17.833 16.2435 17.7962 16.0593L16.3686 10.1185L14.9501 16.0501C14.9041 16.2343 14.8488 16.3541 14.7751 16.4185C14.7015 16.483 14.5725 16.5107 14.4067 16.5107H13.6146ZM25.4501 16.7593C24.9712 16.7593 24.4923 16.7041 24.0317 16.5935C23.5712 16.483 23.212 16.3633 22.9725 16.2251C22.8251 16.1422 22.7238 16.0501 22.687 15.9672C22.6501 15.8843 22.6317 15.7922 22.6317 15.7093V15.2396C22.6317 15.0462 22.7054 14.9541 22.8436 14.9541C22.8988 14.9541 22.9541 14.9633 23.0094 14.9817C23.0646 15.0001 23.1475 15.037 23.2396 15.0738C23.5528 15.212 23.8936 15.3225 24.2528 15.3962C24.6212 15.4699 24.9804 15.5067 25.3488 15.5067C25.9291 15.5067 26.3804 15.4054 26.6936 15.2028C27.0067 15.0001 27.1725 14.7054 27.1725 14.3278C27.1725 14.0699 27.0896 13.858 26.9238 13.683C26.758 13.508 26.4449 13.3514 25.9936 13.2041L24.658 12.7896C23.9857 12.5778 23.4883 12.2646 23.1844 11.8501C22.8804 11.4449 22.7238 10.9935 22.7238 10.5146C22.7238 10.1278 22.8067 9.78697 22.9725 9.49223C23.1383 9.19749 23.3594 8.9396 23.6357 8.73697C23.912 8.52512 24.2251 8.36855 24.5936 8.25802C24.962 8.14749 25.3488 8.10144 25.7541 8.10144C25.9567 8.10144 26.1686 8.11065 26.3712 8.13828C26.583 8.16591 26.7765 8.20276 26.9699 8.2396C27.1541 8.28565 27.3291 8.3317 27.4949 8.38697C27.6607 8.44223 27.7896 8.49749 27.8817 8.55276C28.0107 8.62644 28.1028 8.70012 28.158 8.78302C28.2133 8.8567 28.2409 8.95802 28.2409 9.08697V9.51986C28.2409 9.71328 28.1673 9.8146 28.0291 9.8146C27.9554 9.8146 27.8357 9.77776 27.6791 9.70407C27.1541 9.4646 26.5646 9.34486 25.9107 9.34486C25.3857 9.34486 24.9712 9.42776 24.6857 9.60276C24.4001 9.77776 24.2528 10.0449 24.2528 10.4225C24.2528 10.6804 24.3449 10.9014 24.5291 11.0764C24.7133 11.2514 25.0541 11.4264 25.5423 11.583L26.8501 11.9975C27.5133 12.2093 27.9923 12.5041 28.2778 12.8817C28.5633 13.2593 28.7015 13.6922 28.7015 14.1712C28.7015 14.5672 28.6186 14.9264 28.462 15.2396C28.2962 15.5528 28.0751 15.8291 27.7896 16.0501C27.5041 16.2804 27.1633 16.4462 26.7673 16.5659C26.3528 16.6949 25.9199 16.7593 25.4501 16.7593Z" fill="#252F3E"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M27.191 21.2357C24.1607 23.4739 19.7581 24.662 15.9725 24.662C10.6673 24.662 5.88702 22.7002 2.27649 19.4397C1.99097 19.1818 2.24886 18.8318 2.58965 19.0344C6.49492 21.3002 11.312 22.6726 16.2949 22.6726C19.6568 22.6726 23.3502 21.9726 26.7489 20.5357C27.2554 20.3054 27.6883 20.8673 27.191 21.2357Z" fill="#FF9900"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M28.4527 19.7989C28.0659 19.3015 25.8922 19.5594 24.9067 19.6791C24.6119 19.716 24.5659 19.4581 24.833 19.2647C26.5645 18.0489 29.4106 18.3989 29.7422 18.8041C30.0738 19.2186 29.6501 22.0647 28.029 23.4278C27.7803 23.6397 27.5409 23.5291 27.6514 23.2528C28.0198 22.341 28.8396 20.287 28.4527 19.7989Z" fill="#FF9900"/>
|
||||
</svg>
|
||||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 21c1.67 1.77 5.491 3 9.757 3 2.788 0 5.386-.525 7.317-1.383L25 21.65" stroke="#F90" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="m23 20 3 1.074L25.4 24" stroke="#F90" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M24.564 9.44C23.677 8.76 21 8.633 21 10.796c0 2.396 4 .77 4 3.294 0 1.898-2.67 2.501-4 1.264M14 9v7l2-4 2 4V9" stroke="#252F3E" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M7.053 8.597H8.21a2.526 2.526 0 0 1 2.526 2.526v4.842" stroke="#252F3E" stroke-width="2" stroke-linecap="round"/><circle cx="8.632" cy="13.86" stroke="#252F3E" stroke-width="2" r="2.105"/></svg>
|
||||
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 753 B |
|
|
@ -1 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="96px" height="96px"><path fill="#035bda" d="M46 40L29.317 10.852 22.808 23.96 34.267 37.24 13 39.655zM13.092 18.182L2 36.896 11.442 35.947 28.033 5.678z"/></svg>
|
||||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M11.946 5H19l-7.322 22.216a1.15 1.15 0 0 1-.41.568c-.19.14-.42.216-.656.216H5.123a1.11 1.11 0 0 1-.513-.127 1.132 1.132 0 0 1-.4-.352 1.165 1.165 0 0 1-.151-1.038l6.822-20.7a1.15 1.15 0 0 1 .41-.567c.19-.14.42-.216.655-.216Z" fill="#0A5FAB"/><path d="M22.334 20H11.502c-.1 0-.2.031-.282.09a.52.52 0 0 0-.185.241.545.545 0 0 0 .125.576l6.96 6.786c.203.197.47.307.747.307H25l-2.666-8Z" fill="#0078D4"/><path d="M21.035 5.782a1.149 1.149 0 0 0-.415-.566A1.128 1.128 0 0 0 19.957 5H12c.238 0 .47.076.663.216.193.14.338.338.414.566l6.906 20.7a1.16 1.16 0 0 1-.558 1.391 1.12 1.12 0 0 1-.52.127h7.959a1.127 1.127 0 0 0 .923-.48 1.159 1.159 0 0 0 .153-1.038l-6.905-20.7Z" fill="#2C9DE3"/></svg>
|
||||
|
Before Width: | Height: | Size: 229 B After Width: | Height: | Size: 771 B |
|
|
@ -20,7 +20,7 @@ class Bittensor_LLMs implements INode {
|
|||
this.name = 'NIBittensorLLM'
|
||||
this.version = 2.0
|
||||
this.type = 'Bittensor'
|
||||
this.icon = 'logo.png'
|
||||
this.icon = 'NIBittensor.svg'
|
||||
this.category = 'LLMs'
|
||||
this.description = 'Wrapper around Bittensor subnet 1 large language models'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(NIBittensorLLM)]
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18.64 25.698V29H8l1.61-6.25a9.81 9.81 0 0 0-.045-4.5C9.027 15.808 8 15.394 8 10.824c.01-2.35.916-4.601 2.517-6.256C12.12 2.913 14.285 1.989 16.54 2c2.254.01 4.412.955 5.999 2.625 1.587 1.67 2.472 3.93 2.462 6.28V12l2 4h-2v4.208a3.821 3.821 0 0 1-1.08 2.373 3.531 3.531 0 0 1-2.306 1.054c-.165.01-.375.004-.606-.012-1.242-.085-2.367.83-2.367 2.075Z" fill="#000" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M21 13h-2l-1-2m3-1-1-2h-4m-3 1 2 4m-1 6 3-3h4" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
||||
|
After Width: | Height: | Size: 666 B |
|
Before Width: | Height: | Size: 24 KiB |
|
|
@ -0,0 +1 @@
|
|||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M11.776 18.304c.64 0 1.92-.032 3.712-.768 2.08-.864 6.176-2.4 9.152-4 2.08-1.12 2.976-2.592 2.976-4.576 0-2.72-2.208-4.96-4.96-4.96h-11.52A7.143 7.143 0 0 0 4 11.136c0 3.936 3.008 7.168 7.776 7.168Z" fill="#39594D"/><path fill-rule="evenodd" clip-rule="evenodd" d="M13.728 23.2c0-1.92 1.152-3.68 2.944-4.416l3.616-1.504C23.968 15.776 28 18.464 28 22.432A5.572 5.572 0 0 1 22.432 28h-3.936c-2.624 0-4.768-2.144-4.768-4.8Z" fill="#D18EE2"/><path d="M8.128 19.232A4.138 4.138 0 0 0 4 23.36v.544C4 26.144 5.856 28 8.128 28a4.138 4.138 0 0 0 4.128-4.128v-.544c-.032-2.24-1.856-4.096-4.128-4.096Z" fill="#FF7759"/></svg>
|
||||
|
After Width: | Height: | Size: 738 B |
|
|
@ -20,7 +20,7 @@ class Cohere_LLMs implements INode {
|
|||
this.name = 'cohere'
|
||||
this.version = 2.0
|
||||
this.type = 'Cohere'
|
||||
this.icon = 'cohere.png'
|
||||
this.icon = 'Cohere.svg'
|
||||
this.category = 'LLMs'
|
||||
this.description = 'Wrapper around Cohere large language models'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(Cohere)]
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 7.7 KiB |
|
|
@ -0,0 +1 @@
|
|||
<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>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
|
|
@ -19,7 +19,7 @@ class GooglePaLM_LLMs implements INode {
|
|||
this.name = 'GooglePaLM'
|
||||
this.version = 2.0
|
||||
this.type = 'GooglePaLM'
|
||||
this.icon = 'Google_PaLM_Logo.svg'
|
||||
this.icon = 'GooglePaLM.svg'
|
||||
this.category = 'LLMs'
|
||||
this.description = 'Wrapper around Google MakerSuite PaLM large language models'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(GooglePaLM)]
|
||||
|
|
|
|||
|
|
@ -1,67 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 27.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Standard_product_icon__x28_1:1_x29_"
|
||||
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="192px" height="192px"
|
||||
viewBox="0 0 192 192" enable-background="new 0 0 192 192" xml:space="preserve">
|
||||
<symbol id="material_x5F_product_x5F_standard_x5F_icon_x5F_keylines_00000077318920148093339210000006245950728745084294_" viewBox="-96 -96 192 192">
|
||||
<g opacity="0.4">
|
||||
<defs>
|
||||
<path id="SVGID_1_" opacity="0.4" d="M-96,96V-96H96V96H-96z"/>
|
||||
</defs>
|
||||
<clipPath id="SVGID_00000071517564283228984050000017848131202901217410_">
|
||||
<use xlink:href="#SVGID_1_" overflow="visible"/>
|
||||
</clipPath>
|
||||
<g clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)">
|
||||
<g>
|
||||
<path d="M95.75,95.75v-191.5h-191.5v191.5H95.75 M96,96H-96V-96H96V96L96,96z"/>
|
||||
</g>
|
||||
<circle fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" cx="0" cy="0" r="64"/>
|
||||
</g>
|
||||
|
||||
<circle clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)" fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" cx="0" cy="0" r="88"/>
|
||||
|
||||
<path clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)" fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" d="
|
||||
M64,76H-64c-6.6,0-12-5.4-12-12V-64c0-6.6,5.4-12,12-12H64c6.6,0,12,5.4,12,12V64C76,70.6,70.6,76,64,76z"/>
|
||||
|
||||
<path clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)" fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" d="
|
||||
M52,88H-52c-6.6,0-12-5.4-12-12V-76c0-6.6,5.4-12,12-12H52c6.6,0,12,5.4,12,12V76C64,82.6,58.6,88,52,88z"/>
|
||||
|
||||
<path clip-path="url(#SVGID_00000071517564283228984050000017848131202901217410_)" fill="none" stroke="#000000" stroke-width="0.25" stroke-miterlimit="10" d="
|
||||
M76,64H-76c-6.6,0-12-5.4-12-12V-52c0-6.6,5.4-12,12-12H76c6.6,0,12,5.4,12,12V52C88,58.6,82.6,64,76,64z"/>
|
||||
</g>
|
||||
</symbol>
|
||||
<rect id="bounding_box_1_" display="none" fill="none" width="192" height="192"/>
|
||||
<g id="art_layer">
|
||||
<g>
|
||||
<path fill="#F9AB00" d="M96,181.92L96,181.92c6.63,0,12-5.37,12-12v-104H84v104C84,176.55,89.37,181.92,96,181.92z"/>
|
||||
<g>
|
||||
<path fill="#5BB974" d="M143.81,103.87C130.87,90.94,111.54,88.32,96,96l51.37,51.37c2.12,2.12,5.77,1.28,6.67-1.57
|
||||
C158.56,131.49,155.15,115.22,143.81,103.87z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#129EAF" d="M48.19,103.87C61.13,90.94,80.46,88.32,96,96l-51.37,51.37c-2.12,2.12-5.77,1.28-6.67-1.57
|
||||
C33.44,131.49,36.85,115.22,48.19,103.87z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#AF5CF7" d="M140,64c-20.44,0-37.79,13.4-44,32h81.24c3.33,0,5.55-3.52,4.04-6.49C173.56,74.36,157.98,64,140,64z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#FF8BCB" d="M104.49,42.26C90.03,56.72,87.24,78.45,96,96l57.45-57.45c2.36-2.36,1.44-6.42-1.73-7.45
|
||||
C135.54,25.85,117.2,29.55,104.49,42.26z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#FA7B17" d="M87.51,42.26C101.97,56.72,104.76,78.45,96,96L38.55,38.55c-2.36-2.36-1.44-6.42,1.73-7.45
|
||||
C56.46,25.85,74.8,29.55,87.51,42.26z"/>
|
||||
</g>
|
||||
<g>
|
||||
<g>
|
||||
<path fill="#4285F4" d="M52,64c20.44,0,37.79,13.4,44,32H14.76c-3.33,0-5.55-3.52-4.04-6.49C18.44,74.36,34.02,64,52,64z"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g id="keylines" display="none">
|
||||
|
||||
<use xlink:href="#material_x5F_product_x5F_standard_x5F_icon_x5F_keylines_00000077318920148093339210000006245950728745084294_" width="192" height="192" id="material_x5F_product_x5F_standard_x5F_icon_x5F_keylines" x="-96" y="-96" transform="matrix(1 0 0 -1 96 96)" display="inline" overflow="visible"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 3.6 KiB |
|
|
@ -0,0 +1 @@
|
|||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8 6.5V4m4 10.5V12m4 4.5V14m4-2.5V9m4 .5V7m-8 19.5 9-6.5m-9 6.5L7 20" stroke="#4285F4" stroke-width="2" stroke-linecap="round"/><circle cx="16" cy="26" r="2" fill="#fff" stroke="#4285F4" stroke-width="2"/><circle cx="8" cy="16" r="1" fill="#4285F4"/><circle cx="12" cy="18" r="1" fill="#4285F4"/><circle cx="16" cy="20" r="1" fill="#4285F4"/><circle cx="1" cy="1" r="1" transform="matrix(-1 0 0 1 25 15)" fill="#4285F4"/><circle cx="1" cy="1" r="1" transform="matrix(-1 0 0 1 21 17)" fill="#4285F4"/><circle cx="8" cy="13" r="1" fill="#4285F4"/><circle cx="20" cy="15" r="1" fill="#4285F4"/><circle cx="24" cy="13" r="1" fill="#4285F4"/><circle cx="12" cy="9" r="1" fill="#4285F4"/><circle cx="16" cy="11" r="1" fill="#4285F4"/><circle cx="8" cy="10" r="1" fill="#4285F4"/><circle cx="12" cy="6" r="1" fill="#4285F4"/><circle cx="16" cy="8" r="1" fill="#4285F4"/><circle cx="20" cy="6" r="1" fill="#4285F4"/><circle cx="24" cy="4" r="1" fill="#4285F4"/></svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
|
|
@ -21,7 +21,7 @@ class GoogleVertexAI_LLMs implements INode {
|
|||
this.name = 'googlevertexai'
|
||||
this.version = 2.0
|
||||
this.type = 'GoogleVertexAI'
|
||||
this.icon = 'vertexai.svg'
|
||||
this.icon = 'GoogleVertex.svg'
|
||||
this.category = 'LLMs'
|
||||
this.description = 'Wrapper around GoogleVertexAI large language models'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(GoogleVertexAI)]
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
<!-- from https://cloud.google.com/icons-->
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24px" height="24px"><path d="M20,13.89A.77.77,0,0,0,19,13.73l-7,5.14v.22a.72.72,0,1,1,0,1.43v0a.74.74,0,0,0,.45-.15l7.41-5.47A.76.76,0,0,0,20,13.89Z" style="fill:#669df6"/><path d="M12,20.52a.72.72,0,0,1,0-1.43h0v-.22L5,13.73a.76.76,0,0,0-1,.16.74.74,0,0,0,.16,1l7.41,5.47a.73.73,0,0,0,.44.15v0Z" style="fill:#aecbfa"/><path d="M12,18.34a1.47,1.47,0,1,0,1.47,1.47A1.47,1.47,0,0,0,12,18.34Zm0,2.18a.72.72,0,1,1,.72-.71A.71.71,0,0,1,12,20.52Z" style="fill:#4285f4"/><path d="M6,6.11a.76.76,0,0,1-.75-.75V3.48a.76.76,0,1,1,1.51,0V5.36A.76.76,0,0,1,6,6.11Z" style="fill:#aecbfa"/><circle cx="5.98" cy="12" r="0.76" style="fill:#aecbfa"/><circle cx="5.98" cy="9.79" r="0.76" style="fill:#aecbfa"/><circle cx="5.98" cy="7.57" r="0.76" style="fill:#aecbfa"/><path d="M18,8.31a.76.76,0,0,1-.75-.76V5.67a.75.75,0,1,1,1.5,0V7.55A.75.75,0,0,1,18,8.31Z" style="fill:#4285f4"/><circle cx="18.02" cy="12.01" r="0.76" style="fill:#4285f4"/><circle cx="18.02" cy="9.76" r="0.76" style="fill:#4285f4"/><circle cx="18.02" cy="3.48" r="0.76" style="fill:#4285f4"/><path d="M12,15a.76.76,0,0,1-.75-.75V12.34a.76.76,0,0,1,1.51,0v1.89A.76.76,0,0,1,12,15Z" style="fill:#669df6"/><circle cx="12" cy="16.45" r="0.76" style="fill:#669df6"/><circle cx="12" cy="10.14" r="0.76" style="fill:#669df6"/><circle cx="12" cy="7.92" r="0.76" style="fill:#669df6"/><path d="M15,10.54a.76.76,0,0,1-.75-.75V7.91a.76.76,0,1,1,1.51,0V9.79A.76.76,0,0,1,15,10.54Z" style="fill:#4285f4"/><circle cx="15.01" cy="5.69" r="0.76" style="fill:#4285f4"/><circle cx="15.01" cy="14.19" r="0.76" style="fill:#4285f4"/><circle cx="15.01" cy="11.97" r="0.76" style="fill:#4285f4"/><circle cx="8.99" cy="14.19" r="0.76" style="fill:#aecbfa"/><circle cx="8.99" cy="7.92" r="0.76" style="fill:#aecbfa"/><circle cx="8.99" cy="5.69" r="0.76" style="fill:#aecbfa"/><path d="M9,12.73A.76.76,0,0,1,8.24,12V10.1a.75.75,0,1,1,1.5,0V12A.75.75,0,0,1,9,12.73Z" style="fill:#aecbfa"/></svg>
|
||||
|
Before Width: | Height: | Size: 2.0 KiB |
|
|
@ -0,0 +1 @@
|
|||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#HuggingFace__a)"><circle cx="16" cy="15" r="13" fill="#FFD21E" stroke="#FF9D00" stroke-width="2"/><path d="M13 9a2 2 0 1 0-4 0m14 0a2 2 0 1 0-4 0m3 4c-1.466 1.246-3.61 2.031-6 2.031s-4.534-.785-6-2.031" stroke="#32343D" stroke-width="2" stroke-linecap="round"/><path d="m18.85 20.18.541-2.227a1.14 1.14 0 0 1 2.235.311l.02 1.899 3.14-3.484a1.144 1.144 0 1 1 1.619 1.618l-2.697 2.9 3.506-3.505a1.144 1.144 0 1 1 1.618 1.618l-3.506 3.506 2.532-2.323c.446-.447 1.066-.551 1.513-.105a1.144 1.144 0 0 1 0 1.618l-.845.846c.415-.318.953-.198 1.345.194a1.089 1.089 0 0 1-.078 1.61l-1.722 1.467-3.503 2.586a3.689 3.689 0 0 1-.631.376 4.273 4.273 0 0 1-4.838-.846l-.408-.408c-1.249-1.249-1.317-3.049-.679-4.695l.159-.41a5.12 5.12 0 0 0 .244-.832l.435-1.713Zm-5.901 0-.542-2.227a1.14 1.14 0 0 0-2.235.311l-.02 1.899-3.14-3.484a1.144 1.144 0 1 0-1.618 1.618l2.696 2.9-3.505-3.505a1.144 1.144 0 1 0-1.618 1.618l3.505 3.506-2.531-2.323c-.447-.447-1.067-.551-1.514-.105a1.144 1.144 0 0 0 0 1.618l.845.846c-.414-.318-.953-.198-1.345.194a1.089 1.089 0 0 0 .078 1.61l1.723 1.467 3.502 2.586c.198.146.41.272.631.376a4.273 4.273 0 0 0 4.839-.846l.407-.408c1.25-1.249 1.318-3.049.68-4.695l-.16-.41a5.14 5.14 0 0 1-.244-.832l-.434-1.713Z" fill="#FFD21E" stroke="#FF9D00" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><circle cx="7" cy="12" r="1" fill="#FFAD03"/><circle cx="25" cy="12" r="1" fill="#FFAD03"/></g><defs><clipPath id="HuggingFace__a"><path fill="#fff" d="M0 0h32v32H0z"/></clipPath></defs></svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
|
|
@ -20,7 +20,7 @@ class HuggingFaceInference_LLMs implements INode {
|
|||
this.name = 'huggingFaceInference_LLMs'
|
||||
this.version = 2.0
|
||||
this.type = 'HuggingFaceInference'
|
||||
this.icon = 'huggingface.png'
|
||||
this.icon = 'HuggingFace.svg'
|
||||
this.category = 'LLMs'
|
||||
this.description = 'Wrapper around HuggingFace large language models'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(HuggingFaceInference)]
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 118 KiB |
|
|
@ -0,0 +1 @@
|
|||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7 27.5c0-1.273.388-2.388.97-3-.582-.612-.97-1.727-.97-3 0-1.293.4-2.422.996-3.028A4.818 4.818 0 0 1 7 15.5c0-2.485 1.79-4.5 4-4.5l.1.001a5.002 5.002 0 0 1 9.8 0L21 11c2.21 0 4 2.015 4 4.5 0 1.139-.376 2.18-.996 2.972.595.606.996 1.735.996 3.028 0 1.273-.389 2.388-.97 3 .581.612.97 1.727.97 3" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M9.5 11C9.167 8.5 9 4 11 4c1.5 0 1.667 2.667 2 4m9.5 3c.333-2.5.5-7-1.5-7-1.5 0-1.667 2.667-2 4" stroke="#000" stroke-width="2" stroke-linecap="round"/><circle cx="11" cy="15" r="1" fill="#000"/><circle cx="21" cy="15" r="1" fill="#000"/><path d="M13 17c0-2 2-2.5 3-2.5s3 .5 3 2.5-2 2.5-3 2.5-3-.5-3-2.5Z" stroke="#000" stroke-width="2" stroke-linecap="round"/></svg>
|
||||
|
After Width: | Height: | Size: 834 B |
|
|
@ -1,8 +1,7 @@
|
|||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { Ollama } from 'langchain/llms/ollama'
|
||||
import { Ollama, OllamaInput } from 'langchain/llms/ollama'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
import { OllamaInput } from 'langchain/dist/util/ollama'
|
||||
import { BaseLLMParams } from 'langchain/llms/base'
|
||||
|
||||
class Ollama_LLMs implements INode {
|
||||
|
|
@ -22,7 +21,7 @@ class Ollama_LLMs implements INode {
|
|||
this.name = 'ollama'
|
||||
this.version = 2.0
|
||||
this.type = 'Ollama'
|
||||
this.icon = 'ollama.png'
|
||||
this.icon = 'Ollama.svg'
|
||||
this.category = 'LLMs'
|
||||
this.description = 'Wrapper around open source large language models on Ollama'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(Ollama)]
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 7.3 KiB |
|
|
@ -1,6 +1,7 @@
|
|||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { BufferMemory } from 'langchain/memory'
|
||||
import { FlowiseMemory, IMessage, INode, INodeData, INodeParams, MemoryMethods, MessageType } from '../../../src/Interface'
|
||||
import { convertBaseMessagetoIMessage, getBaseClasses } from '../../../src/utils'
|
||||
import { BufferMemory, BufferMemoryInput } from 'langchain/memory'
|
||||
import { BaseMessage } from 'langchain/schema'
|
||||
|
||||
class BufferMemory_Memory implements INode {
|
||||
label: string
|
||||
|
|
@ -41,7 +42,7 @@ class BufferMemory_Memory implements INode {
|
|||
async init(nodeData: INodeData): Promise<any> {
|
||||
const memoryKey = nodeData.inputs?.memoryKey as string
|
||||
const inputKey = nodeData.inputs?.inputKey as string
|
||||
return new BufferMemory({
|
||||
return new BufferMemoryExtended({
|
||||
returnMessages: true,
|
||||
memoryKey,
|
||||
inputKey
|
||||
|
|
@ -49,4 +50,41 @@ class BufferMemory_Memory implements INode {
|
|||
}
|
||||
}
|
||||
|
||||
class BufferMemoryExtended extends FlowiseMemory implements MemoryMethods {
|
||||
constructor(fields: BufferMemoryInput) {
|
||||
super(fields)
|
||||
}
|
||||
|
||||
async getChatMessages(_?: string, returnBaseMessages = false): Promise<IMessage[] | BaseMessage[]> {
|
||||
const memoryResult = await this.loadMemoryVariables({})
|
||||
const baseMessages = memoryResult[this.memoryKey ?? 'chat_history']
|
||||
return returnBaseMessages ? baseMessages : convertBaseMessagetoIMessage(baseMessages)
|
||||
}
|
||||
|
||||
async addChatMessages(msgArray: { text: string; type: MessageType }[]): Promise<void> {
|
||||
const input = msgArray.find((msg) => msg.type === 'userMessage')
|
||||
const output = msgArray.find((msg) => msg.type === 'apiMessage')
|
||||
|
||||
const inputValues = { [this.inputKey ?? 'input']: input?.text }
|
||||
const outputValues = { output: output?.text }
|
||||
|
||||
await this.saveContext(inputValues, outputValues)
|
||||
}
|
||||
|
||||
async clearChatMessages(): Promise<void> {
|
||||
await this.clear()
|
||||
}
|
||||
|
||||
async resumeMessages(messages: IMessage[]): Promise<void> {
|
||||
// Clear existing chatHistory to avoid duplication
|
||||
if (messages.length) await this.clear()
|
||||
|
||||
// Insert into chatHistory
|
||||
for (const msg of messages) {
|
||||
if (msg.type === 'userMessage') await this.chatHistory.addUserMessage(msg.message)
|
||||
else if (msg.type === 'apiMessage') await this.chatHistory.addAIChatMessage(msg.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: BufferMemory_Memory }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { FlowiseWindowMemory, IMessage, INode, INodeData, INodeParams, MemoryMethods, MessageType } from '../../../src/Interface'
|
||||
import { convertBaseMessagetoIMessage, getBaseClasses } from '../../../src/utils'
|
||||
import { BufferWindowMemory, BufferWindowMemoryInput } from 'langchain/memory'
|
||||
import { BaseMessage } from 'langchain/schema'
|
||||
|
||||
class BufferWindowMemory_Memory implements INode {
|
||||
label: string
|
||||
|
|
@ -57,7 +58,44 @@ class BufferWindowMemory_Memory implements INode {
|
|||
k: parseInt(k, 10)
|
||||
}
|
||||
|
||||
return new BufferWindowMemory(obj)
|
||||
return new BufferWindowMemoryExtended(obj)
|
||||
}
|
||||
}
|
||||
|
||||
class BufferWindowMemoryExtended extends FlowiseWindowMemory implements MemoryMethods {
|
||||
constructor(fields: BufferWindowMemoryInput) {
|
||||
super(fields)
|
||||
}
|
||||
|
||||
async getChatMessages(_?: string, returnBaseMessages = false): Promise<IMessage[] | BaseMessage[]> {
|
||||
const memoryResult = await this.loadMemoryVariables({})
|
||||
const baseMessages = memoryResult[this.memoryKey ?? 'chat_history']
|
||||
return returnBaseMessages ? baseMessages : convertBaseMessagetoIMessage(baseMessages)
|
||||
}
|
||||
|
||||
async addChatMessages(msgArray: { text: string; type: MessageType }[]): Promise<void> {
|
||||
const input = msgArray.find((msg) => msg.type === 'userMessage')
|
||||
const output = msgArray.find((msg) => msg.type === 'apiMessage')
|
||||
|
||||
const inputValues = { [this.inputKey ?? 'input']: input?.text }
|
||||
const outputValues = { output: output?.text }
|
||||
|
||||
await this.saveContext(inputValues, outputValues)
|
||||
}
|
||||
|
||||
async clearChatMessages(): Promise<void> {
|
||||
await this.clear()
|
||||
}
|
||||
|
||||
async resumeMessages(messages: IMessage[]): Promise<void> {
|
||||
// Clear existing chatHistory to avoid duplication
|
||||
if (messages.length) await this.clear()
|
||||
|
||||
// Insert into chatHistory
|
||||
for (const msg of messages) {
|
||||
if (msg.type === 'userMessage') await this.chatHistory.addUserMessage(msg.message)
|
||||
else if (msg.type === 'apiMessage') await this.chatHistory.addAIChatMessage(msg.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { FlowiseSummaryMemory, IMessage, INode, INodeData, INodeParams, MemoryMethods, MessageType } from '../../../src/Interface'
|
||||
import { convertBaseMessagetoIMessage, getBaseClasses } from '../../../src/utils'
|
||||
import { ConversationSummaryMemory, ConversationSummaryMemoryInput } from 'langchain/memory'
|
||||
import { BaseLanguageModel } from 'langchain/base_language'
|
||||
import { BaseMessage } from 'langchain/schema'
|
||||
|
||||
class ConversationSummaryMemory_Memory implements INode {
|
||||
label: string
|
||||
|
|
@ -56,7 +57,48 @@ class ConversationSummaryMemory_Memory implements INode {
|
|||
inputKey
|
||||
}
|
||||
|
||||
return new ConversationSummaryMemory(obj)
|
||||
return new ConversationSummaryMemoryExtended(obj)
|
||||
}
|
||||
}
|
||||
|
||||
class ConversationSummaryMemoryExtended extends FlowiseSummaryMemory implements MemoryMethods {
|
||||
constructor(fields: ConversationSummaryMemoryInput) {
|
||||
super(fields)
|
||||
}
|
||||
|
||||
async getChatMessages(_?: string, returnBaseMessages = false): Promise<IMessage[] | BaseMessage[]> {
|
||||
const memoryResult = await this.loadMemoryVariables({})
|
||||
const baseMessages = memoryResult[this.memoryKey ?? 'chat_history']
|
||||
return returnBaseMessages ? baseMessages : convertBaseMessagetoIMessage(baseMessages)
|
||||
}
|
||||
|
||||
async addChatMessages(msgArray: { text: string; type: MessageType }[]): Promise<void> {
|
||||
const input = msgArray.find((msg) => msg.type === 'userMessage')
|
||||
const output = msgArray.find((msg) => msg.type === 'apiMessage')
|
||||
|
||||
const inputValues = { [this.inputKey ?? 'input']: input?.text }
|
||||
const outputValues = { output: output?.text }
|
||||
|
||||
await this.saveContext(inputValues, outputValues)
|
||||
}
|
||||
|
||||
async clearChatMessages(): Promise<void> {
|
||||
await this.clear()
|
||||
}
|
||||
|
||||
async resumeMessages(messages: IMessage[]): Promise<void> {
|
||||
// Clear existing chatHistory to avoid duplication
|
||||
if (messages.length) await this.clear()
|
||||
|
||||
// Insert into chatHistory
|
||||
for (const msg of messages) {
|
||||
if (msg.type === 'userMessage') await this.chatHistory.addUserMessage(msg.message)
|
||||
else if (msg.type === 'apiMessage') await this.chatHistory.addAIChatMessage(msg.message)
|
||||
}
|
||||
|
||||
// Replace buffer
|
||||
const chatMessages = await this.chatHistory.getMessages()
|
||||
this.buffer = await this.predictNewSummary(chatMessages.slice(-2), this.buffer)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,25 @@
|
|||
import {
|
||||
ICommonObject,
|
||||
INode,
|
||||
INodeData,
|
||||
INodeParams,
|
||||
DynamoDBClient,
|
||||
DynamoDBClientConfig,
|
||||
GetItemCommand,
|
||||
GetItemCommandInput,
|
||||
UpdateItemCommand,
|
||||
UpdateItemCommandInput,
|
||||
DeleteItemCommand,
|
||||
DeleteItemCommandInput,
|
||||
AttributeValue
|
||||
} from '@aws-sdk/client-dynamodb'
|
||||
import { DynamoDBChatMessageHistory } from 'langchain/stores/message/dynamodb'
|
||||
import { BufferMemory, BufferMemoryInput } from 'langchain/memory'
|
||||
import { mapStoredMessageToChatMessage, AIMessage, HumanMessage, StoredMessage, BaseMessage } from 'langchain/schema'
|
||||
import {
|
||||
convertBaseMessagetoIMessage,
|
||||
getBaseClasses,
|
||||
getCredentialData,
|
||||
getCredentialParam,
|
||||
serializeChatHistory
|
||||
} from '../../../src'
|
||||
import { DynamoDBChatMessageHistory } from 'langchain/stores/message/dynamodb'
|
||||
import { BufferMemory, BufferMemoryInput } from 'langchain/memory'
|
||||
} from '../../../src/utils'
|
||||
import { FlowiseMemory, ICommonObject, IMessage, INode, INodeData, INodeParams, MemoryMethods, MessageType } from '../../../src/Interface'
|
||||
|
||||
class DynamoDb_Memory implements INode {
|
||||
label: string
|
||||
|
|
@ -102,49 +112,203 @@ class DynamoDb_Memory implements INode {
|
|||
const initalizeDynamoDB = async (nodeData: INodeData, options: ICommonObject): Promise<BufferMemory> => {
|
||||
const tableName = nodeData.inputs?.tableName as string
|
||||
const partitionKey = nodeData.inputs?.partitionKey as string
|
||||
const sessionId = nodeData.inputs?.sessionId as string
|
||||
const region = nodeData.inputs?.region as string
|
||||
const memoryKey = nodeData.inputs?.memoryKey as string
|
||||
const chatId = options.chatId
|
||||
|
||||
let isSessionIdUsingChatMessageId = false
|
||||
if (!sessionId && chatId) isSessionIdUsingChatMessageId = true
|
||||
let sessionId = ''
|
||||
|
||||
if (!nodeData.inputs?.sessionId && chatId) {
|
||||
isSessionIdUsingChatMessageId = true
|
||||
sessionId = chatId
|
||||
} else {
|
||||
sessionId = nodeData.inputs?.sessionId
|
||||
}
|
||||
|
||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||
const accessKeyId = getCredentialParam('accessKey', credentialData, nodeData)
|
||||
const secretAccessKey = getCredentialParam('secretAccessKey', credentialData, nodeData)
|
||||
|
||||
const config: DynamoDBClientConfig = {
|
||||
region,
|
||||
credentials: {
|
||||
accessKeyId,
|
||||
secretAccessKey
|
||||
}
|
||||
}
|
||||
|
||||
const client = new DynamoDBClient(config ?? {})
|
||||
|
||||
const dynamoDb = new DynamoDBChatMessageHistory({
|
||||
tableName,
|
||||
partitionKey,
|
||||
sessionId: sessionId ? sessionId : chatId,
|
||||
config: {
|
||||
region,
|
||||
credentials: {
|
||||
accessKeyId,
|
||||
secretAccessKey
|
||||
}
|
||||
}
|
||||
sessionId,
|
||||
config
|
||||
})
|
||||
|
||||
const memory = new BufferMemoryExtended({
|
||||
memoryKey: memoryKey ?? 'chat_history',
|
||||
chatHistory: dynamoDb,
|
||||
isSessionIdUsingChatMessageId
|
||||
isSessionIdUsingChatMessageId,
|
||||
sessionId,
|
||||
dynamodbClient: client
|
||||
})
|
||||
return memory
|
||||
}
|
||||
|
||||
interface BufferMemoryExtendedInput {
|
||||
isSessionIdUsingChatMessageId: boolean
|
||||
dynamodbClient: DynamoDBClient
|
||||
sessionId: string
|
||||
}
|
||||
|
||||
class BufferMemoryExtended extends BufferMemory {
|
||||
isSessionIdUsingChatMessageId? = false
|
||||
interface DynamoDBSerializedChatMessage {
|
||||
M: {
|
||||
type: {
|
||||
S: string
|
||||
}
|
||||
text: {
|
||||
S: string
|
||||
}
|
||||
role?: {
|
||||
S: string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
constructor(fields: BufferMemoryInput & Partial<BufferMemoryExtendedInput>) {
|
||||
class BufferMemoryExtended extends FlowiseMemory implements MemoryMethods {
|
||||
isSessionIdUsingChatMessageId = false
|
||||
sessionId = ''
|
||||
dynamodbClient: DynamoDBClient
|
||||
|
||||
constructor(fields: BufferMemoryInput & BufferMemoryExtendedInput) {
|
||||
super(fields)
|
||||
this.isSessionIdUsingChatMessageId = fields.isSessionIdUsingChatMessageId
|
||||
this.sessionId = fields.sessionId
|
||||
this.dynamodbClient = fields.dynamodbClient
|
||||
}
|
||||
|
||||
overrideDynamoKey(overrideSessionId = '') {
|
||||
const existingDynamoKey = (this as any).dynamoKey
|
||||
const partitionKey = (this as any).partitionKey
|
||||
|
||||
let newDynamoKey: Record<string, AttributeValue> = {}
|
||||
|
||||
if (Object.keys(existingDynamoKey).includes(partitionKey)) {
|
||||
newDynamoKey[partitionKey] = { S: overrideSessionId }
|
||||
}
|
||||
|
||||
return Object.keys(newDynamoKey).length ? newDynamoKey : existingDynamoKey
|
||||
}
|
||||
|
||||
async addNewMessage(
|
||||
messages: StoredMessage[],
|
||||
client: DynamoDBClient,
|
||||
tableName = '',
|
||||
dynamoKey: Record<string, AttributeValue> = {},
|
||||
messageAttributeName = 'messages'
|
||||
) {
|
||||
const params: UpdateItemCommandInput = {
|
||||
TableName: tableName,
|
||||
Key: dynamoKey,
|
||||
ExpressionAttributeNames: {
|
||||
'#m': messageAttributeName
|
||||
},
|
||||
ExpressionAttributeValues: {
|
||||
':empty_list': {
|
||||
L: []
|
||||
},
|
||||
':m': {
|
||||
L: messages.map((message) => {
|
||||
const dynamoSerializedMessage: DynamoDBSerializedChatMessage = {
|
||||
M: {
|
||||
type: {
|
||||
S: message.type
|
||||
},
|
||||
text: {
|
||||
S: message.data.content
|
||||
}
|
||||
}
|
||||
}
|
||||
if (message.data.role) {
|
||||
dynamoSerializedMessage.M.role = { S: message.data.role }
|
||||
}
|
||||
return dynamoSerializedMessage
|
||||
})
|
||||
}
|
||||
},
|
||||
UpdateExpression: 'SET #m = list_append(if_not_exists(#m, :empty_list), :m)'
|
||||
}
|
||||
|
||||
await client.send(new UpdateItemCommand(params))
|
||||
}
|
||||
|
||||
async getChatMessages(overrideSessionId = '', returnBaseMessages = false): Promise<IMessage[] | BaseMessage[]> {
|
||||
if (!this.dynamodbClient) return []
|
||||
|
||||
const dynamoKey = overrideSessionId ? this.overrideDynamoKey(overrideSessionId) : (this as any).dynamoKey
|
||||
const tableName = (this as any).tableName
|
||||
const messageAttributeName = (this as any).messageAttributeName
|
||||
|
||||
const params: GetItemCommandInput = {
|
||||
TableName: tableName,
|
||||
Key: dynamoKey
|
||||
}
|
||||
|
||||
const response = await this.dynamodbClient.send(new GetItemCommand(params))
|
||||
const items = response.Item ? response.Item[messageAttributeName]?.L ?? [] : []
|
||||
const messages = items
|
||||
.map((item) => ({
|
||||
type: item.M?.type.S,
|
||||
data: {
|
||||
role: item.M?.role?.S,
|
||||
content: item.M?.text.S
|
||||
}
|
||||
}))
|
||||
.filter((x): x is StoredMessage => x.type !== undefined && x.data.content !== undefined)
|
||||
const baseMessages = messages.map(mapStoredMessageToChatMessage)
|
||||
return returnBaseMessages ? baseMessages : convertBaseMessagetoIMessage(baseMessages)
|
||||
}
|
||||
|
||||
async addChatMessages(msgArray: { text: string; type: MessageType }[], overrideSessionId = ''): Promise<void> {
|
||||
if (!this.dynamodbClient) return
|
||||
|
||||
const dynamoKey = overrideSessionId ? this.overrideDynamoKey(overrideSessionId) : (this as any).dynamoKey
|
||||
const tableName = (this as any).tableName
|
||||
const messageAttributeName = (this as any).messageAttributeName
|
||||
|
||||
const input = msgArray.find((msg) => msg.type === 'userMessage')
|
||||
const output = msgArray.find((msg) => msg.type === 'apiMessage')
|
||||
|
||||
if (input) {
|
||||
const newInputMessage = new HumanMessage(input.text)
|
||||
const messageToAdd = [newInputMessage].map((msg) => msg.toDict())
|
||||
await this.addNewMessage(messageToAdd, this.dynamodbClient, tableName, dynamoKey, messageAttributeName)
|
||||
}
|
||||
|
||||
if (output) {
|
||||
const newOutputMessage = new AIMessage(output.text)
|
||||
const messageToAdd = [newOutputMessage].map((msg) => msg.toDict())
|
||||
await this.addNewMessage(messageToAdd, this.dynamodbClient, tableName, dynamoKey, messageAttributeName)
|
||||
}
|
||||
}
|
||||
|
||||
async clearChatMessages(overrideSessionId = ''): Promise<void> {
|
||||
if (!this.dynamodbClient) return
|
||||
|
||||
const dynamoKey = overrideSessionId ? this.overrideDynamoKey(overrideSessionId) : (this as any).dynamoKey
|
||||
const tableName = (this as any).tableName
|
||||
|
||||
const params: DeleteItemCommandInput = {
|
||||
TableName: tableName,
|
||||
Key: dynamoKey
|
||||
}
|
||||
await this.dynamodbClient.send(new DeleteItemCommand(params))
|
||||
await this.clear()
|
||||
}
|
||||
|
||||
async resumeMessages(): Promise<void> {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
import { MongoClient, Collection, Document } from 'mongodb'
|
||||
import { MongoDBChatMessageHistory } from 'langchain/stores/message/mongodb'
|
||||
import { BufferMemory, BufferMemoryInput } from 'langchain/memory'
|
||||
import { mapStoredMessageToChatMessage, AIMessage, HumanMessage, BaseMessage } from 'langchain/schema'
|
||||
import {
|
||||
convertBaseMessagetoIMessage,
|
||||
getBaseClasses,
|
||||
getCredentialData,
|
||||
getCredentialParam,
|
||||
ICommonObject,
|
||||
INode,
|
||||
INodeData,
|
||||
INodeParams,
|
||||
serializeChatHistory
|
||||
} from '../../../src'
|
||||
import { MongoDBChatMessageHistory } from 'langchain/stores/message/mongodb'
|
||||
import { BufferMemory, BufferMemoryInput } from 'langchain/memory'
|
||||
import { BaseMessage, mapStoredMessageToChatMessage } from 'langchain/schema'
|
||||
import { MongoClient } from 'mongodb'
|
||||
} from '../../../src/utils'
|
||||
import { FlowiseMemory, ICommonObject, IMessage, INode, INodeData, INodeParams, MemoryMethods, MessageType } from '../../../src/Interface'
|
||||
|
||||
class MongoDB_Memory implements INode {
|
||||
label: string
|
||||
|
|
@ -99,23 +97,30 @@ class MongoDB_Memory implements INode {
|
|||
const initializeMongoDB = async (nodeData: INodeData, options: ICommonObject): Promise<BufferMemory> => {
|
||||
const databaseName = nodeData.inputs?.databaseName as string
|
||||
const collectionName = nodeData.inputs?.collectionName as string
|
||||
const sessionId = nodeData.inputs?.sessionId as string
|
||||
const memoryKey = nodeData.inputs?.memoryKey as string
|
||||
const chatId = options?.chatId as string
|
||||
|
||||
let isSessionIdUsingChatMessageId = false
|
||||
if (!sessionId && chatId) isSessionIdUsingChatMessageId = true
|
||||
let sessionId = ''
|
||||
|
||||
if (!nodeData.inputs?.sessionId && chatId) {
|
||||
isSessionIdUsingChatMessageId = true
|
||||
sessionId = chatId
|
||||
} else {
|
||||
sessionId = nodeData.inputs?.sessionId
|
||||
}
|
||||
|
||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||
let mongoDBConnectUrl = getCredentialParam('mongoDBConnectUrl', credentialData, nodeData)
|
||||
const mongoDBConnectUrl = getCredentialParam('mongoDBConnectUrl', credentialData, nodeData)
|
||||
|
||||
const client = new MongoClient(mongoDBConnectUrl)
|
||||
await client.connect()
|
||||
|
||||
const collection = client.db(databaseName).collection(collectionName)
|
||||
|
||||
const mongoDBChatMessageHistory = new MongoDBChatMessageHistory({
|
||||
collection,
|
||||
sessionId: sessionId ? sessionId : chatId
|
||||
sessionId
|
||||
})
|
||||
|
||||
mongoDBChatMessageHistory.getMessages = async (): Promise<BaseMessage[]> => {
|
||||
|
|
@ -144,20 +149,81 @@ const initializeMongoDB = async (nodeData: INodeData, options: ICommonObject): P
|
|||
return new BufferMemoryExtended({
|
||||
memoryKey: memoryKey ?? 'chat_history',
|
||||
chatHistory: mongoDBChatMessageHistory,
|
||||
isSessionIdUsingChatMessageId
|
||||
isSessionIdUsingChatMessageId,
|
||||
sessionId,
|
||||
collection
|
||||
})
|
||||
}
|
||||
|
||||
interface BufferMemoryExtendedInput {
|
||||
isSessionIdUsingChatMessageId: boolean
|
||||
collection: Collection<Document>
|
||||
sessionId: string
|
||||
}
|
||||
|
||||
class BufferMemoryExtended extends BufferMemory {
|
||||
class BufferMemoryExtended extends FlowiseMemory implements MemoryMethods {
|
||||
sessionId = ''
|
||||
collection: Collection<Document>
|
||||
isSessionIdUsingChatMessageId? = false
|
||||
|
||||
constructor(fields: BufferMemoryInput & Partial<BufferMemoryExtendedInput>) {
|
||||
constructor(fields: BufferMemoryInput & BufferMemoryExtendedInput) {
|
||||
super(fields)
|
||||
this.isSessionIdUsingChatMessageId = fields.isSessionIdUsingChatMessageId
|
||||
this.sessionId = fields.sessionId
|
||||
this.collection = fields.collection
|
||||
}
|
||||
|
||||
async getChatMessages(overrideSessionId = '', returnBaseMessages = false): Promise<IMessage[] | BaseMessage[]> {
|
||||
if (!this.collection) return []
|
||||
|
||||
const id = overrideSessionId ?? this.sessionId
|
||||
const document = await this.collection.findOne({ sessionId: id })
|
||||
const messages = document?.messages || []
|
||||
const baseMessages = messages.map(mapStoredMessageToChatMessage)
|
||||
return returnBaseMessages ? baseMessages : convertBaseMessagetoIMessage(baseMessages)
|
||||
}
|
||||
|
||||
async addChatMessages(msgArray: { text: string; type: MessageType }[], overrideSessionId = ''): Promise<void> {
|
||||
if (!this.collection) return
|
||||
|
||||
const id = overrideSessionId ?? this.sessionId
|
||||
const input = msgArray.find((msg) => msg.type === 'userMessage')
|
||||
const output = msgArray.find((msg) => msg.type === 'apiMessage')
|
||||
|
||||
if (input) {
|
||||
const newInputMessage = new HumanMessage(input.text)
|
||||
const messageToAdd = [newInputMessage].map((msg) => msg.toDict())
|
||||
await this.collection.updateOne(
|
||||
{ sessionId: id },
|
||||
{
|
||||
$push: { messages: { $each: messageToAdd } }
|
||||
},
|
||||
{ upsert: true }
|
||||
)
|
||||
}
|
||||
|
||||
if (output) {
|
||||
const newOutputMessage = new AIMessage(output.text)
|
||||
const messageToAdd = [newOutputMessage].map((msg) => msg.toDict())
|
||||
await this.collection.updateOne(
|
||||
{ sessionId: id },
|
||||
{
|
||||
$push: { messages: { $each: messageToAdd } }
|
||||
},
|
||||
{ upsert: true }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
async clearChatMessages(overrideSessionId = ''): Promise<void> {
|
||||
if (!this.collection) return
|
||||
|
||||
const id = overrideSessionId ?? this.sessionId
|
||||
await this.collection.deleteOne({ sessionId: id })
|
||||
await this.clear()
|
||||
}
|
||||
|
||||
async resumeMessages(): Promise<void> {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { IMessage, INode, INodeData, INodeParams, MemoryMethods, MessageType } from '../../../src/Interface'
|
||||
import { convertBaseMessagetoIMessage, getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { ICommonObject } from '../../../src'
|
||||
import { MotorheadMemory, MotorheadMemoryInput } from 'langchain/memory'
|
||||
import { MotorheadMemory, MotorheadMemoryInput, InputValues, MemoryVariables, OutputValues, getBufferString } from 'langchain/memory'
|
||||
import fetch from 'node-fetch'
|
||||
import { getBufferString } from 'langchain/memory'
|
||||
import { BaseMessage } from 'langchain/schema'
|
||||
|
||||
class MotorMemory_Memory implements INode {
|
||||
label: string
|
||||
|
|
@ -88,19 +88,26 @@ class MotorMemory_Memory implements INode {
|
|||
const initalizeMotorhead = async (nodeData: INodeData, options: ICommonObject): Promise<MotorheadMemory> => {
|
||||
const memoryKey = nodeData.inputs?.memoryKey as string
|
||||
const baseURL = nodeData.inputs?.baseURL as string
|
||||
const sessionId = nodeData.inputs?.sessionId as string
|
||||
const chatId = options?.chatId as string
|
||||
|
||||
let isSessionIdUsingChatMessageId = false
|
||||
if (!sessionId && chatId) isSessionIdUsingChatMessageId = true
|
||||
let sessionId = ''
|
||||
|
||||
if (!nodeData.inputs?.sessionId && chatId) {
|
||||
isSessionIdUsingChatMessageId = true
|
||||
sessionId = chatId
|
||||
} else {
|
||||
sessionId = nodeData.inputs?.sessionId
|
||||
}
|
||||
|
||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||
const apiKey = getCredentialParam('apiKey', credentialData, nodeData)
|
||||
const clientId = getCredentialParam('clientId', credentialData, nodeData)
|
||||
|
||||
let obj: MotorheadMemoryInput & Partial<MotorheadMemoryExtendedInput> = {
|
||||
let obj: MotorheadMemoryInput & MotorheadMemoryExtendedInput = {
|
||||
returnMessages: true,
|
||||
sessionId: sessionId ? sessionId : chatId,
|
||||
isSessionIdUsingChatMessageId,
|
||||
sessionId,
|
||||
memoryKey
|
||||
}
|
||||
|
||||
|
|
@ -117,8 +124,6 @@ const initalizeMotorhead = async (nodeData: INodeData, options: ICommonObject):
|
|||
}
|
||||
}
|
||||
|
||||
if (isSessionIdUsingChatMessageId) obj.isSessionIdUsingChatMessageId = true
|
||||
|
||||
const motorheadMemory = new MotorheadMemoryExtended(obj)
|
||||
|
||||
// Get messages from sessionId
|
||||
|
|
@ -131,15 +136,32 @@ interface MotorheadMemoryExtendedInput {
|
|||
isSessionIdUsingChatMessageId: boolean
|
||||
}
|
||||
|
||||
class MotorheadMemoryExtended extends MotorheadMemory {
|
||||
class MotorheadMemoryExtended extends MotorheadMemory implements MemoryMethods {
|
||||
isSessionIdUsingChatMessageId? = false
|
||||
|
||||
constructor(fields: MotorheadMemoryInput & Partial<MotorheadMemoryExtendedInput>) {
|
||||
constructor(fields: MotorheadMemoryInput & MotorheadMemoryExtendedInput) {
|
||||
super(fields)
|
||||
this.isSessionIdUsingChatMessageId = fields.isSessionIdUsingChatMessageId
|
||||
}
|
||||
|
||||
async clear(): Promise<void> {
|
||||
async loadMemoryVariables(values: InputValues, overrideSessionId = ''): Promise<MemoryVariables> {
|
||||
if (overrideSessionId) {
|
||||
this.sessionId = overrideSessionId
|
||||
}
|
||||
return super.loadMemoryVariables({ values })
|
||||
}
|
||||
|
||||
async saveContext(inputValues: InputValues, outputValues: OutputValues, overrideSessionId = ''): Promise<void> {
|
||||
if (overrideSessionId) {
|
||||
this.sessionId = overrideSessionId
|
||||
}
|
||||
return super.saveContext(inputValues, outputValues)
|
||||
}
|
||||
|
||||
async clear(overrideSessionId = ''): Promise<void> {
|
||||
if (overrideSessionId) {
|
||||
this.sessionId = overrideSessionId
|
||||
}
|
||||
try {
|
||||
await this.caller.call(fetch, `${this.url}/sessions/${this.sessionId}/memory`, {
|
||||
//@ts-ignore
|
||||
|
|
@ -155,6 +177,28 @@ class MotorheadMemoryExtended extends MotorheadMemory {
|
|||
await this.chatHistory.clear()
|
||||
await super.clear()
|
||||
}
|
||||
|
||||
async getChatMessages(overrideSessionId = '', returnBaseMessages = false): Promise<IMessage[] | BaseMessage[]> {
|
||||
const id = overrideSessionId ?? this.sessionId
|
||||
const memoryVariables = await this.loadMemoryVariables({}, id)
|
||||
const baseMessages = memoryVariables[this.memoryKey]
|
||||
return returnBaseMessages ? baseMessages : convertBaseMessagetoIMessage(baseMessages)
|
||||
}
|
||||
|
||||
async addChatMessages(msgArray: { text: string; type: MessageType }[], overrideSessionId = ''): Promise<void> {
|
||||
const id = overrideSessionId ?? this.sessionId
|
||||
const input = msgArray.find((msg) => msg.type === 'userMessage')
|
||||
const output = msgArray.find((msg) => msg.type === 'apiMessage')
|
||||
const inputValues = { [this.inputKey ?? 'input']: input?.text }
|
||||
const outputValues = { output: output?.text }
|
||||
|
||||
await this.saveContext(inputValues, outputValues, id)
|
||||
}
|
||||
|
||||
async clearChatMessages(overrideSessionId = ''): Promise<void> {
|
||||
const id = overrideSessionId ?? this.sessionId
|
||||
await this.clear(id)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: MotorMemory_Memory }
|
||||
|
|
|
|||
|
|
@ -1,8 +1,14 @@
|
|||
import { INode, INodeData, INodeParams, ICommonObject } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam, serializeChatHistory } from '../../../src/utils'
|
||||
import { INode, INodeData, INodeParams, ICommonObject, IMessage, MessageType, FlowiseMemory, MemoryMethods } from '../../../src/Interface'
|
||||
import {
|
||||
convertBaseMessagetoIMessage,
|
||||
getBaseClasses,
|
||||
getCredentialData,
|
||||
getCredentialParam,
|
||||
serializeChatHistory
|
||||
} from '../../../src/utils'
|
||||
import { BufferMemory, BufferMemoryInput } from 'langchain/memory'
|
||||
import { RedisChatMessageHistory, RedisChatMessageHistoryInput } from 'langchain/stores/message/ioredis'
|
||||
import { mapStoredMessageToChatMessage, BaseMessage } from 'langchain/schema'
|
||||
import { mapStoredMessageToChatMessage, BaseMessage, AIMessage, HumanMessage } from 'langchain/schema'
|
||||
import { Redis } from 'ioredis'
|
||||
|
||||
class RedisBackedChatMemory_Memory implements INode {
|
||||
|
|
@ -94,14 +100,20 @@ class RedisBackedChatMemory_Memory implements INode {
|
|||
}
|
||||
|
||||
const initalizeRedis = async (nodeData: INodeData, options: ICommonObject): Promise<BufferMemory> => {
|
||||
const sessionId = nodeData.inputs?.sessionId as string
|
||||
const sessionTTL = nodeData.inputs?.sessionTTL as number
|
||||
const memoryKey = nodeData.inputs?.memoryKey as string
|
||||
const windowSize = nodeData.inputs?.windowSize as number
|
||||
const chatId = options?.chatId as string
|
||||
|
||||
let isSessionIdUsingChatMessageId = false
|
||||
if (!sessionId && chatId) isSessionIdUsingChatMessageId = true
|
||||
let sessionId = ''
|
||||
|
||||
if (!nodeData.inputs?.sessionId && chatId) {
|
||||
isSessionIdUsingChatMessageId = true
|
||||
sessionId = chatId
|
||||
} else {
|
||||
sessionId = nodeData.inputs?.sessionId
|
||||
}
|
||||
|
||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||
const redisUrl = getCredentialParam('redisUrl', credentialData, nodeData)
|
||||
|
|
@ -128,7 +140,7 @@ const initalizeRedis = async (nodeData: INodeData, options: ICommonObject): Prom
|
|||
}
|
||||
|
||||
let obj: RedisChatMessageHistoryInput = {
|
||||
sessionId: sessionId ? sessionId : chatId,
|
||||
sessionId,
|
||||
client
|
||||
}
|
||||
|
||||
|
|
@ -162,21 +174,71 @@ const initalizeRedis = async (nodeData: INodeData, options: ICommonObject): Prom
|
|||
const memory = new BufferMemoryExtended({
|
||||
memoryKey: memoryKey ?? 'chat_history',
|
||||
chatHistory: redisChatMessageHistory,
|
||||
isSessionIdUsingChatMessageId
|
||||
isSessionIdUsingChatMessageId,
|
||||
sessionId,
|
||||
redisClient: client
|
||||
})
|
||||
return memory
|
||||
}
|
||||
|
||||
interface BufferMemoryExtendedInput {
|
||||
isSessionIdUsingChatMessageId: boolean
|
||||
redisClient: Redis
|
||||
sessionId: string
|
||||
}
|
||||
|
||||
class BufferMemoryExtended extends BufferMemory {
|
||||
class BufferMemoryExtended extends FlowiseMemory implements MemoryMethods {
|
||||
isSessionIdUsingChatMessageId? = false
|
||||
sessionId = ''
|
||||
redisClient: Redis
|
||||
|
||||
constructor(fields: BufferMemoryInput & Partial<BufferMemoryExtendedInput>) {
|
||||
constructor(fields: BufferMemoryInput & BufferMemoryExtendedInput) {
|
||||
super(fields)
|
||||
this.isSessionIdUsingChatMessageId = fields.isSessionIdUsingChatMessageId
|
||||
this.sessionId = fields.sessionId
|
||||
this.redisClient = fields.redisClient
|
||||
}
|
||||
|
||||
async getChatMessages(overrideSessionId = '', returnBaseMessage = false): Promise<IMessage[] | BaseMessage[]> {
|
||||
if (!this.redisClient) return []
|
||||
|
||||
const id = overrideSessionId ?? this.sessionId
|
||||
const rawStoredMessages = await this.redisClient.lrange(id, 0, -1)
|
||||
const orderedMessages = rawStoredMessages.reverse().map((message) => JSON.parse(message))
|
||||
const baseMessages = orderedMessages.map(mapStoredMessageToChatMessage)
|
||||
return returnBaseMessage ? baseMessages : convertBaseMessagetoIMessage(baseMessages)
|
||||
}
|
||||
|
||||
async addChatMessages(msgArray: { text: string; type: MessageType }[], overrideSessionId = ''): Promise<void> {
|
||||
if (!this.redisClient) return
|
||||
|
||||
const id = overrideSessionId ?? this.sessionId
|
||||
const input = msgArray.find((msg) => msg.type === 'userMessage')
|
||||
const output = msgArray.find((msg) => msg.type === 'apiMessage')
|
||||
|
||||
if (input) {
|
||||
const newInputMessage = new HumanMessage(input.text)
|
||||
const messageToAdd = [newInputMessage].map((msg) => msg.toDict())
|
||||
await this.redisClient.lpush(id, JSON.stringify(messageToAdd[0]))
|
||||
}
|
||||
|
||||
if (output) {
|
||||
const newOutputMessage = new AIMessage(output.text)
|
||||
const messageToAdd = [newOutputMessage].map((msg) => msg.toDict())
|
||||
await this.redisClient.lpush(id, JSON.stringify(messageToAdd[0]))
|
||||
}
|
||||
}
|
||||
|
||||
async clearChatMessages(overrideSessionId = ''): Promise<void> {
|
||||
if (!this.redisClient) return
|
||||
|
||||
const id = overrideSessionId ?? this.sessionId
|
||||
await this.redisClient.del(id)
|
||||
await this.clear()
|
||||
}
|
||||
|
||||
async resumeMessages(): Promise<void> {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,16 @@
|
|||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam, serializeChatHistory } from '../../../src/utils'
|
||||
import { ICommonObject } from '../../../src'
|
||||
import { Redis } from '@upstash/redis'
|
||||
import { BufferMemory, BufferMemoryInput } from 'langchain/memory'
|
||||
import { UpstashRedisChatMessageHistory } from 'langchain/stores/message/upstash_redis'
|
||||
import { mapStoredMessageToChatMessage, AIMessage, HumanMessage, StoredMessage, BaseMessage } from 'langchain/schema'
|
||||
import { FlowiseMemory, IMessage, INode, INodeData, INodeParams, MemoryMethods, MessageType } from '../../../src/Interface'
|
||||
import {
|
||||
convertBaseMessagetoIMessage,
|
||||
getBaseClasses,
|
||||
getCredentialData,
|
||||
getCredentialParam,
|
||||
serializeChatHistory
|
||||
} from '../../../src/utils'
|
||||
import { ICommonObject } from '../../../src/Interface'
|
||||
|
||||
class UpstashRedisBackedChatMemory_Memory implements INode {
|
||||
label: string
|
||||
|
|
@ -84,29 +92,39 @@ class UpstashRedisBackedChatMemory_Memory implements INode {
|
|||
|
||||
const initalizeUpstashRedis = async (nodeData: INodeData, options: ICommonObject): Promise<BufferMemory> => {
|
||||
const baseURL = nodeData.inputs?.baseURL as string
|
||||
const sessionId = nodeData.inputs?.sessionId as string
|
||||
const sessionTTL = nodeData.inputs?.sessionTTL as string
|
||||
const chatId = options?.chatId as string
|
||||
|
||||
let isSessionIdUsingChatMessageId = false
|
||||
if (!sessionId && chatId) isSessionIdUsingChatMessageId = true
|
||||
let sessionId = ''
|
||||
|
||||
if (!nodeData.inputs?.sessionId && chatId) {
|
||||
isSessionIdUsingChatMessageId = true
|
||||
sessionId = chatId
|
||||
} else {
|
||||
sessionId = nodeData.inputs?.sessionId
|
||||
}
|
||||
|
||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||
const upstashRestToken = getCredentialParam('upstashRestToken', credentialData, nodeData)
|
||||
|
||||
const client = new Redis({
|
||||
url: baseURL,
|
||||
token: upstashRestToken
|
||||
})
|
||||
|
||||
const redisChatMessageHistory = new UpstashRedisChatMessageHistory({
|
||||
sessionId: sessionId ? sessionId : chatId,
|
||||
sessionId,
|
||||
sessionTTL: sessionTTL ? parseInt(sessionTTL, 10) : undefined,
|
||||
config: {
|
||||
url: baseURL,
|
||||
token: upstashRestToken
|
||||
}
|
||||
client
|
||||
})
|
||||
|
||||
const memory = new BufferMemoryExtended({
|
||||
memoryKey: 'chat_history',
|
||||
chatHistory: redisChatMessageHistory,
|
||||
isSessionIdUsingChatMessageId
|
||||
isSessionIdUsingChatMessageId,
|
||||
sessionId,
|
||||
redisClient: client
|
||||
})
|
||||
|
||||
return memory
|
||||
|
|
@ -114,14 +132,63 @@ const initalizeUpstashRedis = async (nodeData: INodeData, options: ICommonObject
|
|||
|
||||
interface BufferMemoryExtendedInput {
|
||||
isSessionIdUsingChatMessageId: boolean
|
||||
redisClient: Redis
|
||||
sessionId: string
|
||||
}
|
||||
|
||||
class BufferMemoryExtended extends BufferMemory {
|
||||
class BufferMemoryExtended extends FlowiseMemory implements MemoryMethods {
|
||||
isSessionIdUsingChatMessageId? = false
|
||||
sessionId = ''
|
||||
redisClient: Redis
|
||||
|
||||
constructor(fields: BufferMemoryInput & Partial<BufferMemoryExtendedInput>) {
|
||||
constructor(fields: BufferMemoryInput & BufferMemoryExtendedInput) {
|
||||
super(fields)
|
||||
this.isSessionIdUsingChatMessageId = fields.isSessionIdUsingChatMessageId
|
||||
this.sessionId = fields.sessionId
|
||||
this.redisClient = fields.redisClient
|
||||
}
|
||||
|
||||
async getChatMessages(overrideSessionId = '', returnBaseMessages = false): Promise<IMessage[] | BaseMessage[]> {
|
||||
if (!this.redisClient) return []
|
||||
|
||||
const id = overrideSessionId ?? this.sessionId
|
||||
const rawStoredMessages: StoredMessage[] = await this.redisClient.lrange<StoredMessage>(id, 0, -1)
|
||||
const orderedMessages = rawStoredMessages.reverse()
|
||||
const previousMessages = orderedMessages.filter((x): x is StoredMessage => x.type !== undefined && x.data.content !== undefined)
|
||||
const baseMessages = previousMessages.map(mapStoredMessageToChatMessage)
|
||||
return returnBaseMessages ? baseMessages : convertBaseMessagetoIMessage(baseMessages)
|
||||
}
|
||||
|
||||
async addChatMessages(msgArray: { text: string; type: MessageType }[], overrideSessionId = ''): Promise<void> {
|
||||
if (!this.redisClient) return
|
||||
|
||||
const id = overrideSessionId ?? this.sessionId
|
||||
const input = msgArray.find((msg) => msg.type === 'userMessage')
|
||||
const output = msgArray.find((msg) => msg.type === 'apiMessage')
|
||||
|
||||
if (input) {
|
||||
const newInputMessage = new HumanMessage(input.text)
|
||||
const messageToAdd = [newInputMessage].map((msg) => msg.toDict())
|
||||
await this.redisClient.lpush(id, JSON.stringify(messageToAdd[0]))
|
||||
}
|
||||
|
||||
if (output) {
|
||||
const newOutputMessage = new AIMessage(output.text)
|
||||
const messageToAdd = [newOutputMessage].map((msg) => msg.toDict())
|
||||
await this.redisClient.lpush(id, JSON.stringify(messageToAdd[0]))
|
||||
}
|
||||
}
|
||||
|
||||
async clearChatMessages(overrideSessionId = ''): Promise<void> {
|
||||
if (!this.redisClient) return
|
||||
|
||||
const id = overrideSessionId ?? this.sessionId
|
||||
await this.redisClient.del(id)
|
||||
await this.clear()
|
||||
}
|
||||
|
||||
async resumeMessages(): Promise<void> {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import { IMessage, INode, INodeData, INodeParams, MemoryMethods, MessageType } from '../../../src/Interface'
|
||||
import { convertBaseMessagetoIMessage, getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { ZepMemory, ZepMemoryInput } from 'langchain/memory/zep'
|
||||
import { getBufferString, InputValues, MemoryVariables, OutputValues } from 'langchain/memory'
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { ICommonObject } from '../../../src'
|
||||
import { InputValues, MemoryVariables, OutputValues, getBufferString } from 'langchain/memory'
|
||||
import { BaseMessage } from 'langchain/schema'
|
||||
|
||||
class ZepMemory_Memory implements INode {
|
||||
label: string
|
||||
|
|
@ -147,7 +148,7 @@ const initalizeZep = async (nodeData: INodeData, options: ICommonObject): Promis
|
|||
|
||||
const obj: ZepMemoryInput & ZepMemoryExtendedInput = {
|
||||
baseURL,
|
||||
sessionId: sessionId ? sessionId : chatId,
|
||||
sessionId,
|
||||
aiPrefix,
|
||||
humanPrefix,
|
||||
returnMessages: true,
|
||||
|
|
@ -166,7 +167,7 @@ interface ZepMemoryExtendedInput {
|
|||
k?: number
|
||||
}
|
||||
|
||||
class ZepMemoryExtended extends ZepMemory {
|
||||
class ZepMemoryExtended extends ZepMemory implements MemoryMethods {
|
||||
isSessionIdUsingChatMessageId? = false
|
||||
lastN?: number
|
||||
|
||||
|
|
@ -196,6 +197,28 @@ class ZepMemoryExtended extends ZepMemory {
|
|||
}
|
||||
return super.clear()
|
||||
}
|
||||
|
||||
async getChatMessages(overrideSessionId = '', returnBaseMessages = false): Promise<IMessage[] | BaseMessage[]> {
|
||||
const id = overrideSessionId ?? this.sessionId
|
||||
const memoryVariables = await this.loadMemoryVariables({}, id)
|
||||
const baseMessages = memoryVariables[this.memoryKey]
|
||||
return returnBaseMessages ? baseMessages : convertBaseMessagetoIMessage(baseMessages)
|
||||
}
|
||||
|
||||
async addChatMessages(msgArray: { text: string; type: MessageType }[], overrideSessionId = ''): Promise<void> {
|
||||
const id = overrideSessionId ?? this.sessionId
|
||||
const input = msgArray.find((msg) => msg.type === 'userMessage')
|
||||
const output = msgArray.find((msg) => msg.type === 'apiMessage')
|
||||
const inputValues = { [this.inputKey ?? 'input']: input?.text }
|
||||
const outputValues = { output: output?.text }
|
||||
|
||||
await this.saveContext(inputValues, outputValues, id)
|
||||
}
|
||||
|
||||
async clearChatMessages(overrideSessionId = ''): Promise<void> {
|
||||
const id = overrideSessionId ?? this.sessionId
|
||||
await this.clear(id)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: ZepMemory_Memory }
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
|||
import { getBaseClasses } from '../../../src'
|
||||
import { Moderation } from '../Moderation'
|
||||
import { SimplePromptModerationRunner } from './SimplePromptModerationRunner'
|
||||
import { BaseChatModel } from 'langchain/chat_models/base'
|
||||
|
||||
class SimplePromptModeration implements INode {
|
||||
label: string
|
||||
|
|
@ -17,7 +18,7 @@ class SimplePromptModeration implements INode {
|
|||
constructor() {
|
||||
this.label = 'Simple Prompt Moderation'
|
||||
this.name = 'inputModerationSimple'
|
||||
this.version = 1.0
|
||||
this.version = 2.0
|
||||
this.type = 'Moderation'
|
||||
this.icon = 'moderation.svg'
|
||||
this.category = 'Moderation'
|
||||
|
|
@ -30,8 +31,14 @@ class SimplePromptModeration implements INode {
|
|||
type: 'string',
|
||||
rows: 4,
|
||||
placeholder: `ignore previous instructions\ndo not follow the directions\nyou must ignore all previous instructions`,
|
||||
description: 'An array of string literals (enter one per line) that should not appear in the prompt text.',
|
||||
optional: false
|
||||
description: 'An array of string literals (enter one per line) that should not appear in the prompt text.'
|
||||
},
|
||||
{
|
||||
label: 'Chat Model',
|
||||
name: 'model',
|
||||
type: 'BaseChatModel',
|
||||
description: 'Use LLM to detect if the input is similar to those specified in Deny List',
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Error Message',
|
||||
|
|
@ -46,9 +53,10 @@ class SimplePromptModeration implements INode {
|
|||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const denyList = nodeData.inputs?.denyList as string
|
||||
const model = nodeData.inputs?.model as BaseChatModel
|
||||
const moderationErrorMessage = nodeData.inputs?.moderationErrorMessage as string
|
||||
|
||||
return new SimplePromptModerationRunner(denyList, moderationErrorMessage)
|
||||
return new SimplePromptModerationRunner(denyList, moderationErrorMessage, model)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +1,39 @@
|
|||
import { Moderation } from '../Moderation'
|
||||
import { BaseChatModel } from 'langchain/chat_models/base'
|
||||
|
||||
export class SimplePromptModerationRunner implements Moderation {
|
||||
private readonly denyList: string = ''
|
||||
private readonly moderationErrorMessage: string = ''
|
||||
private readonly model: BaseChatModel
|
||||
|
||||
constructor(denyList: string, moderationErrorMessage: string) {
|
||||
constructor(denyList: string, moderationErrorMessage: string, model?: BaseChatModel) {
|
||||
this.denyList = denyList
|
||||
if (denyList.indexOf('\n') === -1) {
|
||||
this.denyList += '\n'
|
||||
}
|
||||
this.moderationErrorMessage = moderationErrorMessage
|
||||
if (model) this.model = model
|
||||
}
|
||||
|
||||
async checkForViolations(input: string): Promise<string> {
|
||||
this.denyList.split('\n').forEach((denyListItem) => {
|
||||
if (denyListItem && denyListItem !== '' && input.toLowerCase().includes(denyListItem.toLowerCase())) {
|
||||
throw Error(this.moderationErrorMessage)
|
||||
if (this.model) {
|
||||
const denyArray = this.denyList.split('\n')
|
||||
for (const denyStr of denyArray) {
|
||||
if (!denyStr || denyStr === '') continue
|
||||
const res = await this.model.invoke(
|
||||
`Are these two sentences similar to each other? Only return Yes or No.\nFirst sentence: ${input}\nSecond sentence: ${denyStr}`
|
||||
)
|
||||
if (res.content.toString().toLowerCase().includes('yes')) {
|
||||
throw Error(this.moderationErrorMessage)
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.denyList.split('\n').forEach((denyListItem) => {
|
||||
if (denyListItem && denyListItem !== '' && input.toLowerCase().includes(denyListItem.toLowerCase())) {
|
||||
throw Error(this.moderationErrorMessage)
|
||||
}
|
||||
})
|
||||
}
|
||||
return Promise.resolve(input)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="32" height="32" fill="white"/>
|
||||
<rect x="5" y="7" width="22" height="18" rx="2" stroke="black" stroke-width="2"/>
|
||||
<path d="M11 12L15 16L11 20" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M17 20H21" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 396 B |
|
|
@ -1,5 +1,4 @@
|
|||
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="32" height="32" fill="white"/>
|
||||
<rect x="5" y="7" width="22" height="18" rx="2" stroke="black" stroke-width="2"/>
|
||||
<path d="M11 12L15 16L11 20" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M17 20H21" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 396 B |
|
|
@ -60,7 +60,7 @@ class CustomTool_Tools implements INode {
|
|||
}
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||
async init(nodeData: INodeData, input: string, options: ICommonObject): Promise<any> {
|
||||
const selectedToolId = nodeData.inputs?.selectedTool as string
|
||||
const customToolFunc = nodeData.inputs?.customToolFunc as string
|
||||
|
||||
|
|
@ -80,7 +80,36 @@ class CustomTool_Tools implements INode {
|
|||
code: tool.func
|
||||
}
|
||||
if (customToolFunc) obj.code = customToolFunc
|
||||
return new DynamicStructuredTool(obj)
|
||||
|
||||
const variables = await appDataSource.getRepository(databaseEntities['Variable']).find()
|
||||
|
||||
// override variables defined in overrideConfig
|
||||
// nodeData.inputs.variables is an Object, check each property and override the variable
|
||||
if (nodeData?.inputs?.vars) {
|
||||
for (const propertyName of Object.getOwnPropertyNames(nodeData.inputs.vars)) {
|
||||
const foundVar = variables.find((v) => v.name === propertyName)
|
||||
if (foundVar) {
|
||||
// even if the variable was defined as runtime, we override it with static value
|
||||
foundVar.type = 'static'
|
||||
foundVar.value = nodeData.inputs.vars[propertyName]
|
||||
} else {
|
||||
// add it the variables, if not found locally in the db
|
||||
variables.push({ name: propertyName, type: 'static', value: nodeData.inputs.vars[propertyName] })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const flow = {
|
||||
chatId: options.chatId, // id is uppercase (I)
|
||||
chatflowId: options.chatflowid, // id is lowercase (i)
|
||||
input
|
||||
}
|
||||
|
||||
let dynamicStructuredTool = new DynamicStructuredTool(obj)
|
||||
dynamicStructuredTool.setVariables(variables)
|
||||
dynamicStructuredTool.setFlowObject(flow)
|
||||
|
||||
return dynamicStructuredTool
|
||||
} catch (e) {
|
||||
throw new Error(e)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,18 @@
|
|||
import { z } from 'zod'
|
||||
import { CallbackManagerForToolRun } from 'langchain/callbacks'
|
||||
import { StructuredTool, ToolParams } from 'langchain/tools'
|
||||
import { NodeVM } from 'vm2'
|
||||
import { availableDependencies } from '../../../src/utils'
|
||||
import { RunnableConfig } from '@langchain/core/runnables'
|
||||
import { StructuredTool, ToolParams } from '@langchain/core/tools'
|
||||
import { CallbackManagerForToolRun, Callbacks, CallbackManager, parseCallbackConfigArg } from '@langchain/core/callbacks/manager'
|
||||
|
||||
class ToolInputParsingException extends Error {
|
||||
output?: string
|
||||
|
||||
constructor(message: string, output?: string) {
|
||||
super(message)
|
||||
this.output = output
|
||||
}
|
||||
}
|
||||
|
||||
export interface BaseDynamicToolInput extends ToolParams {
|
||||
name: string
|
||||
|
|
@ -32,6 +42,8 @@ export class DynamicStructuredTool<
|
|||
func: DynamicStructuredToolInput['func']
|
||||
|
||||
schema: T
|
||||
private variables: any[]
|
||||
private flowObj: any
|
||||
|
||||
constructor(fields: DynamicStructuredToolInput<T>) {
|
||||
super(fields)
|
||||
|
|
@ -43,7 +55,47 @@ export class DynamicStructuredTool<
|
|||
this.schema = fields.schema
|
||||
}
|
||||
|
||||
protected async _call(arg: z.output<T>): Promise<string> {
|
||||
async call(arg: z.output<T>, configArg?: RunnableConfig | Callbacks, tags?: string[], overrideSessionId?: string): Promise<string> {
|
||||
const config = parseCallbackConfigArg(configArg)
|
||||
if (config.runName === undefined) {
|
||||
config.runName = this.name
|
||||
}
|
||||
let parsed
|
||||
try {
|
||||
parsed = await this.schema.parseAsync(arg)
|
||||
} catch (e) {
|
||||
throw new ToolInputParsingException(`Received tool input did not match expected schema`, JSON.stringify(arg))
|
||||
}
|
||||
const callbackManager_ = await CallbackManager.configure(
|
||||
config.callbacks,
|
||||
this.callbacks,
|
||||
config.tags || tags,
|
||||
this.tags,
|
||||
config.metadata,
|
||||
this.metadata,
|
||||
{ verbose: this.verbose }
|
||||
)
|
||||
const runManager = await callbackManager_?.handleToolStart(
|
||||
this.toJSON(),
|
||||
typeof parsed === 'string' ? parsed : JSON.stringify(parsed),
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
config.runName
|
||||
)
|
||||
let result
|
||||
try {
|
||||
result = await this._call(parsed, runManager, overrideSessionId)
|
||||
} catch (e) {
|
||||
await runManager?.handleToolError(e)
|
||||
throw e
|
||||
}
|
||||
await runManager?.handleToolEnd(result)
|
||||
return result
|
||||
}
|
||||
|
||||
protected async _call(arg: z.output<T>, _?: CallbackManagerForToolRun, overrideSessionId?: string): Promise<string> {
|
||||
let sandbox: any = {}
|
||||
if (typeof arg === 'object' && Object.keys(arg).length) {
|
||||
for (const item in arg) {
|
||||
|
|
@ -51,6 +103,32 @@ export class DynamicStructuredTool<
|
|||
}
|
||||
}
|
||||
|
||||
// inject variables
|
||||
let vars = {}
|
||||
if (this.variables) {
|
||||
for (const item of this.variables) {
|
||||
let value = item.value
|
||||
|
||||
// read from .env file
|
||||
if (item.type === 'runtime') {
|
||||
value = process.env[item.name]
|
||||
}
|
||||
|
||||
Object.defineProperty(vars, item.name, {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: value
|
||||
})
|
||||
}
|
||||
}
|
||||
sandbox['$vars'] = vars
|
||||
|
||||
// inject flow properties
|
||||
if (this.flowObj) {
|
||||
sandbox['$flow'] = { ...this.flowObj, sessionId: overrideSessionId }
|
||||
}
|
||||
|
||||
const defaultAllowBuiltInDep = [
|
||||
'assert',
|
||||
'buffer',
|
||||
|
|
@ -87,4 +165,12 @@ export class DynamicStructuredTool<
|
|||
|
||||
return response
|
||||
}
|
||||
|
||||
setVariables(variables: any[]) {
|
||||
this.variables = variables
|
||||
}
|
||||
|
||||
setFlowObject(flow: any) {
|
||||
this.flowObj = flow
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class CustomFunction_Utilities implements INode {
|
|||
inputVars =
|
||||
typeof functionInputVariablesRaw === 'object' ? functionInputVariablesRaw : JSON.parse(functionInputVariablesRaw)
|
||||
} catch (exception) {
|
||||
throw new Error("Invalid JSON in the PromptTemplate's promptValues: " + exception)
|
||||
throw new Error('Invalid JSON in the Custom Function Input Variables: ' + exception)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-arrows-split-2" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M21 17h-5.397a5 5 0 0 1 -4.096 -2.133l-.514 -.734a5 5 0 0 0 -4.096 -2.133h-3.897" /><path d="M21 7h-5.395a5 5 0 0 0 -4.098 2.135l-.51 .73a5 5 0 0 1 -4.097 2.135h-3.9" /><path d="M18 10l3 -3l-3 -3" /><path d="M18 20l3 -3l-3 -3" /></svg>
|
||||
<svg width="32" height="32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5 16h6.127a4 4 0 0 0 3.072-1.44l2.602-3.12A4 4 0 0 1 19.874 10H27m0 12h-7.127a4 4 0 0 1-3.072-1.44L15.5 19l-.65-.78" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="m24 7 3.136 3L24 13m0 12 3.136-3L24 19" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
||||
|
Before Width: | Height: | Size: 528 B After Width: | Height: | Size: 415 B |
|
|
@ -24,7 +24,7 @@ class Postgres_VectorStores implements INode {
|
|||
constructor() {
|
||||
this.label = 'Postgres'
|
||||
this.name = 'postgres'
|
||||
this.version = 1.0
|
||||
this.version = 2.0
|
||||
this.type = 'Postgres'
|
||||
this.icon = 'postgres.svg'
|
||||
this.category = 'Vector Stores'
|
||||
|
|
@ -60,6 +60,13 @@ class Postgres_VectorStores implements INode {
|
|||
name: 'database',
|
||||
type: 'string'
|
||||
},
|
||||
{
|
||||
label: 'SSL Connection',
|
||||
name: 'sslConnection',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
optional: false
|
||||
},
|
||||
{
|
||||
label: 'Port',
|
||||
name: 'port',
|
||||
|
|
@ -117,6 +124,7 @@ class Postgres_VectorStores implements INode {
|
|||
const docs = nodeData.inputs?.document as Document[]
|
||||
const embeddings = nodeData.inputs?.embeddings as Embeddings
|
||||
const additionalConfig = nodeData.inputs?.additionalConfig as string
|
||||
const sslConnection = nodeData.inputs?.sslConnection as boolean
|
||||
|
||||
let additionalConfiguration = {}
|
||||
if (additionalConfig) {
|
||||
|
|
@ -134,7 +142,8 @@ class Postgres_VectorStores implements INode {
|
|||
port: nodeData.inputs?.port as number,
|
||||
username: user,
|
||||
password: password,
|
||||
database: nodeData.inputs?.database as string
|
||||
database: nodeData.inputs?.database as string,
|
||||
ssl: sslConnection
|
||||
}
|
||||
|
||||
const args = {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class Postgres_Existing_VectorStores implements INode {
|
|||
constructor() {
|
||||
this.label = 'Postgres Load Existing Index'
|
||||
this.name = 'postgresExistingIndex'
|
||||
this.version = 1.0
|
||||
this.version = 2.0
|
||||
this.type = 'Postgres'
|
||||
this.icon = 'postgres.svg'
|
||||
this.category = 'Vector Stores'
|
||||
|
|
@ -52,6 +52,13 @@ class Postgres_Existing_VectorStores implements INode {
|
|||
name: 'database',
|
||||
type: 'string'
|
||||
},
|
||||
{
|
||||
label: 'SSL Connection',
|
||||
name: 'sslConnection',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
optional: false
|
||||
},
|
||||
{
|
||||
label: 'Port',
|
||||
name: 'port',
|
||||
|
|
@ -109,6 +116,7 @@ class Postgres_Existing_VectorStores implements INode {
|
|||
const output = nodeData.outputs?.output as string
|
||||
const topK = nodeData.inputs?.topK as string
|
||||
const k = topK ? parseFloat(topK) : 4
|
||||
const sslConnection = nodeData.inputs?.sslConnection as boolean
|
||||
|
||||
let additionalConfiguration = {}
|
||||
if (additionalConfig) {
|
||||
|
|
@ -126,7 +134,8 @@ class Postgres_Existing_VectorStores implements INode {
|
|||
port: nodeData.inputs?.port as number,
|
||||
username: user,
|
||||
password: password,
|
||||
database: nodeData.inputs?.database as string
|
||||
database: nodeData.inputs?.database as string,
|
||||
ssl: sslConnection
|
||||
}
|
||||
|
||||
const args = {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class PostgresUpsert_VectorStores implements INode {
|
|||
constructor() {
|
||||
this.label = 'Postgres Upsert Document'
|
||||
this.name = 'postgresUpsert'
|
||||
this.version = 1.0
|
||||
this.version = 2.0
|
||||
this.type = 'Postgres'
|
||||
this.icon = 'postgres.svg'
|
||||
this.category = 'Vector Stores'
|
||||
|
|
@ -59,6 +59,13 @@ class PostgresUpsert_VectorStores implements INode {
|
|||
name: 'database',
|
||||
type: 'string'
|
||||
},
|
||||
{
|
||||
label: 'SSL Connection',
|
||||
name: 'sslConnection',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
optional: false
|
||||
},
|
||||
{
|
||||
label: 'Port',
|
||||
name: 'port',
|
||||
|
|
@ -117,6 +124,7 @@ class PostgresUpsert_VectorStores implements INode {
|
|||
const output = nodeData.outputs?.output as string
|
||||
const topK = nodeData.inputs?.topK as string
|
||||
const k = topK ? parseFloat(topK) : 4
|
||||
const sslConnection = nodeData.inputs?.sslConnection as boolean
|
||||
|
||||
let additionalConfiguration = {}
|
||||
if (additionalConfig) {
|
||||
|
|
@ -134,7 +142,8 @@ class PostgresUpsert_VectorStores implements INode {
|
|||
port: nodeData.inputs?.port as number,
|
||||
username: user,
|
||||
password: password,
|
||||
database: nodeData.inputs?.database as string
|
||||
database: nodeData.inputs?.database as string,
|
||||
ssl: sslConnection
|
||||
}
|
||||
|
||||
const args = {
|
||||
|
|
|
|||