MCPcopy Index your code
hub / github.com/FlowiseAI/Flowise / onChainStart

Method onChainStart

packages/components/src/handler.ts:916–1150  ·  view source on GitHub ↗
(name: string, input: string, parentIds?: ICommonObject)

Source from the content-addressed store, hash-verified

914 }
915
916 async onChainStart(name: string, input: string, parentIds?: ICommonObject) {
917 const returnIds: ICommonObject = {
918 langSmith: {},
919 langFuse: {},
920 lunary: {},
921 langWatch: {},
922 arize: {},
923 phoenix: {},
924 opik: {}
925 }
926
927 if (Object.prototype.hasOwnProperty.call(this.handlers, 'langSmith')) {
928 if (!parentIds || !Object.keys(parentIds).length) {
929 const parentRunConfig: RunTreeConfig = {
930 name,
931 run_type: 'chain',
932 inputs: {
933 text: input
934 },
935 serialized: {},
936 project_name: this.handlers['langSmith'].langSmithProject,
937 client: this.handlers['langSmith'].client,
938 ...this.nodeData?.inputs?.analytics?.langSmith
939 }
940 const parentRun = new RunTree(parentRunConfig)
941 await parentRun.postRun()
942 // Merge rather than replace: AnalyticHandler is a per-chatId singleton, so recursive
943 // executeAgentFlow calls (e.g. iterationAgentflow) re-enter onChainStart on the same
944 // instance. Replacing would drop the outer call's parent entry and orphan its trace.
945 this.handlers['langSmith'].chainRun = {
946 ...this.handlers['langSmith'].chainRun,
947 [parentRun.id]: parentRun
948 }
949 returnIds['langSmith'].chainRun = parentRun.id
950 } else {
951 const parentRun: RunTree | undefined = this.handlers['langSmith'].chainRun[parentIds['langSmith'].chainRun]
952 if (parentRun) {
953 const childChainRun = await parentRun.createChild({
954 name,
955 run_type: 'chain',
956 inputs: {
957 text: input
958 }
959 })
960 await childChainRun.postRun()
961 this.handlers['langSmith'].chainRun = {
962 ...this.handlers['langSmith'].chainRun,
963 [childChainRun.id]: childChainRun
964 }
965 returnIds['langSmith'].chainRun = childChainRun.id
966 }
967 }
968 }
969
970 if (Object.prototype.hasOwnProperty.call(this.handlers, 'langFuse')) {
971 let langfuseTraceClient: LangfuseTraceClient
972
973 if (!parentIds || !Object.keys(parentIds).length) {

Callers 3

runMethod · 0.45
handler.test.tsFile · 0.45
executeAgentFlowFunction · 0.45

Calls 3

stringifyMethod · 0.80
updateMethod · 0.65
callMethod · 0.45

Tested by

no test coverage detected