add analytic

This commit is contained in:
Henry
2023-09-11 23:44:20 +01:00
parent 0a5d453338
commit d19f72db6f
42 changed files with 742 additions and 82 deletions
@@ -3,7 +3,7 @@ import { initializeAgentExecutorWithOptions, AgentExecutor } from 'langchain/age
import { getBaseClasses, mapChatHistory } from '../../../src/utils'
import { flatten } from 'lodash'
import { BaseChatMemory } from 'langchain/memory'
import { ConsoleCallbackHandler, CustomChainHandler } from '../../../src/handler'
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
const defaultMessage = `Do your best to answer the questions. Feel free to use any tools available to look up relevant information, only if necessary.`
@@ -86,13 +86,14 @@ class ConversationalRetrievalAgent_Agents implements INode {
}
const loggerHandler = new ConsoleCallbackHandler(options.logger)
const callbacks = await additionalCallbacks(nodeData, options)
if (options.socketIO && options.socketIOClientId) {
const handler = new CustomChainHandler(options.socketIO, options.socketIOClientId)
const result = await executor.call({ input }, [loggerHandler, handler])
const result = await executor.call({ input }, [loggerHandler, handler, ...callbacks])
return result?.output
} else {
const result = await executor.call({ input }, [loggerHandler])
const result = await executor.call({ input }, [loggerHandler, ...callbacks])
return result?.output
}
}