change flat to flatten from lodash
This commit is contained in:
parent
66bfd536a1
commit
ffebe7c769
|
|
@ -3,6 +3,7 @@ import { BaseChatModel } from 'langchain/chat_models/base'
|
||||||
import { AutoGPT } from 'langchain/experimental/autogpt'
|
import { AutoGPT } from 'langchain/experimental/autogpt'
|
||||||
import { Tool } from 'langchain/tools'
|
import { Tool } from 'langchain/tools'
|
||||||
import { VectorStoreRetriever } from 'langchain/vectorstores/base'
|
import { VectorStoreRetriever } from 'langchain/vectorstores/base'
|
||||||
|
import { flatten } from 'lodash'
|
||||||
|
|
||||||
class AutoGPT_Agents implements INode {
|
class AutoGPT_Agents implements INode {
|
||||||
label: string
|
label: string
|
||||||
|
|
@ -67,7 +68,7 @@ class AutoGPT_Agents implements INode {
|
||||||
const model = nodeData.inputs?.model as BaseChatModel
|
const model = nodeData.inputs?.model as BaseChatModel
|
||||||
const vectorStoreRetriever = nodeData.inputs?.vectorStoreRetriever as VectorStoreRetriever
|
const vectorStoreRetriever = nodeData.inputs?.vectorStoreRetriever as VectorStoreRetriever
|
||||||
let tools = nodeData.inputs?.tools as Tool[]
|
let tools = nodeData.inputs?.tools as Tool[]
|
||||||
tools = tools.flat()
|
tools = flatten(tools)
|
||||||
const aiName = (nodeData.inputs?.aiName as string) || 'AutoGPT'
|
const aiName = (nodeData.inputs?.aiName as string) || 'AutoGPT'
|
||||||
const aiRole = (nodeData.inputs?.aiRole as string) || 'Assistant'
|
const aiRole = (nodeData.inputs?.aiRole as string) || 'Assistant'
|
||||||
const maxLoop = nodeData.inputs?.maxLoop as string
|
const maxLoop = nodeData.inputs?.maxLoop as string
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { BaseChatMemory, ChatMessageHistory } from 'langchain/memory'
|
||||||
import { getBaseClasses } from '../../../src/utils'
|
import { getBaseClasses } from '../../../src/utils'
|
||||||
import { AIChatMessage, HumanChatMessage } from 'langchain/schema'
|
import { AIChatMessage, HumanChatMessage } from 'langchain/schema'
|
||||||
import { BaseLanguageModel } from 'langchain/base_language'
|
import { BaseLanguageModel } from 'langchain/base_language'
|
||||||
|
import { flatten } from 'lodash'
|
||||||
|
|
||||||
class ConversationalAgent_Agents implements INode {
|
class ConversationalAgent_Agents implements INode {
|
||||||
label: string
|
label: string
|
||||||
|
|
@ -63,7 +64,7 @@ class ConversationalAgent_Agents implements INode {
|
||||||
async init(nodeData: INodeData): Promise<any> {
|
async init(nodeData: INodeData): Promise<any> {
|
||||||
const model = nodeData.inputs?.model as BaseLanguageModel
|
const model = nodeData.inputs?.model as BaseLanguageModel
|
||||||
let tools = nodeData.inputs?.tools as Tool[]
|
let tools = nodeData.inputs?.tools as Tool[]
|
||||||
tools = tools.flat()
|
tools = flatten(tools)
|
||||||
const memory = nodeData.inputs?.memory as BaseChatMemory
|
const memory = nodeData.inputs?.memory as BaseChatMemory
|
||||||
const humanMessage = nodeData.inputs?.humanMessage as string
|
const humanMessage = nodeData.inputs?.humanMessage as string
|
||||||
const systemMessage = nodeData.inputs?.systemMessage as string
|
const systemMessage = nodeData.inputs?.systemMessage as string
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { initializeAgentExecutorWithOptions, AgentExecutor } from 'langchain/age
|
||||||
import { getBaseClasses } from '../../../src/utils'
|
import { getBaseClasses } from '../../../src/utils'
|
||||||
import { Tool } from 'langchain/tools'
|
import { Tool } from 'langchain/tools'
|
||||||
import { BaseLanguageModel } from 'langchain/base_language'
|
import { BaseLanguageModel } from 'langchain/base_language'
|
||||||
|
import { flatten } from 'lodash'
|
||||||
|
|
||||||
class MRKLAgentChat_Agents implements INode {
|
class MRKLAgentChat_Agents implements INode {
|
||||||
label: string
|
label: string
|
||||||
|
|
@ -40,7 +41,7 @@ class MRKLAgentChat_Agents implements INode {
|
||||||
async init(nodeData: INodeData): Promise<any> {
|
async init(nodeData: INodeData): Promise<any> {
|
||||||
const model = nodeData.inputs?.model as BaseLanguageModel
|
const model = nodeData.inputs?.model as BaseLanguageModel
|
||||||
let tools = nodeData.inputs?.tools as Tool[]
|
let tools = nodeData.inputs?.tools as Tool[]
|
||||||
tools = tools.flat()
|
tools = flatten(tools)
|
||||||
const executor = await initializeAgentExecutorWithOptions(tools, model, {
|
const executor = await initializeAgentExecutorWithOptions(tools, model, {
|
||||||
agentType: 'chat-zero-shot-react-description',
|
agentType: 'chat-zero-shot-react-description',
|
||||||
verbose: process.env.DEBUG === 'true' ? true : false
|
verbose: process.env.DEBUG === 'true' ? true : false
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { initializeAgentExecutorWithOptions, AgentExecutor } from 'langchain/age
|
||||||
import { Tool } from 'langchain/tools'
|
import { Tool } from 'langchain/tools'
|
||||||
import { getBaseClasses } from '../../../src/utils'
|
import { getBaseClasses } from '../../../src/utils'
|
||||||
import { BaseLanguageModel } from 'langchain/base_language'
|
import { BaseLanguageModel } from 'langchain/base_language'
|
||||||
|
import { flatten } from 'lodash'
|
||||||
|
|
||||||
class MRKLAgentLLM_Agents implements INode {
|
class MRKLAgentLLM_Agents implements INode {
|
||||||
label: string
|
label: string
|
||||||
|
|
@ -40,7 +41,7 @@ class MRKLAgentLLM_Agents implements INode {
|
||||||
async init(nodeData: INodeData): Promise<any> {
|
async init(nodeData: INodeData): Promise<any> {
|
||||||
const model = nodeData.inputs?.model as BaseLanguageModel
|
const model = nodeData.inputs?.model as BaseLanguageModel
|
||||||
let tools = nodeData.inputs?.tools as Tool[]
|
let tools = nodeData.inputs?.tools as Tool[]
|
||||||
tools = tools.flat()
|
tools = flatten(tools)
|
||||||
|
|
||||||
const executor = await initializeAgentExecutorWithOptions(tools, model, {
|
const executor = await initializeAgentExecutorWithOptions(tools, model, {
|
||||||
agentType: 'zero-shot-react-description',
|
agentType: 'zero-shot-react-description',
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { Chroma } from 'langchain/vectorstores/chroma'
|
||||||
import { Embeddings } from 'langchain/embeddings/base'
|
import { Embeddings } from 'langchain/embeddings/base'
|
||||||
import { Document } from 'langchain/document'
|
import { Document } from 'langchain/document'
|
||||||
import { getBaseClasses } from '../../../src/utils'
|
import { getBaseClasses } from '../../../src/utils'
|
||||||
|
import { flatten } from 'lodash'
|
||||||
|
|
||||||
class ChromaUpsert_VectorStores implements INode {
|
class ChromaUpsert_VectorStores implements INode {
|
||||||
label: string
|
label: string
|
||||||
|
|
@ -68,7 +69,7 @@ class ChromaUpsert_VectorStores implements INode {
|
||||||
const chromaURL = nodeData.inputs?.chromaURL as string
|
const chromaURL = nodeData.inputs?.chromaURL as string
|
||||||
const output = nodeData.outputs?.output as string
|
const output = nodeData.outputs?.output as string
|
||||||
|
|
||||||
const flattenDocs = docs && docs.length ? docs.flat() : []
|
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
||||||
const finalDocs = []
|
const finalDocs = []
|
||||||
for (let i = 0; i < flattenDocs.length; i += 1) {
|
for (let i = 0; i < flattenDocs.length; i += 1) {
|
||||||
finalDocs.push(new Document(flattenDocs[i]))
|
finalDocs.push(new Document(flattenDocs[i]))
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { Embeddings } from 'langchain/embeddings/base'
|
||||||
import { Document } from 'langchain/document'
|
import { Document } from 'langchain/document'
|
||||||
import { getBaseClasses } from '../../../src/utils'
|
import { getBaseClasses } from '../../../src/utils'
|
||||||
import { FaissStore } from 'langchain/vectorstores/faiss'
|
import { FaissStore } from 'langchain/vectorstores/faiss'
|
||||||
|
import { flatten } from 'lodash'
|
||||||
|
|
||||||
class FaissUpsert_VectorStores implements INode {
|
class FaissUpsert_VectorStores implements INode {
|
||||||
label: string
|
label: string
|
||||||
|
|
@ -63,7 +64,7 @@ class FaissUpsert_VectorStores implements INode {
|
||||||
const output = nodeData.outputs?.output as string
|
const output = nodeData.outputs?.output as string
|
||||||
const basePath = nodeData.inputs?.basePath as string
|
const basePath = nodeData.inputs?.basePath as string
|
||||||
|
|
||||||
const flattenDocs = docs && docs.length ? docs.flat() : []
|
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
||||||
const finalDocs = []
|
const finalDocs = []
|
||||||
for (let i = 0; i < flattenDocs.length; i += 1) {
|
for (let i = 0; i < flattenDocs.length; i += 1) {
|
||||||
finalDocs.push(new Document(flattenDocs[i]))
|
finalDocs.push(new Document(flattenDocs[i]))
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { MemoryVectorStore } from 'langchain/vectorstores/memory'
|
||||||
import { Embeddings } from 'langchain/embeddings/base'
|
import { Embeddings } from 'langchain/embeddings/base'
|
||||||
import { Document } from 'langchain/document'
|
import { Document } from 'langchain/document'
|
||||||
import { getBaseClasses } from '../../../src/utils'
|
import { getBaseClasses } from '../../../src/utils'
|
||||||
|
import { flatten } from 'lodash'
|
||||||
|
|
||||||
class InMemoryVectorStore_VectorStores implements INode {
|
class InMemoryVectorStore_VectorStores implements INode {
|
||||||
label: string
|
label: string
|
||||||
|
|
@ -55,7 +56,7 @@ class InMemoryVectorStore_VectorStores implements INode {
|
||||||
const embeddings = nodeData.inputs?.embeddings as Embeddings
|
const embeddings = nodeData.inputs?.embeddings as Embeddings
|
||||||
const output = nodeData.outputs?.output as string
|
const output = nodeData.outputs?.output as string
|
||||||
|
|
||||||
const flattenDocs = docs && docs.length ? docs.flat() : []
|
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
||||||
const finalDocs = []
|
const finalDocs = []
|
||||||
for (let i = 0; i < flattenDocs.length; i += 1) {
|
for (let i = 0; i < flattenDocs.length; i += 1) {
|
||||||
finalDocs.push(new Document(flattenDocs[i]))
|
finalDocs.push(new Document(flattenDocs[i]))
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { PineconeLibArgs, PineconeStore } from 'langchain/vectorstores/pinecone'
|
||||||
import { Embeddings } from 'langchain/embeddings/base'
|
import { Embeddings } from 'langchain/embeddings/base'
|
||||||
import { Document } from 'langchain/document'
|
import { Document } from 'langchain/document'
|
||||||
import { getBaseClasses } from '../../../src/utils'
|
import { getBaseClasses } from '../../../src/utils'
|
||||||
|
import { flatten } from 'lodash'
|
||||||
|
|
||||||
class PineconeUpsert_VectorStores implements INode {
|
class PineconeUpsert_VectorStores implements INode {
|
||||||
label: string
|
label: string
|
||||||
|
|
@ -90,7 +91,7 @@ class PineconeUpsert_VectorStores implements INode {
|
||||||
|
|
||||||
const pineconeIndex = client.Index(index)
|
const pineconeIndex = client.Index(index)
|
||||||
|
|
||||||
const flattenDocs = docs && docs.length ? docs.flat() : []
|
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
||||||
const finalDocs = []
|
const finalDocs = []
|
||||||
for (let i = 0; i < flattenDocs.length; i += 1) {
|
for (let i = 0; i < flattenDocs.length; i += 1) {
|
||||||
finalDocs.push(new Document(flattenDocs[i]))
|
finalDocs.push(new Document(flattenDocs[i]))
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { Document } from 'langchain/document'
|
||||||
import { getBaseClasses } from '../../../src/utils'
|
import { getBaseClasses } from '../../../src/utils'
|
||||||
import { SupabaseVectorStore } from 'langchain/vectorstores/supabase'
|
import { SupabaseVectorStore } from 'langchain/vectorstores/supabase'
|
||||||
import { createClient } from '@supabase/supabase-js'
|
import { createClient } from '@supabase/supabase-js'
|
||||||
|
import { flatten } from 'lodash'
|
||||||
|
|
||||||
class SupabaseUpsert_VectorStores implements INode {
|
class SupabaseUpsert_VectorStores implements INode {
|
||||||
label: string
|
label: string
|
||||||
|
|
@ -82,7 +83,7 @@ class SupabaseUpsert_VectorStores implements INode {
|
||||||
|
|
||||||
const client = createClient(supabaseProjUrl, supabaseApiKey)
|
const client = createClient(supabaseProjUrl, supabaseApiKey)
|
||||||
|
|
||||||
const flattenDocs = docs && docs.length ? docs.flat() : []
|
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
||||||
const finalDocs = []
|
const finalDocs = []
|
||||||
for (let i = 0; i < flattenDocs.length; i += 1) {
|
for (let i = 0; i < flattenDocs.length; i += 1) {
|
||||||
finalDocs.push(new Document(flattenDocs[i]))
|
finalDocs.push(new Document(flattenDocs[i]))
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { Document } from 'langchain/document'
|
||||||
import { getBaseClasses } from '../../../src/utils'
|
import { getBaseClasses } from '../../../src/utils'
|
||||||
import { WeaviateLibArgs, WeaviateStore } from 'langchain/vectorstores/weaviate'
|
import { WeaviateLibArgs, WeaviateStore } from 'langchain/vectorstores/weaviate'
|
||||||
import weaviate, { WeaviateClient, ApiKey } from 'weaviate-ts-client'
|
import weaviate, { WeaviateClient, ApiKey } from 'weaviate-ts-client'
|
||||||
|
import { flatten } from 'lodash'
|
||||||
|
|
||||||
class WeaviateUpsert_VectorStores implements INode {
|
class WeaviateUpsert_VectorStores implements INode {
|
||||||
label: string
|
label: string
|
||||||
|
|
@ -122,7 +123,7 @@ class WeaviateUpsert_VectorStores implements INode {
|
||||||
|
|
||||||
const client: WeaviateClient = weaviate.client(clientConfig)
|
const client: WeaviateClient = weaviate.client(clientConfig)
|
||||||
|
|
||||||
const flattenDocs = docs && docs.length ? docs.flat() : []
|
const flattenDocs = docs && docs.length ? flatten(docs) : []
|
||||||
const finalDocs = []
|
const finalDocs = []
|
||||||
for (let i = 0; i < flattenDocs.length; i += 1) {
|
for (let i = 0; i < flattenDocs.length; i += 1) {
|
||||||
finalDocs.push(new Document(flattenDocs[i]))
|
finalDocs.push(new Document(flattenDocs[i]))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue