mirror of https://github.com/FlowiseAI/Flowise.git
Merge branch 'main' into bugfix/webscrape-relative-links
commit
92bdf1cc51
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
不确定要贡献什么?一些想法:
|
||||
|
||||
- 从 Langchain 创建新组件
|
||||
- 从 `packages/components` 创建新组件
|
||||
- 更新现有组件,如扩展功能、修复错误
|
||||
- 添加新的 Chatflow 想法
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ Flowise 在一个单一的单体存储库中有 3 个不同的模块。
|
|||
|
||||
- `server`:用于提供 API 逻辑的 Node 后端
|
||||
- `ui`:React 前端
|
||||
- `components`:Langchain 组件
|
||||
- `components`:Langchain/LlamaIndex 组件
|
||||
|
||||
#### 先决条件
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ Found an issue? [Report it](https://github.com/FlowiseAI/Flowise/issues/new/choo
|
|||
|
||||
Not sure what to contribute? Some ideas:
|
||||
|
||||
- Create new components from Langchain
|
||||
- Create new components from `packages/components`
|
||||
- Update existing components such as extending functionality, fixing bugs
|
||||
- Add new chatflow ideas
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ Flowise has 3 different modules in a single mono repository.
|
|||
|
||||
- `server`: Node backend to serve API logics
|
||||
- `ui`: React frontend
|
||||
- `components`: Langchain components
|
||||
- `components`: Third-party nodes integrations
|
||||
|
||||
#### Prerequisite
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ Flowise 在一个单一的代码库中有 3 个不同的模块。
|
|||
|
||||
- `server`:用于提供 API 逻辑的 Node 后端
|
||||
- `ui`:React 前端
|
||||
- `components`:Langchain 组件
|
||||
- `components`:第三方节点集成
|
||||
|
||||
### 先决条件
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ Flowise has 3 different modules in a single mono repository.
|
|||
|
||||
- `server`: Node backend to serve API logics
|
||||
- `ui`: React frontend
|
||||
- `components`: Langchain components
|
||||
- `components`: Third-party nodes integrations
|
||||
|
||||
### Prerequisite
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "flowise",
|
||||
"version": "1.5.0",
|
||||
"version": "1.5.1",
|
||||
"private": true,
|
||||
"homepage": "https://flowiseai.com",
|
||||
"workspaces": [
|
||||
|
|
@ -53,5 +53,8 @@
|
|||
},
|
||||
"engines": {
|
||||
"node": ">=18.15.0"
|
||||
},
|
||||
"resolutions": {
|
||||
"@qdrant/openapi-typescript-fetch": "1.2.1"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { INodeParams, INodeCredential } from '../src/Interface'
|
||||
|
||||
class LLMonitorApi implements INodeCredential {
|
||||
class LunaryApi implements INodeCredential {
|
||||
label: string
|
||||
name: string
|
||||
version: number
|
||||
|
|
@ -8,25 +8,25 @@ class LLMonitorApi implements INodeCredential {
|
|||
inputs: INodeParams[]
|
||||
|
||||
constructor() {
|
||||
this.label = 'LLMonitor API'
|
||||
this.name = 'llmonitorApi'
|
||||
this.label = 'Lunary API'
|
||||
this.name = 'lunaryApi'
|
||||
this.version = 1.0
|
||||
this.description = 'Refer to <a target="_blank" href="https://llmonitor.com/docs">official guide</a> to get APP ID'
|
||||
this.description = 'Refer to <a target="_blank" href="https://lunary.ai/docs">official guide</a> to get APP ID'
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'APP ID',
|
||||
name: 'llmonitorAppId',
|
||||
name: 'lunaryAppId',
|
||||
type: 'password',
|
||||
placeholder: '<LLMonitor_APP_ID>'
|
||||
placeholder: '<Lunary_APP_ID>'
|
||||
},
|
||||
{
|
||||
label: 'Endpoint',
|
||||
name: 'llmonitorEndpoint',
|
||||
name: 'lunaryEndpoint',
|
||||
type: 'string',
|
||||
default: 'https://app.llmonitor.com'
|
||||
default: 'https://app.lunary.ai'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { credClass: LLMonitorApi }
|
||||
module.exports = { credClass: LunaryApi }
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
import { ICommonObject, INode, INodeData, INodeParams, PromptTemplate } from '../../../src/Interface'
|
||||
import { AgentExecutor } from 'langchain/agents'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { LoadPyodide, finalSystemPrompt, systemPrompt } from './core'
|
||||
import { LLMChain } from 'langchain/chains'
|
||||
import { BaseLanguageModel } from 'langchain/base_language'
|
||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||
import axios from 'axios'
|
||||
import { BaseLanguageModel } from '@langchain/core/language_models/base'
|
||||
import { AgentExecutor } from 'langchain/agents'
|
||||
import { LLMChain } from 'langchain/chains'
|
||||
import { ICommonObject, INode, INodeData, INodeParams, PromptTemplate } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||
import { LoadPyodide, finalSystemPrompt, systemPrompt } from './core'
|
||||
|
||||
class Airtable_Agents implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { BaseChatModel } from 'langchain/chat_models/base'
|
||||
import { AutoGPT } from 'langchain/experimental/autogpt'
|
||||
import { Tool } from 'langchain/tools'
|
||||
import { AIMessage, HumanMessage, SystemMessage } from 'langchain/schema'
|
||||
import { VectorStoreRetriever } from 'langchain/vectorstores/base'
|
||||
import { flatten } from 'lodash'
|
||||
import { StructuredTool } from 'langchain/tools'
|
||||
import { Tool, StructuredTool } from '@langchain/core/tools'
|
||||
import { BaseChatModel } from '@langchain/core/language_models/chat_models'
|
||||
import { AIMessage, HumanMessage, SystemMessage } from '@langchain/core/messages'
|
||||
import { VectorStoreRetriever } from '@langchain/core/vectorstores'
|
||||
import { PromptTemplate } from '@langchain/core/prompts'
|
||||
import { AutoGPT } from 'langchain/experimental/autogpt'
|
||||
import { LLMChain } from 'langchain/chains'
|
||||
import { PromptTemplate } from 'langchain/prompts'
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
|
||||
type ObjectTool = StructuredTool
|
||||
const FINISH_NAME = 'finish'
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { BaseChatModel } from '@langchain/core/language_models/chat_models'
|
||||
import { VectorStore } from '@langchain/core/vectorstores'
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { BabyAGI } from './core'
|
||||
import { BaseChatModel } from 'langchain/chat_models/base'
|
||||
import { VectorStore } from 'langchain/vectorstores/base'
|
||||
|
||||
class BabyAGI_Agents implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { BaseChatModel } from '@langchain/core/language_models/chat_models'
|
||||
import { VectorStore } from '@langchain/core/vectorstores'
|
||||
import { Document } from '@langchain/core/documents'
|
||||
import { PromptTemplate } from '@langchain/core/prompts'
|
||||
import { LLMChain } from 'langchain/chains'
|
||||
import { BaseChatModel } from 'langchain/chat_models/base'
|
||||
import { VectorStore } from 'langchain/dist/vectorstores/base'
|
||||
import { Document } from 'langchain/document'
|
||||
import { PromptTemplate } from 'langchain/prompts'
|
||||
|
||||
class TaskCreationChain extends LLMChain {
|
||||
constructor(prompt: PromptTemplate, llm: BaseChatModel) {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { ICommonObject, INode, INodeData, INodeParams, PromptTemplate } from '../../../src/Interface'
|
||||
import { BaseLanguageModel } from '@langchain/core/language_models/base'
|
||||
import { AgentExecutor } from 'langchain/agents'
|
||||
import { LLMChain } from 'langchain/chains'
|
||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||
import { ICommonObject, INode, INodeData, INodeParams, PromptTemplate } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { LoadPyodide, finalSystemPrompt, systemPrompt } from './core'
|
||||
import { LLMChain } from 'langchain/chains'
|
||||
import { BaseLanguageModel } from 'langchain/base_language'
|
||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||
|
||||
class CSV_Agents implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
import { Tool } from 'langchain/tools'
|
||||
import { BaseChatModel } from 'langchain/chat_models/base'
|
||||
import { flatten } from 'lodash'
|
||||
import { AgentStep, BaseMessage, ChainValues, AIMessage, HumanMessage } from 'langchain/schema'
|
||||
import { RunnableSequence } from 'langchain/schema/runnable'
|
||||
import { Tool } from '@langchain/core/tools'
|
||||
import { BaseChatModel } from '@langchain/core/language_models/chat_models'
|
||||
import { AIMessage, BaseMessage, HumanMessage } from '@langchain/core/messages'
|
||||
import { ChainValues } from '@langchain/core/utils/types'
|
||||
import { AgentStep } from '@langchain/core/agents'
|
||||
import { renderTemplate } from '@langchain/core/prompts'
|
||||
import { RunnableSequence } from '@langchain/core/runnables'
|
||||
import { ChatConversationalAgent } from 'langchain/agents'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||
import { FlowiseMemory, ICommonObject, IMessage, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { AgentExecutor } from '../../../src/agents'
|
||||
import { ChatConversationalAgent } from 'langchain/agents'
|
||||
import { renderTemplate } from '@langchain/core/prompts'
|
||||
|
||||
const DEFAULT_PREFIX = `Assistant is a large language model trained by OpenAI.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
import { ChainValues, AgentStep, BaseMessage } from 'langchain/schema'
|
||||
import { flatten } from 'lodash'
|
||||
import { ChatOpenAI } from 'langchain/chat_models/openai'
|
||||
import { ChatPromptTemplate, MessagesPlaceholder } from 'langchain/prompts'
|
||||
import { formatToOpenAIFunction } from 'langchain/tools'
|
||||
import { RunnableSequence } from 'langchain/schema/runnable'
|
||||
import { BaseMessage } from '@langchain/core/messages'
|
||||
import { ChainValues } from '@langchain/core/utils/types'
|
||||
import { AgentStep } from '@langchain/core/agents'
|
||||
import { RunnableSequence } from '@langchain/core/runnables'
|
||||
import { ChatOpenAI, formatToOpenAIFunction } from '@langchain/openai'
|
||||
import { ChatPromptTemplate, MessagesPlaceholder } from '@langchain/core/prompts'
|
||||
import { OpenAIFunctionsAgentOutputParser } from 'langchain/agents/openai/output_parser'
|
||||
import { FlowiseMemory, ICommonObject, IMessage, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||
import { OpenAIFunctionsAgentOutputParser } from 'langchain/agents/openai/output_parser'
|
||||
import { AgentExecutor, formatAgentSteps } from '../../../src/agents'
|
||||
|
||||
const defaultMessage = `Do your best to answer the questions. Feel free to use any tools available to look up relevant information, only if necessary.`
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { initializeAgentExecutorWithOptions, AgentExecutor } from 'langchain/agents'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { Tool } from 'langchain/tools'
|
||||
import { BaseLanguageModel } from 'langchain/base_language'
|
||||
import { flatten } from 'lodash'
|
||||
import { AgentExecutor } from 'langchain/agents'
|
||||
import { pull } from 'langchain/hub'
|
||||
import { Tool } from '@langchain/core/tools'
|
||||
import type { PromptTemplate } from '@langchain/core/prompts'
|
||||
import { BaseChatModel } from '@langchain/core/language_models/chat_models'
|
||||
import { additionalCallbacks } from '../../../src/handler'
|
||||
import { FlowiseMemory, ICommonObject, IMessage, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { createReactAgent } from '../../../src/agents'
|
||||
|
||||
class MRKLAgentChat_Agents implements INode {
|
||||
label: string
|
||||
|
|
@ -16,11 +19,12 @@ class MRKLAgentChat_Agents implements INode {
|
|||
category: string
|
||||
baseClasses: string[]
|
||||
inputs: INodeParams[]
|
||||
sessionId?: string
|
||||
|
||||
constructor() {
|
||||
constructor(fields?: { sessionId?: string }) {
|
||||
this.label = 'ReAct Agent for Chat Models'
|
||||
this.name = 'mrklAgentChat'
|
||||
this.version = 1.0
|
||||
this.version = 3.0
|
||||
this.type = 'AgentExecutor'
|
||||
this.category = 'Agents'
|
||||
this.icon = 'agent.svg'
|
||||
|
|
@ -34,30 +38,64 @@ class MRKLAgentChat_Agents implements INode {
|
|||
list: true
|
||||
},
|
||||
{
|
||||
label: 'Language Model',
|
||||
label: 'Chat Model',
|
||||
name: 'model',
|
||||
type: 'BaseLanguageModel'
|
||||
type: 'BaseChatModel'
|
||||
},
|
||||
{
|
||||
label: 'Memory',
|
||||
name: 'memory',
|
||||
type: 'BaseChatMemory'
|
||||
}
|
||||
]
|
||||
this.sessionId = fields?.sessionId
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const model = nodeData.inputs?.model as BaseLanguageModel
|
||||
let tools = nodeData.inputs?.tools as Tool[]
|
||||
tools = flatten(tools)
|
||||
const executor = await initializeAgentExecutorWithOptions(tools, model, {
|
||||
agentType: 'chat-zero-shot-react-description',
|
||||
verbose: process.env.DEBUG === 'true' ? true : false
|
||||
})
|
||||
return executor
|
||||
async init(): Promise<any> {
|
||||
return null
|
||||
}
|
||||
|
||||
async run(nodeData: INodeData, input: string, options: ICommonObject): Promise<string> {
|
||||
const executor = nodeData.instance as AgentExecutor
|
||||
const memory = nodeData.inputs?.memory as FlowiseMemory
|
||||
const model = nodeData.inputs?.model as BaseChatModel
|
||||
let tools = nodeData.inputs?.tools as Tool[]
|
||||
tools = flatten(tools)
|
||||
|
||||
const promptWithChat = await pull<PromptTemplate>('hwchase17/react-chat')
|
||||
|
||||
const agent = await createReactAgent({
|
||||
llm: model,
|
||||
tools,
|
||||
prompt: promptWithChat
|
||||
})
|
||||
|
||||
const executor = new AgentExecutor({
|
||||
agent,
|
||||
tools,
|
||||
verbose: process.env.DEBUG === 'true' ? true : false
|
||||
})
|
||||
|
||||
const callbacks = await additionalCallbacks(nodeData, options)
|
||||
|
||||
const result = await executor.call({ input }, [...callbacks])
|
||||
const prevChatHistory = options.chatHistory
|
||||
const chatHistory = ((await memory.getChatMessages(this.sessionId, false, prevChatHistory)) as IMessage[]) ?? []
|
||||
const chatHistoryString = chatHistory.map((hist) => hist.message).join('\\n')
|
||||
|
||||
const result = await executor.invoke({ input, chat_history: chatHistoryString }, { callbacks })
|
||||
|
||||
await memory.addChatMessages(
|
||||
[
|
||||
{
|
||||
text: input,
|
||||
type: 'userMessage'
|
||||
},
|
||||
{
|
||||
text: result?.output,
|
||||
type: 'apiMessage'
|
||||
}
|
||||
],
|
||||
this.sessionId
|
||||
)
|
||||
|
||||
return result?.output
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { initializeAgentExecutorWithOptions, AgentExecutor } from 'langchain/agents'
|
||||
import { Tool } from 'langchain/tools'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { BaseLanguageModel } from 'langchain/base_language'
|
||||
import { flatten } from 'lodash'
|
||||
import { AgentExecutor } from 'langchain/agents'
|
||||
import { pull } from 'langchain/hub'
|
||||
import { Tool } from '@langchain/core/tools'
|
||||
import type { PromptTemplate } from '@langchain/core/prompts'
|
||||
import { BaseLanguageModel } from 'langchain/base_language'
|
||||
import { additionalCallbacks } from '../../../src/handler'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { createReactAgent } from '../../../src/agents'
|
||||
|
||||
class MRKLAgentLLM_Agents implements INode {
|
||||
label: string
|
||||
|
|
@ -41,24 +44,32 @@ class MRKLAgentLLM_Agents implements INode {
|
|||
]
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
async init(): Promise<any> {
|
||||
return null
|
||||
}
|
||||
|
||||
async run(nodeData: INodeData, input: string, options: ICommonObject): Promise<string> {
|
||||
const model = nodeData.inputs?.model as BaseLanguageModel
|
||||
let tools = nodeData.inputs?.tools as Tool[]
|
||||
tools = flatten(tools)
|
||||
|
||||
const executor = await initializeAgentExecutorWithOptions(tools, model, {
|
||||
agentType: 'zero-shot-react-description',
|
||||
const prompt = await pull<PromptTemplate>('hwchase17/react')
|
||||
|
||||
const agent = await createReactAgent({
|
||||
llm: model,
|
||||
tools,
|
||||
prompt
|
||||
})
|
||||
|
||||
const executor = new AgentExecutor({
|
||||
agent,
|
||||
tools,
|
||||
verbose: process.env.DEBUG === 'true' ? true : false
|
||||
})
|
||||
return executor
|
||||
}
|
||||
|
||||
async run(nodeData: INodeData, input: string, options: ICommonObject): Promise<string> {
|
||||
const executor = nodeData.instance as AgentExecutor
|
||||
|
||||
const callbacks = await additionalCallbacks(nodeData, options)
|
||||
|
||||
const result = await executor.call({ input }, [...callbacks])
|
||||
const result = await executor.invoke({ input }, { callbacks })
|
||||
|
||||
return result?.output
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
import { ChainValues, AgentStep, BaseMessage } from 'langchain/schema'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { flatten } from 'lodash'
|
||||
import { RunnableSequence } from 'langchain/schema/runnable'
|
||||
import { formatToOpenAIFunction } from 'langchain/tools'
|
||||
import { ChatOpenAI } from 'langchain/chat_models/openai'
|
||||
import { BaseMessage } from '@langchain/core/messages'
|
||||
import { ChainValues } from '@langchain/core/utils/types'
|
||||
import { AgentStep } from '@langchain/core/agents'
|
||||
import { RunnableSequence } from '@langchain/core/runnables'
|
||||
import { ChatOpenAI, formatToOpenAIFunction } from '@langchain/openai'
|
||||
import { ChatPromptTemplate, MessagesPlaceholder } from '@langchain/core/prompts'
|
||||
import { OpenAIFunctionsAgentOutputParser } from 'langchain/agents/openai/output_parser'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { FlowiseMemory, ICommonObject, IMessage, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||
import { ChatPromptTemplate, MessagesPlaceholder } from 'langchain/prompts'
|
||||
import { OpenAIFunctionsAgentOutputParser } from 'langchain/agents/openai/output_parser'
|
||||
import { AgentExecutor, formatAgentSteps } from '../../../src/agents'
|
||||
|
||||
class OpenAIFunctionAgent_Agents implements INode {
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
|
@ -1,6 +1,6 @@
|
|||
import { INode, INodeParams } from '../../../src/Interface'
|
||||
|
||||
class LLMonitor_Analytic implements INode {
|
||||
class Lunary_Analytic implements INode {
|
||||
label: string
|
||||
name: string
|
||||
version: number
|
||||
|
|
@ -13,10 +13,10 @@ class LLMonitor_Analytic implements INode {
|
|||
credential: INodeParams
|
||||
|
||||
constructor() {
|
||||
this.label = 'LLMonitor'
|
||||
this.name = 'llmonitor'
|
||||
this.label = 'Lunary'
|
||||
this.name = 'lunary'
|
||||
this.version = 1.0
|
||||
this.type = 'LLMonitor'
|
||||
this.type = 'Lunary'
|
||||
this.icon = 'Lunary.svg'
|
||||
this.category = 'Analytic'
|
||||
this.baseClasses = [this.type]
|
||||
|
|
@ -25,9 +25,9 @@ class LLMonitor_Analytic implements INode {
|
|||
label: 'Connect Credential',
|
||||
name: 'credential',
|
||||
type: 'credential',
|
||||
credentialNames: ['llmonitorApi']
|
||||
credentialNames: ['lunaryApi']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: LLMonitor_Analytic }
|
||||
module.exports = { nodeClass: Lunary_Analytic }
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { getBaseClasses, ICommonObject, INode, INodeData, INodeParams } from '../../../src'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
import { BaseCache } from '@langchain/core/caches'
|
||||
import hash from 'object-hash'
|
||||
import { getBaseClasses, ICommonObject, INode, INodeData, INodeParams } from '../../../src'
|
||||
|
||||
class InMemoryCache implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { getBaseClasses, ICommonObject, INode, INodeData, INodeParams } from '../../../src'
|
||||
import { Embeddings } from '@langchain/core/embeddings'
|
||||
import { BaseStore } from '@langchain/core/stores'
|
||||
import { CacheBackedEmbeddings } from 'langchain/embeddings/cache_backed'
|
||||
import { Embeddings } from 'langchain/embeddings/base'
|
||||
import { BaseStore } from 'langchain/schema/storage'
|
||||
import { getBaseClasses, ICommonObject, INode, INodeData, INodeParams } from '../../../src'
|
||||
|
||||
class InMemoryEmbeddingCache implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { getBaseClasses, getCredentialData, getCredentialParam, ICommonObject, INode, INodeData, INodeParams } from '../../../src'
|
||||
import { MomentoCache as LangchainMomentoCache } from 'langchain/cache/momento'
|
||||
import { CacheClient, Configurations, CredentialProvider } from '@gomomento/sdk'
|
||||
import { MomentoCache as LangchainMomentoCache } from '@langchain/community/caches/momento'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam, ICommonObject, INode, INodeData, INodeParams } from '../../../src'
|
||||
|
||||
class MomentoCache implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import { getBaseClasses, getCredentialData, getCredentialParam, ICommonObject, INode, INodeData, INodeParams } from '../../../src'
|
||||
import { RedisCache as LangchainRedisCache } from 'langchain/cache/ioredis'
|
||||
import { Redis, RedisOptions } from 'ioredis'
|
||||
import { isEqual } from 'lodash'
|
||||
import { Generation, ChatGeneration, StoredGeneration, mapStoredMessageToChatMessage } from 'langchain/schema'
|
||||
import hash from 'object-hash'
|
||||
import { RedisCache as LangchainRedisCache } from '@langchain/community/caches/ioredis'
|
||||
import { StoredGeneration, mapStoredMessageToChatMessage } from '@langchain/core/messages'
|
||||
import { Generation, ChatGeneration } from '@langchain/core/outputs'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam, ICommonObject, INode, INodeData, INodeParams } from '../../../src'
|
||||
|
||||
let redisClientSingleton: Redis
|
||||
let redisClientOption: RedisOptions
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { getBaseClasses, getCredentialData, getCredentialParam, ICommonObject, INode, INodeData, INodeParams } from '../../../src'
|
||||
import { Redis, RedisOptions } from 'ioredis'
|
||||
import { isEqual } from 'lodash'
|
||||
import { RedisByteStore } from '@langchain/community/storage/ioredis'
|
||||
import { Embeddings } from '@langchain/core/embeddings'
|
||||
import { CacheBackedEmbeddings } from 'langchain/embeddings/cache_backed'
|
||||
import { RedisByteStore } from 'langchain/storage/ioredis'
|
||||
import { Embeddings } from 'langchain/embeddings/base'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam, ICommonObject, INode, INodeData, INodeParams } from '../../../src'
|
||||
|
||||
let redisClientSingleton: Redis
|
||||
let redisClientOption: RedisOptions
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { UpstashRedisCache as LangchainUpstashRedisCache } from '@langchain/community/caches/upstash_redis'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam, ICommonObject, INode, INodeData, INodeParams } from '../../../src'
|
||||
import { UpstashRedisCache as LangchainUpstashRedisCache } from 'langchain/cache/upstash_redis'
|
||||
|
||||
class UpstashRedisCache implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { BaseLanguageModel } from '@langchain/core/language_models/base'
|
||||
import { PromptTemplate } from '@langchain/core/prompts'
|
||||
import { APIChain } from 'langchain/chains'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { BaseLanguageModel } from 'langchain/base_language'
|
||||
import { PromptTemplate } from 'langchain/prompts'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||
|
||||
export const API_URL_RAW_PROMPT_TEMPLATE = `You are given the below API Documentation:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { ChatOpenAI } from '@langchain/openai'
|
||||
import { APIChain, createOpenAPIChain } from 'langchain/chains'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { ChatOpenAI } from 'langchain/chat_models/openai'
|
||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||
|
||||
class OpenApiChain_Chains implements INode {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { BaseLanguageModel } from 'langchain/base_language'
|
||||
import { PromptTemplate } from 'langchain/prompts'
|
||||
import { BaseLanguageModel } from '@langchain/core/language_models/base'
|
||||
import { PromptTemplate } from '@langchain/core/prompts'
|
||||
import { API_RESPONSE_RAW_PROMPT_TEMPLATE, API_URL_RAW_PROMPT_TEMPLATE, APIChain } from './postCore'
|
||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
|
||||
class POSTApiChain_Chains implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { BaseLanguageModel } from 'langchain/base_language'
|
||||
import { CallbackManagerForChainRun } from 'langchain/callbacks'
|
||||
import { BaseLanguageModel } from '@langchain/core/language_models/base'
|
||||
import { CallbackManagerForChainRun } from '@langchain/core/callbacks/manager'
|
||||
import { BaseChain, ChainInputs, LLMChain, SerializedAPIChain } from 'langchain/chains'
|
||||
import { BasePromptTemplate, PromptTemplate } from 'langchain/prompts'
|
||||
import { ChainValues } from 'langchain/schema'
|
||||
import { BasePromptTemplate, PromptTemplate } from '@langchain/core/prompts'
|
||||
import { ChainValues } from '@langchain/core/utils/types'
|
||||
import fetch from 'node-fetch'
|
||||
|
||||
export const API_URL_RAW_PROMPT_TEMPLATE = `You are given the below API Documentation:
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import { FlowiseMemory, ICommonObject, IMessage, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { ConversationChain } from 'langchain/chains'
|
||||
import { getBaseClasses, handleEscapeCharacters } from '../../../src/utils'
|
||||
import { ChatPromptTemplate, HumanMessagePromptTemplate, MessagesPlaceholder, SystemMessagePromptTemplate } from 'langchain/prompts'
|
||||
import { BaseChatModel } from 'langchain/chat_models/base'
|
||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||
import { RunnableSequence } from 'langchain/schema/runnable'
|
||||
import { StringOutputParser } from 'langchain/schema/output_parser'
|
||||
import { ChatPromptTemplate, HumanMessagePromptTemplate, MessagesPlaceholder, SystemMessagePromptTemplate } from '@langchain/core/prompts'
|
||||
import { BaseChatModel } from '@langchain/core/language_models/chat_models'
|
||||
import { RunnableSequence } from '@langchain/core/runnables'
|
||||
import { StringOutputParser } from '@langchain/core/output_parsers'
|
||||
import { ConsoleCallbackHandler as LCConsoleCallbackHandler } from '@langchain/core/tracers/console'
|
||||
import { ConversationChain } from 'langchain/chains'
|
||||
import { FlowiseMemory, ICommonObject, IMessage, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||
import { getBaseClasses, handleEscapeCharacters } from '../../../src/utils'
|
||||
import { checkInputs, Moderation, streamResponse } from '../../moderation/Moderation'
|
||||
import { formatResponse } from '../../outputparsers/OutputParserHelpers'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
import { BaseLanguageModel } from 'langchain/base_language'
|
||||
import { ConversationalRetrievalQAChain } from 'langchain/chains'
|
||||
import { BaseRetriever } from 'langchain/schema/retriever'
|
||||
import { BufferMemoryInput } from 'langchain/memory'
|
||||
import { PromptTemplate } from 'langchain/prompts'
|
||||
import { QA_TEMPLATE, REPHRASE_TEMPLATE, RESPONSE_TEMPLATE } from './prompts'
|
||||
import { Runnable, RunnableSequence, RunnableMap, RunnableBranch, RunnableLambda } from 'langchain/schema/runnable'
|
||||
import { BaseMessage, HumanMessage, AIMessage } from 'langchain/schema'
|
||||
import { StringOutputParser } from 'langchain/schema/output_parser'
|
||||
import type { Document } from 'langchain/document'
|
||||
import { ChatPromptTemplate, MessagesPlaceholder } from 'langchain/prompts'
|
||||
import { applyPatch } from 'fast-json-patch'
|
||||
import { BaseLanguageModel } from '@langchain/core/language_models/base'
|
||||
import { BaseRetriever } from '@langchain/core/retrievers'
|
||||
import { PromptTemplate, ChatPromptTemplate, MessagesPlaceholder } from '@langchain/core/prompts'
|
||||
import { Runnable, RunnableSequence, RunnableMap, RunnableBranch, RunnableLambda } from '@langchain/core/runnables'
|
||||
import { BaseMessage, HumanMessage, AIMessage } from '@langchain/core/messages'
|
||||
import { ConsoleCallbackHandler as LCConsoleCallbackHandler } from '@langchain/core/tracers/console'
|
||||
import { StringOutputParser } from '@langchain/core/output_parsers'
|
||||
import type { Document } from '@langchain/core/documents'
|
||||
import { BufferMemoryInput } from 'langchain/memory'
|
||||
import { ConversationalRetrievalQAChain } from 'langchain/chains'
|
||||
import { convertBaseMessagetoIMessage, getBaseClasses } from '../../../src/utils'
|
||||
import { ConsoleCallbackHandler, additionalCallbacks } from '../../../src/handler'
|
||||
import { FlowiseMemory, ICommonObject, IMessage, INode, INodeData, INodeParams, MemoryMethods } from '../../../src/Interface'
|
||||
import { ConsoleCallbackHandler as LCConsoleCallbackHandler } from '@langchain/core/tracers/console'
|
||||
import { QA_TEMPLATE, REPHRASE_TEMPLATE, RESPONSE_TEMPLATE } from './prompts'
|
||||
|
||||
type RetrievalChainInput = {
|
||||
chat_history: string
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, handleEscapeCharacters } from '../../../src/utils'
|
||||
import { LLMChain } from 'langchain/chains'
|
||||
import { BaseLanguageModel, BaseLanguageModelCallOptions } from 'langchain/base_language'
|
||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||
import { BaseOutputParser } from 'langchain/schema/output_parser'
|
||||
import { formatResponse, injectOutputParser } from '../../outputparsers/OutputParserHelpers'
|
||||
import { BaseLLMOutputParser } from 'langchain/schema/output_parser'
|
||||
import { BaseLanguageModel, BaseLanguageModelCallOptions } from '@langchain/core/language_models/base'
|
||||
import { BaseLLMOutputParser, BaseOutputParser } from '@langchain/core/output_parsers'
|
||||
import { OutputFixingParser } from 'langchain/output_parsers'
|
||||
import { LLMChain } from 'langchain/chains'
|
||||
import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
|
||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||
import { getBaseClasses, handleEscapeCharacters } from '../../../src/utils'
|
||||
import { checkInputs, Moderation, streamResponse } from '../../moderation/Moderation'
|
||||
import { formatResponse, injectOutputParser } from '../../outputparsers/OutputParserHelpers'
|
||||
|
||||
class LLMChain_Chains implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { BaseLanguageModel } from 'langchain/base_language'
|
||||
import { BaseLanguageModel } from '@langchain/core/language_models/base'
|
||||
import { MultiPromptChain } from 'langchain/chains'
|
||||
import { ICommonObject, INode, INodeData, INodeParams, PromptRetriever } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { MultiPromptChain } from 'langchain/chains'
|
||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||
|
||||
class MultiPromptChain_Chains implements INode {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { BaseLanguageModel } from 'langchain/base_language'
|
||||
import { BaseLanguageModel } from '@langchain/core/language_models/base'
|
||||
import { MultiRetrievalQAChain } from 'langchain/chains'
|
||||
import { ICommonObject, INode, INodeData, INodeParams, VectorStoreRetriever } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { MultiRetrievalQAChain } from 'langchain/chains'
|
||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||
|
||||
class MultiRetrievalQAChain_Chains implements INode {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { BaseRetriever } from '@langchain/core/retrievers'
|
||||
import { BaseLanguageModel } from '@langchain/core/language_models/base'
|
||||
import { RetrievalQAChain } from 'langchain/chains'
|
||||
import { BaseRetriever } from 'langchain/schema/retriever'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { BaseLanguageModel } from 'langchain/base_language'
|
||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
|
||||
class RetrievalQAChain_Chains implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { SqlDatabaseChain, SqlDatabaseChainInput, DEFAULT_SQL_DATABASE_PROMPT } from 'langchain/chains/sql_db'
|
||||
import { getBaseClasses, getInputVariables } from '../../../src/utils'
|
||||
import { DataSource } from 'typeorm'
|
||||
import { SqlDatabase } from 'langchain/sql_db'
|
||||
import { BaseLanguageModel } from 'langchain/base_language'
|
||||
import { PromptTemplate, PromptTemplateInput } from 'langchain/prompts'
|
||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||
import { DataSourceOptions } from 'typeorm/data-source'
|
||||
import { DataSource } from 'typeorm'
|
||||
import { BaseLanguageModel } from '@langchain/core/language_models/base'
|
||||
import { PromptTemplate, PromptTemplateInput } from '@langchain/core/prompts'
|
||||
import { SqlDatabaseChain, SqlDatabaseChainInput, DEFAULT_SQL_DATABASE_PROMPT } from 'langchain/chains/sql_db'
|
||||
import { SqlDatabase } from 'langchain/sql_db'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||
import { getBaseClasses, getInputVariables } from '../../../src/utils'
|
||||
|
||||
type DatabaseType = 'sqlite' | 'postgres' | 'mssql' | 'mysql'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import fetch from 'node-fetch'
|
||||
import { Document } from '@langchain/core/documents'
|
||||
import { VectaraStore } from '@langchain/community/vectorstores/vectara'
|
||||
import { VectorDBQAChain } from 'langchain/chains'
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { VectorDBQAChain } from 'langchain/chains'
|
||||
import { Document } from 'langchain/document'
|
||||
import { VectaraStore } from 'langchain/vectorstores/vectara'
|
||||
import fetch from 'node-fetch'
|
||||
|
||||
// functionality based on https://github.com/vectara/vectara-answer
|
||||
const reorderCitations = (unorderedSummary: string) => {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { BaseLanguageModel } from '@langchain/core/language_models/base'
|
||||
import { VectorStore } from '@langchain/core/vectorstores'
|
||||
import { VectorDBQAChain } from 'langchain/chains'
|
||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { VectorDBQAChain } from 'langchain/chains'
|
||||
import { BaseLanguageModel } from 'langchain/base_language'
|
||||
import { VectorStore } from 'langchain/vectorstores/base'
|
||||
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
|
||||
|
||||
class VectorDBQAChain_Chains implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { BedrockChat } from '@langchain/community/chat_models/bedrock'
|
||||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { BaseChatModelParams } from '@langchain/core/language_models/chat_models'
|
||||
import { BaseBedrockInput } from 'langchain/dist/util/bedrock'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { BedrockChat } from 'langchain/chat_models/bedrock'
|
||||
import { BaseBedrockInput } from 'langchain/dist/util/bedrock'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
import { BaseChatModelParams } from 'langchain/chat_models/base'
|
||||
|
||||
/**
|
||||
* I had to run the following to build the component
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { AzureOpenAIInput, ChatOpenAI, OpenAIChatInput } from '@langchain/openai'
|
||||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { BaseLLMParams } from '@langchain/core/language_models/llms'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { AzureOpenAIInput, ChatOpenAI, OpenAIChatInput } from 'langchain/chat_models/openai'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
import { BaseLLMParams } from 'langchain/llms/base'
|
||||
|
||||
class AzureChatOpenAI_ChatModels implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { NIBittensorChatModel, BittensorInput } from 'langchain/experimental/chat_models/bittensor'
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { NIBittensorChatModel, BittensorInput } from 'langchain/experimental/chat_models/bittensor'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
|
||||
class Bittensor_ChatModels implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { AnthropicInput, ChatAnthropic } from '@langchain/anthropic'
|
||||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { BaseLLMParams } from '@langchain/core/language_models/llms'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { AnthropicInput, ChatAnthropic } from 'langchain/chat_models/anthropic'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
import { BaseLLMParams } from 'langchain/llms/base'
|
||||
|
||||
class ChatAnthropic_ChatModels implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { convertMultiOptionsToStringArray, getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
import { ChatGoogleGenerativeAI, GoogleGenerativeAIChatInput } from '@langchain/google-genai'
|
||||
import { HarmBlockThreshold, HarmCategory } from '@google/generative-ai'
|
||||
import type { SafetySetting } from '@google/generative-ai'
|
||||
import { ChatGoogleGenerativeAI, GoogleGenerativeAIChatInput } from '@langchain/google-genai'
|
||||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { convertMultiOptionsToStringArray, getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
|
||||
class GoogleGenerativeAI_ChatModels implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { ChatGooglePaLM, GooglePaLMChatInput } from '@langchain/community/chat_models/googlepalm'
|
||||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { ChatGooglePaLM, GooglePaLMChatInput } from 'langchain/chat_models/googlepalm'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
|
||||
class ChatGooglePaLM_ChatModels implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { GoogleAuthOptions } from 'google-auth-library'
|
||||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { ChatGoogleVertexAI, GoogleVertexAIChatInput } from '@langchain/community/chat_models/googlevertexai'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { ChatGoogleVertexAI, GoogleVertexAIChatInput } from 'langchain/chat_models/googlevertexai'
|
||||
import { GoogleAuthOptions } from 'google-auth-library'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
|
||||
class GoogleVertexAI_ChatModels implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { HFInput, HuggingFaceInference } from './core'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { HFInput, HuggingFaceInference } from './core'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
|
||||
class ChatHuggingFace_ChatModels implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { LLM, BaseLLMParams } from '@langchain/core/language_models/llms'
|
||||
import { getEnvironmentVariable } from '../../../src/utils'
|
||||
import { LLM, BaseLLMParams } from 'langchain/llms/base'
|
||||
|
||||
export interface HFInput {
|
||||
/** Model to use */
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
import { OpenAIChatInput, ChatOpenAI } from '@langchain/openai'
|
||||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { BaseLLMParams } from '@langchain/core/language_models/llms'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { OpenAIChat } from 'langchain/llms/openai'
|
||||
import { OpenAIChatInput } from 'langchain/chat_models/openai'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
import { BaseLLMParams } from 'langchain/llms/base'
|
||||
|
||||
class ChatLocalAI_ChatModels implements INode {
|
||||
label: string
|
||||
|
|
@ -25,7 +24,7 @@ class ChatLocalAI_ChatModels implements INode {
|
|||
this.icon = 'localai.png'
|
||||
this.category = 'Chat Models'
|
||||
this.description = 'Use local LLMs like llama.cpp, gpt4all using LocalAI'
|
||||
this.baseClasses = [this.type, 'BaseChatModel', ...getBaseClasses(OpenAIChat)]
|
||||
this.baseClasses = [this.type, 'BaseChatModel', ...getBaseClasses(ChatOpenAI)]
|
||||
this.credential = {
|
||||
label: 'Connect Credential',
|
||||
name: 'credential',
|
||||
|
|
@ -111,7 +110,7 @@ class ChatLocalAI_ChatModels implements INode {
|
|||
if (cache) obj.cache = cache
|
||||
if (localAIApiKey) obj.openAIApiKey = localAIApiKey
|
||||
|
||||
const model = new OpenAIChat(obj, { basePath })
|
||||
const model = new ChatOpenAI(obj, { basePath })
|
||||
|
||||
return model
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { ChatMistralAI, ChatMistralAIInput } from '@langchain/mistralai'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
import { ChatMistralAI, ChatMistralAIInput } from '@langchain/mistralai'
|
||||
|
||||
class ChatMistral_ChatModels implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { ChatOllama, ChatOllamaInput } from '@langchain/community/chat_models/ollama'
|
||||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { BaseLLMParams } from '@langchain/core/language_models/llms'
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { ChatOllama, ChatOllamaInput } from 'langchain/chat_models/ollama'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
import { BaseLLMParams } from 'langchain/llms/base'
|
||||
|
||||
class ChatOllama_ChatModels implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { ChatOpenAI, OpenAIChatInput } from '@langchain/openai'
|
||||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { BaseLLMParams } from '@langchain/core/language_models/llms'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { ChatOpenAI, OpenAIChatInput } from 'langchain/chat_models/openai'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
import { BaseLLMParams } from 'langchain/llms/base'
|
||||
|
||||
class ChatOpenAI_ChatModels implements INode {
|
||||
label: string
|
||||
|
|
@ -19,7 +19,7 @@ class ChatOpenAI_ChatModels implements INode {
|
|||
constructor() {
|
||||
this.label = 'ChatOpenAI'
|
||||
this.name = 'chatOpenAI'
|
||||
this.version = 3.0
|
||||
this.version = 4.0
|
||||
this.type = 'ChatOpenAI'
|
||||
this.icon = 'openai.svg'
|
||||
this.category = 'Chat Models'
|
||||
|
|
@ -59,6 +59,10 @@ class ChatOpenAI_ChatModels implements INode {
|
|||
label: 'gpt-4-1106-preview',
|
||||
name: 'gpt-4-1106-preview'
|
||||
},
|
||||
{
|
||||
label: 'gpt-4-1106-vision-preview',
|
||||
name: 'gpt-4-1106-vision-preview'
|
||||
},
|
||||
{
|
||||
label: 'gpt-4-vision-preview',
|
||||
name: 'gpt-4-vision-preview'
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { ChatOpenAI, OpenAIChatInput } from '@langchain/openai'
|
||||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { BaseLLMParams } from '@langchain/core/language_models/llms'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { ChatOpenAI, OpenAIChatInput } from 'langchain/chat_models/openai'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
import { BaseLLMParams } from 'langchain/llms/base'
|
||||
|
||||
class ChatOpenAICustom_ChatModels implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import axios, { AxiosRequestConfig } from 'axios'
|
||||
import { Document } from '@langchain/core/documents'
|
||||
import { TextSplitter } from 'langchain/text_splitter'
|
||||
import { BaseDocumentLoader } from 'langchain/document_loaders/base'
|
||||
import { Document } from 'langchain/document'
|
||||
import axios, { AxiosRequestConfig } from 'axios'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
|
||||
class API_DocumentLoaders implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import axios from 'axios'
|
||||
import { Document } from '@langchain/core/documents'
|
||||
import { TextSplitter } from 'langchain/text_splitter'
|
||||
import { BaseDocumentLoader } from 'langchain/document_loaders/base'
|
||||
import { Document } from 'langchain/document'
|
||||
import axios from 'axios'
|
||||
import { getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
|
||||
class Airtable_DocumentLoaders implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { INode, INodeData, INodeParams, ICommonObject } from '../../../src/Inter
|
|||
import { getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { TextSplitter } from 'langchain/text_splitter'
|
||||
import { ApifyDatasetLoader } from 'langchain/document_loaders/web/apify_dataset'
|
||||
import { Document } from 'langchain/document'
|
||||
import { Document } from '@langchain/core/documents'
|
||||
|
||||
class ApifyWebsiteContentCrawler_DocumentLoaders implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
|
||||
import { TextSplitter } from 'langchain/text_splitter'
|
||||
import { Document } from 'langchain/document'
|
||||
import { Document } from '@langchain/core/documents'
|
||||
import { handleEscapeCharacters } from '../../../src'
|
||||
|
||||
class PlainText_DocumentLoaders implements INode {
|
||||
|
|
|
|||
|
|
@ -1,97 +0,0 @@
|
|||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { TextSplitter } from 'langchain/text_splitter'
|
||||
import { SRTLoader } from 'langchain/document_loaders/fs/srt'
|
||||
|
||||
class Subtitles_DocumentLoaders implements INode {
|
||||
label: string
|
||||
name: string
|
||||
version: number
|
||||
description: string
|
||||
type: string
|
||||
icon: string
|
||||
category: string
|
||||
baseClasses: string[]
|
||||
inputs: INodeParams[]
|
||||
|
||||
constructor() {
|
||||
this.label = 'Subtitles File'
|
||||
this.name = 'subtitlesFile'
|
||||
this.version = 1.0
|
||||
this.type = 'Document'
|
||||
this.icon = 'subtitlesFile.svg'
|
||||
this.category = 'Document Loaders'
|
||||
this.description = `Load data from subtitles files`
|
||||
this.baseClasses = [this.type]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Subtitles File',
|
||||
name: 'subtitlesFile',
|
||||
type: 'file',
|
||||
fileType: '.srt'
|
||||
},
|
||||
{
|
||||
label: 'Text Splitter',
|
||||
name: 'textSplitter',
|
||||
type: 'TextSplitter',
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Metadata',
|
||||
name: 'metadata',
|
||||
type: 'json',
|
||||
optional: true,
|
||||
additionalParams: true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
|
||||
const subtitlesFileBase64 = nodeData.inputs?.subtitlesFile as string
|
||||
const metadata = nodeData.inputs?.metadata
|
||||
|
||||
let alldocs = []
|
||||
let files: string[] = []
|
||||
|
||||
if (subtitlesFileBase64.startsWith('[') && subtitlesFileBase64.endsWith(']')) {
|
||||
files = JSON.parse(subtitlesFileBase64)
|
||||
} else {
|
||||
files = [subtitlesFileBase64]
|
||||
}
|
||||
|
||||
for (const file of files) {
|
||||
const splitDataURI = file.split(',')
|
||||
splitDataURI.pop()
|
||||
const bf = Buffer.from(splitDataURI.pop() || '', 'base64')
|
||||
const blob = new Blob([bf])
|
||||
const loader = new SRTLoader(blob)
|
||||
|
||||
if (textSplitter) {
|
||||
const docs = await loader.loadAndSplit(textSplitter)
|
||||
alldocs.push(...docs)
|
||||
} else {
|
||||
const docs = await loader.load()
|
||||
alldocs.push(...docs)
|
||||
}
|
||||
}
|
||||
|
||||
if (metadata) {
|
||||
const parsedMetadata = typeof metadata === 'object' ? metadata : JSON.parse(metadata)
|
||||
let finaldocs = []
|
||||
for (const doc of alldocs) {
|
||||
const newdoc = {
|
||||
...doc,
|
||||
metadata: {
|
||||
...doc.metadata,
|
||||
...parsedMetadata
|
||||
}
|
||||
}
|
||||
finaldocs.push(newdoc)
|
||||
}
|
||||
return finaldocs
|
||||
}
|
||||
return alldocs
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: Subtitles_DocumentLoaders }
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M10.01 20.45C9.01153 19.7553 6 19.6248 6 21.8374C6 24.288 10.5 22.6248 10.5 25.2074C10.5 27.1484 7.49621 27.766 6 26.5" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M24.5 27V20M22 20H27" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M18 5H9C7.89543 5 7 5.89543 7 7V15M18 5L25 12M18 5V12H25M25 12V15" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M14 27V20H17C18.1046 20 19 20.8954 19 22C19 23.1046 18.1046 24 17 24M17 24H14M17 24L19 27" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 763 B |
|
|
@ -1,7 +1,7 @@
|
|||
import { INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
|
||||
import { TextSplitter } from 'langchain/text_splitter'
|
||||
import { TextLoader } from 'langchain/document_loaders/fs/text'
|
||||
import { Document } from 'langchain/document'
|
||||
import { Document } from '@langchain/core/documents'
|
||||
import { handleEscapeCharacters } from '../../../src'
|
||||
|
||||
class Text_DocumentLoaders implements INode {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { VectorStore } from 'langchain/vectorstores/base'
|
||||
import { VectorStore } from '@langchain/core/vectorstores'
|
||||
import { INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
|
||||
import { handleEscapeCharacters } from '../../../src/utils'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { BedrockRuntimeClient, InvokeModelCommand } from '@aws-sdk/client-bedrock-runtime'
|
||||
import { BedrockEmbeddings, BedrockEmbeddingsParams } from '@langchain/community/embeddings/bedrock'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { BedrockEmbeddings, BedrockEmbeddingsParams } from 'langchain/embeddings/bedrock'
|
||||
import { BedrockRuntimeClient, InvokeModelCommand } from '@aws-sdk/client-bedrock-runtime'
|
||||
|
||||
class AWSBedrockEmbedding_Embeddings implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { AzureOpenAIInput } from 'langchain/chat_models/openai'
|
||||
import { AzureOpenAIInput, OpenAIEmbeddings, OpenAIEmbeddingsParams } from '@langchain/openai'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { OpenAIEmbeddings, OpenAIEmbeddingsParams } from 'langchain/embeddings/openai'
|
||||
|
||||
class AzureOpenAIEmbedding_Embeddings implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { CohereEmbeddings, CohereEmbeddingsParams } from '@langchain/cohere'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { CohereEmbeddings, CohereEmbeddingsParams } from 'langchain/embeddings/cohere'
|
||||
|
||||
class CohereEmbedding_Embeddings implements INode {
|
||||
label: string
|
||||
|
|
@ -64,7 +64,7 @@ class CohereEmbedding_Embeddings implements INode {
|
|||
apiKey: cohereApiKey
|
||||
}
|
||||
|
||||
if (modelName) obj.modelName = modelName
|
||||
if (modelName) obj.model = modelName
|
||||
|
||||
const model = new CohereEmbeddings(obj)
|
||||
return model
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { GooglePaLMEmbeddings, GooglePaLMEmbeddingsParams } from '@langchain/community/embeddings/googlepalm'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { GooglePaLMEmbeddings, GooglePaLMEmbeddingsParams } from 'langchain/embeddings/googlepalm'
|
||||
|
||||
class GooglePaLMEmbedding_Embeddings implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { GoogleVertexAIEmbeddings, GoogleVertexAIEmbeddingsParams } from 'langchain/embeddings/googlevertexai'
|
||||
import { GoogleAuthOptions } from 'google-auth-library'
|
||||
import { GoogleVertexAIEmbeddings, GoogleVertexAIEmbeddingsParams } from '@langchain/community/embeddings/googlevertexai'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { GoogleAuthOptions } from 'google-auth-library'
|
||||
|
||||
class GoogleVertexAIEmbedding_Embeddings implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { HfInference } from '@huggingface/inference'
|
||||
import { Embeddings, EmbeddingsParams } from 'langchain/embeddings/base'
|
||||
import { Embeddings, EmbeddingsParams } from '@langchain/core/embeddings'
|
||||
import { getEnvironmentVariable } from '../../../src/utils'
|
||||
|
||||
export interface HuggingFaceInferenceEmbeddingsParams extends EmbeddingsParams {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { OpenAIEmbeddings, OpenAIEmbeddingsParams } from '@langchain/openai'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { OpenAIEmbeddings, OpenAIEmbeddingsParams } from 'langchain/embeddings/openai'
|
||||
|
||||
class LocalAIEmbedding_Embeddings implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { MistralAIEmbeddings, MistralAIEmbeddingsParams } from '@langchain/mistralai'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { MistralAIEmbeddings, MistralAIEmbeddingsParams } from '@langchain/mistralai'
|
||||
|
||||
class MistralEmbedding_Embeddings implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { OllamaEmbeddings } from '@langchain/community/embeddings/ollama'
|
||||
import { OllamaInput } from 'langchain/llms/ollama'
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { OllamaInput } from 'langchain/llms/ollama'
|
||||
import { OllamaEmbeddings } from 'langchain/embeddings/ollama'
|
||||
|
||||
class OllamaEmbedding_Embeddings implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { OpenAIEmbeddings, OpenAIEmbeddingsParams } from '@langchain/openai'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { OpenAIEmbeddings, OpenAIEmbeddingsParams } from 'langchain/embeddings/openai'
|
||||
|
||||
class OpenAIEmbedding_Embeddings implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { OpenAIEmbeddings, OpenAIEmbeddingsParams } from '@langchain/openai'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { OpenAIEmbeddings, OpenAIEmbeddingsParams } from 'langchain/embeddings/openai'
|
||||
|
||||
class OpenAIEmbeddingCustom_Embeddings implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { Bedrock } from '@langchain/community/llms/bedrock'
|
||||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { BaseLLMParams } from '@langchain/core/language_models/llms'
|
||||
import { BaseBedrockInput } from 'langchain/dist/util/bedrock'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { Bedrock } from 'langchain/llms/bedrock'
|
||||
import { BaseBedrockInput } from 'langchain/dist/util/bedrock'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
import { BaseLLMParams } from 'langchain/llms/base'
|
||||
|
||||
/**
|
||||
* I had to run the following to build the component
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import { AzureOpenAIInput, OpenAI, OpenAIInput } from '@langchain/openai'
|
||||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { BaseLLMParams } from '@langchain/core/language_models/llms'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { AzureOpenAIInput, OpenAI, OpenAIInput } from 'langchain/llms/openai'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
import { BaseLLMParams } from 'langchain/llms/base'
|
||||
|
||||
class AzureOpenAI_LLMs implements INode {
|
||||
label: string
|
||||
name: string
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { BaseLLMParams } from '@langchain/core/language_models/llms'
|
||||
import { NIBittensorLLM, BittensorInput } from 'langchain/experimental/llms/bittensor'
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { NIBittensorLLM, BittensorInput } from 'langchain/experimental/llms/bittensor'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
import { BaseLLMParams } from 'langchain/llms/base'
|
||||
|
||||
class Bittensor_LLMs implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { Cohere, CohereInput } from './core'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
|
||||
class Cohere_LLMs implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { LLM, BaseLLMParams } from 'langchain/llms/base'
|
||||
import { LLM, BaseLLMParams } from '@langchain/core/language_models/llms'
|
||||
|
||||
export interface CohereInput extends BaseLLMParams {
|
||||
/** Sampling temperature to use */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import { GooglePaLM, GooglePaLMTextInput } from '@langchain/community/llms/googlepalm'
|
||||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { GooglePaLM, GooglePaLMTextInput } from 'langchain/llms/googlepalm'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
|
||||
class GooglePaLM_LLMs implements INode {
|
||||
label: string
|
||||
name: string
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { GoogleAuthOptions } from 'google-auth-library'
|
||||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { GoogleVertexAI, GoogleVertexAITextInput } from '@langchain/community/llms/googlevertexai'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { GoogleVertexAI, GoogleVertexAITextInput } from 'langchain/llms/googlevertexai'
|
||||
import { GoogleAuthOptions } from 'google-auth-library'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
|
||||
class GoogleVertexAI_LLMs implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { HFInput, HuggingFaceInference } from './core'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
|
||||
class HuggingFaceInference_LLMs implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { LLM, BaseLLMParams } from '@langchain/core/language_models/llms'
|
||||
import { getEnvironmentVariable } from '../../../src/utils'
|
||||
import { LLM, BaseLLMParams } from 'langchain/llms/base'
|
||||
|
||||
export interface HFInput {
|
||||
/** Model to use */
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { Ollama, OllamaInput } from '@langchain/community/llms/ollama'
|
||||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { BaseLLMParams } from '@langchain/core/language_models/llms'
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { Ollama, OllamaInput } from 'langchain/llms/ollama'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
import { BaseLLMParams } from 'langchain/llms/base'
|
||||
|
||||
class Ollama_LLMs implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { OpenAI, OpenAIInput } from '@langchain/openai'
|
||||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { BaseLLMParams } from '@langchain/core/language_models/llms'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { OpenAI, OpenAIInput } from 'langchain/llms/openai'
|
||||
import { BaseLLMParams } from 'langchain/llms/base'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
|
||||
class OpenAI_LLMs implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { Replicate, ReplicateInput } from '@langchain/community/llms/replicate'
|
||||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { BaseLLMParams } from '@langchain/core/language_models/llms'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { Replicate, ReplicateInput } from 'langchain/llms/replicate'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
import { BaseLLMParams } from 'langchain/llms/base'
|
||||
|
||||
class Replicate_LLMs implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { FlowiseMemory, IMessage, INode, INodeData, INodeParams, MemoryMethods } from '../../../src/Interface'
|
||||
import { convertBaseMessagetoIMessage, getBaseClasses } from '../../../src/utils'
|
||||
import { BufferMemory, BufferMemoryInput } from 'langchain/memory'
|
||||
import { BaseMessage } from 'langchain/schema'
|
||||
import { BaseMessage } from '@langchain/core/messages'
|
||||
|
||||
class BufferMemory_Memory implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { FlowiseWindowMemory, IMessage, INode, INodeData, INodeParams, MemoryMethods } from '../../../src/Interface'
|
||||
import { convertBaseMessagetoIMessage, getBaseClasses } from '../../../src/utils'
|
||||
import { BufferWindowMemory, BufferWindowMemoryInput } from 'langchain/memory'
|
||||
import { BaseMessage } from 'langchain/schema'
|
||||
import { BaseMessage } from '@langchain/core/messages'
|
||||
|
||||
class BufferWindowMemory_Memory implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { FlowiseSummaryMemory, IMessage, INode, INodeData, INodeParams, MemoryMe
|
|||
import { convertBaseMessagetoIMessage, getBaseClasses } from '../../../src/utils'
|
||||
import { ConversationSummaryMemory, ConversationSummaryMemoryInput } from 'langchain/memory'
|
||||
import { BaseLanguageModel } from 'langchain/base_language'
|
||||
import { BaseMessage } from 'langchain/schema'
|
||||
import { BaseMessage } from '@langchain/core/messages'
|
||||
|
||||
class ConversationSummaryMemory_Memory implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ import {
|
|||
DeleteItemCommandInput,
|
||||
AttributeValue
|
||||
} from '@aws-sdk/client-dynamodb'
|
||||
import { DynamoDBChatMessageHistory } from 'langchain/stores/message/dynamodb'
|
||||
import { DynamoDBChatMessageHistory } from '@langchain/community/stores/message/dynamodb'
|
||||
import { mapStoredMessageToChatMessage, AIMessage, HumanMessage, StoredMessage, BaseMessage } from '@langchain/core/messages'
|
||||
import { BufferMemory, BufferMemoryInput } from 'langchain/memory'
|
||||
import { mapStoredMessageToChatMessage, AIMessage, HumanMessage, StoredMessage, BaseMessage } from 'langchain/schema'
|
||||
import { convertBaseMessagetoIMessage, getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { FlowiseMemory, ICommonObject, IMessage, INode, INodeData, INodeParams, MemoryMethods, MessageType } from '../../../src/Interface'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { MongoClient, Collection, Document } from 'mongodb'
|
||||
import { MongoDBChatMessageHistory } from 'langchain/stores/message/mongodb'
|
||||
import { MongoDBChatMessageHistory } from '@langchain/community/stores/message/mongodb'
|
||||
import { BufferMemory, BufferMemoryInput } from 'langchain/memory'
|
||||
import { mapStoredMessageToChatMessage, AIMessage, HumanMessage, BaseMessage } from 'langchain/schema'
|
||||
import { mapStoredMessageToChatMessage, AIMessage, HumanMessage, BaseMessage } from '@langchain/core/messages'
|
||||
import { convertBaseMessagetoIMessage, getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { FlowiseMemory, ICommonObject, IMessage, INode, INodeData, INodeParams, MemoryMethods, MessageType } from '../../../src/Interface'
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { convertBaseMessagetoIMessage, getBaseClasses, getCredentialData, getCre
|
|||
import { ICommonObject } from '../../../src'
|
||||
import { MotorheadMemory, MotorheadMemoryInput, InputValues, OutputValues } from 'langchain/memory'
|
||||
import fetch from 'node-fetch'
|
||||
import { AIMessage, BaseMessage, ChatMessage, HumanMessage } from 'langchain/schema'
|
||||
import { AIMessage, BaseMessage, ChatMessage, HumanMessage } from '@langchain/core/messages'
|
||||
|
||||
type MotorheadMessage = {
|
||||
content: string
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { Redis, RedisOptions } from 'ioredis'
|
||||
import { isEqual } from 'lodash'
|
||||
import { BufferMemory, BufferMemoryInput } from 'langchain/memory'
|
||||
import { RedisChatMessageHistory, RedisChatMessageHistoryInput } from 'langchain/stores/message/ioredis'
|
||||
import { mapStoredMessageToChatMessage, BaseMessage, AIMessage, HumanMessage } from 'langchain/schema'
|
||||
import { RedisChatMessageHistory, RedisChatMessageHistoryInput } from '@langchain/community/stores/message/ioredis'
|
||||
import { mapStoredMessageToChatMessage, BaseMessage, AIMessage, HumanMessage } from '@langchain/core/messages'
|
||||
import { INode, INodeData, INodeParams, ICommonObject, MessageType, IMessage, MemoryMethods, FlowiseMemory } from '../../../src/Interface'
|
||||
import { convertBaseMessagetoIMessage, getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,30 @@
|
|||
import { Redis } from '@upstash/redis'
|
||||
import { Redis, RedisConfigNodejs } from '@upstash/redis'
|
||||
import { isEqual } from 'lodash'
|
||||
import { BufferMemory, BufferMemoryInput } from 'langchain/memory'
|
||||
import { UpstashRedisChatMessageHistory } from 'langchain/stores/message/upstash_redis'
|
||||
import { mapStoredMessageToChatMessage, AIMessage, HumanMessage, StoredMessage, BaseMessage } from 'langchain/schema'
|
||||
import { UpstashRedisChatMessageHistory } from '@langchain/community/stores/message/upstash_redis'
|
||||
import { mapStoredMessageToChatMessage, AIMessage, HumanMessage, StoredMessage, BaseMessage } from '@langchain/core/messages'
|
||||
import { FlowiseMemory, IMessage, INode, INodeData, INodeParams, MemoryMethods, MessageType } from '../../../src/Interface'
|
||||
import { convertBaseMessagetoIMessage, getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { ICommonObject } from '../../../src/Interface'
|
||||
|
||||
let redisClientSingleton: Redis
|
||||
let redisClientOption: RedisConfigNodejs
|
||||
|
||||
const getRedisClientbyOption = (option: RedisConfigNodejs) => {
|
||||
if (!redisClientSingleton) {
|
||||
// if client doesn't exists
|
||||
redisClientSingleton = new Redis(option)
|
||||
redisClientOption = option
|
||||
return redisClientSingleton
|
||||
} else if (redisClientSingleton && !isEqual(option, redisClientOption)) {
|
||||
// if client exists but option changed
|
||||
redisClientSingleton = new Redis(option)
|
||||
redisClientOption = option
|
||||
return redisClientSingleton
|
||||
}
|
||||
return redisClientSingleton
|
||||
}
|
||||
|
||||
class UpstashRedisBackedChatMemory_Memory implements INode {
|
||||
label: string
|
||||
name: string
|
||||
|
|
@ -75,7 +94,7 @@ const initalizeUpstashRedis = async (nodeData: INodeData, options: ICommonObject
|
|||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||
const upstashRestToken = getCredentialParam('upstashRestToken', credentialData, nodeData)
|
||||
|
||||
const client = new Redis({
|
||||
const client = getRedisClientbyOption({
|
||||
url: baseURL,
|
||||
token: upstashRestToken
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
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 { ICommonObject } from '../../../src'
|
||||
import { ZepMemory, ZepMemoryInput } from '@langchain/community/memory/zep'
|
||||
import { BaseMessage } from '@langchain/core/messages'
|
||||
import { InputValues, MemoryVariables, OutputValues } from 'langchain/memory'
|
||||
import { BaseMessage } from 'langchain/schema'
|
||||
import { IMessage, INode, INodeData, INodeParams, MemoryMethods, MessageType, ICommonObject } from '../../../src/Interface'
|
||||
import { convertBaseMessagetoIMessage, getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
|
||||
class ZepMemory_Memory implements INode {
|
||||
label: string
|
||||
|
|
@ -18,7 +17,7 @@ class ZepMemory_Memory implements INode {
|
|||
inputs: INodeParams[]
|
||||
|
||||
constructor() {
|
||||
this.label = 'Zep Memory'
|
||||
this.label = 'Zep Memory - Open Source'
|
||||
this.name = 'ZepMemory'
|
||||
this.version = 2.0
|
||||
this.type = 'ZepMemory'
|
||||
|
|
@ -98,11 +97,11 @@ class ZepMemory_Memory implements INode {
|
|||
}
|
||||
|
||||
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||
return await initalizeZep(nodeData, options)
|
||||
return await initializeZep(nodeData, options)
|
||||
}
|
||||
}
|
||||
|
||||
const initalizeZep = async (nodeData: INodeData, options: ICommonObject): Promise<ZepMemory> => {
|
||||
const initializeZep = async (nodeData: INodeData, options: ICommonObject): Promise<ZepMemory> => {
|
||||
const baseURL = nodeData.inputs?.baseURL as string
|
||||
const aiPrefix = nodeData.inputs?.aiPrefix as string
|
||||
const humanPrefix = nodeData.inputs?.humanPrefix as string
|
||||
|
|
|
|||
|
|
@ -0,0 +1,181 @@
|
|||
import { IMessage, INode, INodeData, INodeParams, MemoryMethods, MessageType } from '../../../src/Interface'
|
||||
import { convertBaseMessagetoIMessage, getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { ZepMemory, ZepMemoryInput } from '@getzep/zep-cloud/langchain'
|
||||
|
||||
import { ICommonObject } from '../../../src'
|
||||
import { InputValues, MemoryVariables, OutputValues } from 'langchain/memory'
|
||||
import { BaseMessage } from 'langchain/schema'
|
||||
|
||||
class ZepMemoryCloud_Memory implements INode {
|
||||
label: string
|
||||
name: string
|
||||
version: number
|
||||
description: string
|
||||
type: string
|
||||
icon: string
|
||||
category: string
|
||||
baseClasses: string[]
|
||||
credential: INodeParams
|
||||
inputs: INodeParams[]
|
||||
|
||||
constructor() {
|
||||
this.label = 'Zep Memory - Cloud'
|
||||
this.name = 'ZepMemoryCloud'
|
||||
this.version = 2.0
|
||||
this.type = 'ZepMemory'
|
||||
this.icon = 'zep.svg'
|
||||
this.category = 'Memory'
|
||||
this.description = 'Summarizes the conversation and stores the memory in zep server'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(ZepMemory)]
|
||||
this.credential = {
|
||||
label: 'Connect Credential',
|
||||
name: 'credential',
|
||||
type: 'credential',
|
||||
optional: true,
|
||||
description: 'Configure JWT authentication on your Zep instance (Optional)',
|
||||
credentialNames: ['zepMemoryApi']
|
||||
}
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Session Id',
|
||||
name: 'sessionId',
|
||||
type: 'string',
|
||||
description:
|
||||
'If not specified, a random id will be used. Learn <a target="_blank" href="https://docs.flowiseai.com/memory/long-term-memory#ui-and-embedded-chat">more</a>',
|
||||
default: '',
|
||||
additionalParams: true,
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Memory Type',
|
||||
name: 'memoryType',
|
||||
type: 'string',
|
||||
default: 'perpetual',
|
||||
description: 'Zep Memory Type, can be perpetual or message_window',
|
||||
additionalParams: true
|
||||
},
|
||||
{
|
||||
label: 'AI Prefix',
|
||||
name: 'aiPrefix',
|
||||
type: 'string',
|
||||
default: 'ai',
|
||||
additionalParams: true
|
||||
},
|
||||
{
|
||||
label: 'Human Prefix',
|
||||
name: 'humanPrefix',
|
||||
type: 'string',
|
||||
default: 'human',
|
||||
additionalParams: true
|
||||
},
|
||||
{
|
||||
label: 'Memory Key',
|
||||
name: 'memoryKey',
|
||||
type: 'string',
|
||||
default: 'chat_history',
|
||||
additionalParams: true
|
||||
},
|
||||
{
|
||||
label: 'Input Key',
|
||||
name: 'inputKey',
|
||||
type: 'string',
|
||||
default: 'input',
|
||||
additionalParams: true
|
||||
},
|
||||
{
|
||||
label: 'Output Key',
|
||||
name: 'outputKey',
|
||||
type: 'string',
|
||||
default: 'text',
|
||||
additionalParams: true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||
return await initializeZep(nodeData, options)
|
||||
}
|
||||
}
|
||||
|
||||
const initializeZep = async (nodeData: INodeData, options: ICommonObject): Promise<ZepMemory> => {
|
||||
const aiPrefix = nodeData.inputs?.aiPrefix as string
|
||||
const humanPrefix = nodeData.inputs?.humanPrefix as string
|
||||
const memoryKey = nodeData.inputs?.memoryKey as string
|
||||
const inputKey = nodeData.inputs?.inputKey as string
|
||||
|
||||
const memoryType = nodeData.inputs?.memoryType as 'perpetual' | 'message_window'
|
||||
const sessionId = nodeData.inputs?.sessionId as string
|
||||
|
||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||
const apiKey = getCredentialParam('apiKey', credentialData, nodeData)
|
||||
const obj: ZepMemoryInput & ZepMemoryExtendedInput = {
|
||||
apiKey,
|
||||
aiPrefix,
|
||||
humanPrefix,
|
||||
memoryKey,
|
||||
sessionId,
|
||||
inputKey,
|
||||
memoryType: memoryType,
|
||||
returnMessages: true
|
||||
}
|
||||
|
||||
return new ZepMemoryExtended(obj)
|
||||
}
|
||||
|
||||
interface ZepMemoryExtendedInput {
|
||||
memoryType?: 'perpetual' | 'message_window'
|
||||
}
|
||||
|
||||
class ZepMemoryExtended extends ZepMemory implements MemoryMethods {
|
||||
memoryType: 'perpetual' | 'message_window'
|
||||
|
||||
constructor(fields: ZepMemoryInput & ZepMemoryExtendedInput) {
|
||||
super(fields)
|
||||
this.memoryType = fields.memoryType ?? 'perpetual'
|
||||
}
|
||||
|
||||
async loadMemoryVariables(values: InputValues, overrideSessionId = ''): Promise<MemoryVariables> {
|
||||
if (overrideSessionId) {
|
||||
this.sessionId = overrideSessionId
|
||||
}
|
||||
return super.loadMemoryVariables({ ...values, memoryType: this.memoryType })
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
return super.clear()
|
||||
}
|
||||
|
||||
async getChatMessages(overrideSessionId = '', returnBaseMessages = false): Promise<IMessage[] | BaseMessage[]> {
|
||||
const id = overrideSessionId ? 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 ? 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 ? overrideSessionId : this.sessionId
|
||||
await this.clear(id)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: ZepMemoryCloud_Memory }
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="16" cy="16" r="14" fill="url(#paint0_linear_119_15736)"/>
|
||||
<path d="M12.6665 9.33333V12.6667H19.3332V9.33333C19.3332 8.59695 18.7362 8 17.9998 8H13.9998C13.2635 8 12.6665 8.59695 12.6665 9.33333Z" fill="white" stroke="white" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M19.3333 14.6667H12.6667C12.2985 14.6667 12 14.9652 12 15.3334V18.0001C12 18.3683 12.2985 18.6667 12.6667 18.6667H19.3333C19.7015 18.6667 20 18.3683 20 18.0001V15.3334C20 14.9652 19.7015 14.6667 19.3333 14.6667Z" fill="white" stroke="white" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M10 14.6667V20.0001" stroke="white" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M22 14.6667V20.0001" stroke="white" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M14 20.6667V24.0001" stroke="white" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M18 20.6667V24.0001" stroke="white" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M13.3335 24.6667H14.6668" stroke="white" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M17.3335 24.6667H18.6668" stroke="white" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<circle cx="14.3889" cy="10.0556" r="0.888889" fill="#7734A6"/>
|
||||
<circle cx="17.7224" cy="10.0556" r="0.888889" fill="#7734A6"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_119_15736" x1="5.5" y1="6.5" x2="24.5" y2="26" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#6A31A6"/>
|
||||
<stop offset="1" stop-color="#9A3BA3"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
|
|
@ -1,7 +1,7 @@
|
|||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src'
|
||||
import { Moderation } from '../Moderation'
|
||||
import { OpenAIModerationRunner } from './OpenAIModerationRunner'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src'
|
||||
|
||||
class OpenAIModeration implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -2,7 +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'
|
||||
import { BaseChatModel } from '@langchain/core/language_models/chat_models'
|
||||
|
||||
class SimplePromptModeration implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { Moderation } from '../Moderation'
|
||||
import { BaseChatModel } from 'langchain/chat_models/base'
|
||||
import { BaseChatModel } from '@langchain/core/language_models/chat_models'
|
||||
|
||||
export class SimplePromptModerationRunner implements Moderation {
|
||||
private readonly denyList: string = ''
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { BaseOutputParser, CommaSeparatedListOutputParser } from '@langchain/core/output_parsers'
|
||||
import { getBaseClasses, INode, INodeData, INodeParams } from '../../../src'
|
||||
import { BaseOutputParser } from 'langchain/schema/output_parser'
|
||||
import { CommaSeparatedListOutputParser } from 'langchain/output_parsers'
|
||||
import { CATEGORY } from '../OutputParserHelpers'
|
||||
|
||||
class CSVListOutputParser implements INode {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { getBaseClasses, INode, INodeData, INodeParams } from '../../../src'
|
||||
import { BaseOutputParser } from 'langchain/schema/output_parser'
|
||||
import { CustomListOutputParser as LangchainCustomListOutputParser } from 'langchain/output_parsers'
|
||||
import { BaseOutputParser, CustomListOutputParser as LangchainCustomListOutputParser } from '@langchain/core/output_parsers'
|
||||
import { CATEGORY } from '../OutputParserHelpers'
|
||||
import { getBaseClasses, INode, INodeData, INodeParams } from '../../../src'
|
||||
|
||||
class CustomListOutputParser implements INode {
|
||||
label: string
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { BaseOutputParser } from 'langchain/schema/output_parser'
|
||||
import { BaseOutputParser } from '@langchain/core/output_parsers'
|
||||
import { ChatPromptTemplate, FewShotPromptTemplate, PromptTemplate, SystemMessagePromptTemplate } from '@langchain/core/prompts'
|
||||
import { BaseLanguageModel, BaseLanguageModelCallOptions } from '@langchain/core/language_models/base'
|
||||
import { LLMChain } from 'langchain/chains'
|
||||
import { BaseLanguageModel, BaseLanguageModelCallOptions } from 'langchain/base_language'
|
||||
import { ICommonObject } from '../../src'
|
||||
import { ChatPromptTemplate, FewShotPromptTemplate, PromptTemplate, SystemMessagePromptTemplate } from 'langchain/prompts'
|
||||
|
||||
export const CATEGORY = 'Output Parsers'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { convertSchemaToZod, getBaseClasses, INode, INodeData, INodeParams } from '../../../src'
|
||||
import { BaseOutputParser } from 'langchain/schema/output_parser'
|
||||
import { z } from 'zod'
|
||||
import { BaseOutputParser } from '@langchain/core/output_parsers'
|
||||
import { StructuredOutputParser as LangchainStructuredOutputParser } from 'langchain/output_parsers'
|
||||
import { CATEGORY } from '../OutputParserHelpers'
|
||||
import { z } from 'zod'
|
||||
import { convertSchemaToZod, getBaseClasses, INode, INodeData, INodeParams } from '../../../src'
|
||||
|
||||
class StructuredOutputParser implements INode {
|
||||
label: string
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue