langgraph-ui-components 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es100.js +25 -157
- package/dist/index.es100.js.map +1 -1
- package/dist/index.es101.js +3130 -176
- package/dist/index.es101.js.map +1 -1
- package/dist/index.es102.js +36 -13
- package/dist/index.es102.js.map +1 -1
- package/dist/index.es103.js +5 -30
- package/dist/index.es103.js.map +1 -1
- package/dist/index.es104.js +69 -30
- package/dist/index.es104.js.map +1 -1
- package/dist/index.es105.js +28 -3148
- package/dist/index.es105.js.map +1 -1
- package/dist/index.es106.js +5 -16
- package/dist/index.es106.js.map +1 -1
- package/dist/index.es107.js +2 -7
- package/dist/index.es107.js.map +1 -1
- package/dist/index.es108.js +13 -2
- package/dist/index.es108.js.map +1 -1
- package/dist/index.es109.js +499 -9
- package/dist/index.es109.js.map +1 -1
- package/dist/index.es11.js +2 -2
- package/dist/index.es11.js.map +1 -1
- package/dist/index.es110.js +5 -501
- package/dist/index.es110.js.map +1 -1
- package/dist/index.es111.js +2 -7
- package/dist/index.es111.js.map +1 -1
- package/dist/index.es112.js +148 -2
- package/dist/index.es112.js.map +1 -1
- package/dist/index.es113.js +878 -118
- package/dist/index.es113.js.map +1 -1
- package/dist/index.es114.js +251 -877
- package/dist/index.es114.js.map +1 -1
- package/dist/index.es115.js +3 -281
- package/dist/index.es115.js.map +1 -1
- package/dist/index.es116.js +445 -3
- package/dist/index.es116.js.map +1 -1
- package/dist/index.es117.js +39 -437
- package/dist/index.es117.js.map +1 -1
- package/dist/index.es118.js +22 -46
- package/dist/index.es118.js.map +1 -1
- package/dist/index.es119.js +78 -21
- package/dist/index.es119.js.map +1 -1
- package/dist/index.es120.js +126 -76
- package/dist/index.es120.js.map +1 -1
- package/dist/index.es121.js +45 -125
- package/dist/index.es121.js.map +1 -1
- package/dist/index.es122.js +9 -48
- package/dist/index.es122.js.map +1 -1
- package/dist/index.es123.js +45 -10
- package/dist/index.es123.js.map +1 -1
- package/dist/index.es124.js +97 -43
- package/dist/index.es124.js.map +1 -1
- package/dist/index.es125.js +48 -94
- package/dist/index.es125.js.map +1 -1
- package/dist/index.es126.js +14 -51
- package/dist/index.es126.js.map +1 -1
- package/dist/index.es127.js +13 -162
- package/dist/index.es127.js.map +1 -1
- package/dist/index.es128.js +89 -2
- package/dist/index.es128.js.map +1 -1
- package/dist/index.es129.js +2 -15
- package/dist/index.es129.js.map +1 -1
- package/dist/index.es130.js +54 -87
- package/dist/index.es130.js.map +1 -1
- package/dist/index.es131.js +100 -2
- package/dist/index.es131.js.map +1 -1
- package/dist/index.es132.js +186 -51
- package/dist/index.es132.js.map +1 -1
- package/dist/index.es133.js +97 -87
- package/dist/index.es133.js.map +1 -1
- package/dist/index.es134.js +31 -187
- package/dist/index.es134.js.map +1 -1
- package/dist/index.es135.js +10 -110
- package/dist/index.es135.js.map +1 -1
- package/dist/index.es136.js +11 -35
- package/dist/index.es136.js.map +1 -1
- package/dist/index.es137.js +12 -10
- package/dist/index.es137.js.map +1 -1
- package/dist/index.es138.js +90 -10
- package/dist/index.es138.js.map +1 -1
- package/dist/index.es139.js +274 -11
- package/dist/index.es139.js.map +1 -1
- package/dist/index.es140.js +2 -91
- package/dist/index.es140.js.map +1 -1
- package/dist/index.es141.js +150 -261
- package/dist/index.es141.js.map +1 -1
- package/dist/index.es142.js +51 -2
- package/dist/index.es142.js.map +1 -1
- package/dist/index.es143.js +34 -158
- package/dist/index.es143.js.map +1 -1
- package/dist/index.es144.js +34 -50
- package/dist/index.es144.js.map +1 -1
- package/dist/index.es145.js +32 -32
- package/dist/index.es145.js.map +1 -1
- package/dist/index.es146.js +23 -34
- package/dist/index.es146.js.map +1 -1
- package/dist/index.es147.js +583 -32
- package/dist/index.es147.js.map +1 -1
- package/dist/index.es148.js +121 -20
- package/dist/index.es148.js.map +1 -1
- package/dist/index.es149.js +158 -585
- package/dist/index.es149.js.map +1 -1
- package/dist/index.es15.js +15 -15
- package/dist/index.es150.js +2 -125
- package/dist/index.es150.js.map +1 -1
- package/dist/index.es157.js +2 -2
- package/dist/index.es159.js +2 -2
- package/dist/index.es161.js +64 -25
- package/dist/index.es161.js.map +1 -1
- package/dist/index.es162.js +22 -12
- package/dist/index.es162.js.map +1 -1
- package/dist/index.es163.js +5 -53
- package/dist/index.es163.js.map +1 -1
- package/dist/index.es164.js +337 -52
- package/dist/index.es164.js.map +1 -1
- package/dist/index.es165.js +24 -21
- package/dist/index.es165.js.map +1 -1
- package/dist/index.es166.js +12 -6
- package/dist/index.es166.js.map +1 -1
- package/dist/index.es167.js +49 -344
- package/dist/index.es167.js.map +1 -1
- package/dist/index.es175.js +1 -1
- package/dist/index.es178.js +1 -1
- package/dist/index.es183.js +1 -1
- package/dist/index.es195.js +2 -2
- package/dist/index.es197.js +2 -2
- package/dist/index.es200.js +1 -1
- package/dist/index.es201.js +1 -1
- package/dist/index.es203.js +1 -1
- package/dist/index.es204.js +2 -2
- package/dist/index.es206.js +1 -1
- package/dist/index.es209.js +3 -3
- package/dist/index.es21.js +1 -1
- package/dist/index.es210.js +2 -2
- package/dist/index.es212.js +1 -1
- package/dist/index.es214.js +1 -1
- package/dist/index.es215.js +1 -1
- package/dist/index.es217.js +1 -1
- package/dist/index.es218.js +2 -2
- package/dist/index.es219.js +1 -1
- package/dist/index.es220.js +1 -1
- package/dist/index.es221.js +1 -1
- package/dist/index.es222.js +1 -1
- package/dist/index.es223.js +1 -1
- package/dist/index.es224.js +1 -1
- package/dist/index.es225.js +1 -1
- package/dist/index.es229.js +2 -2
- package/dist/index.es28.js +7 -7
- package/dist/index.es29.js +1 -1
- package/dist/index.es32.js +4 -4
- package/dist/index.es33.js +15 -1191
- package/dist/index.es33.js.map +1 -1
- package/dist/index.es34.js +117 -6
- package/dist/index.es34.js.map +1 -1
- package/dist/index.es35.js +70 -8
- package/dist/index.es35.js.map +1 -1
- package/dist/index.es36.js +19 -148
- package/dist/index.es36.js.map +1 -1
- package/dist/index.es37.js +255 -112
- package/dist/index.es37.js.map +1 -1
- package/dist/index.es38.js +40 -68
- package/dist/index.es38.js.map +1 -1
- package/dist/index.es39.js +214 -17
- package/dist/index.es39.js.map +1 -1
- package/dist/index.es40.js +53 -247
- package/dist/index.es40.js.map +1 -1
- package/dist/index.es41.js +123 -24
- package/dist/index.es41.js.map +1 -1
- package/dist/index.es42.js +14 -205
- package/dist/index.es42.js.map +1 -1
- package/dist/index.es43.js +221 -58
- package/dist/index.es43.js.map +1 -1
- package/dist/index.es44.js +7 -140
- package/dist/index.es44.js.map +1 -1
- package/dist/index.es45.js +1185 -17
- package/dist/index.es45.js.map +1 -1
- package/dist/index.es46.js +6 -229
- package/dist/index.es46.js.map +1 -1
- package/dist/index.es47.js +146 -15
- package/dist/index.es47.js.map +1 -1
- package/dist/index.es49.js +7 -90
- package/dist/index.es49.js.map +1 -1
- package/dist/index.es50.js +92 -6
- package/dist/index.es50.js.map +1 -1
- package/dist/index.es51.js +3 -14
- package/dist/index.es51.js.map +1 -1
- package/dist/index.es52.js +36 -8
- package/dist/index.es52.js.map +1 -1
- package/dist/index.es53.js +61 -83
- package/dist/index.es53.js.map +1 -1
- package/dist/index.es54.js +37 -3
- package/dist/index.es54.js.map +1 -1
- package/dist/index.es55.js +304 -34
- package/dist/index.es55.js.map +1 -1
- package/dist/index.es56.js +9 -72
- package/dist/index.es56.js.map +1 -1
- package/dist/index.es57.js +85 -32
- package/dist/index.es57.js.map +1 -1
- package/dist/index.es58.js +6 -304
- package/dist/index.es58.js.map +1 -1
- package/dist/index.es59.js +15 -9
- package/dist/index.es59.js.map +1 -1
- package/dist/index.es60.js +142 -5
- package/dist/index.es60.js.map +1 -1
- package/dist/index.es61.js +285 -148
- package/dist/index.es61.js.map +1 -1
- package/dist/index.es62.js +62 -668
- package/dist/index.es62.js.map +1 -1
- package/dist/index.es63.js +201 -131
- package/dist/index.es63.js.map +1 -1
- package/dist/index.es64.js +29 -295
- package/dist/index.es64.js.map +1 -1
- package/dist/index.es65.js +8 -65
- package/dist/index.es65.js.map +1 -1
- package/dist/index.es66.js +9 -210
- package/dist/index.es66.js.map +1 -1
- package/dist/index.es67.js +181 -28
- package/dist/index.es67.js.map +1 -1
- package/dist/index.es68.js +23 -8
- package/dist/index.es68.js.map +1 -1
- package/dist/index.es69.js +1397 -9
- package/dist/index.es69.js.map +1 -1
- package/dist/index.es70.js +9 -187
- package/dist/index.es70.js.map +1 -1
- package/dist/index.es71.js +8 -24
- package/dist/index.es71.js.map +1 -1
- package/dist/index.es72.js +5 -1399
- package/dist/index.es72.js.map +1 -1
- package/dist/index.es73.js +163 -9
- package/dist/index.es73.js.map +1 -1
- package/dist/index.es74.js +672 -8
- package/dist/index.es74.js.map +1 -1
- package/dist/index.es75.js +11 -36
- package/dist/index.es75.js.map +1 -1
- package/dist/index.es76.js +40 -5
- package/dist/index.es76.js.map +1 -1
- package/dist/index.es77.js +32 -71
- package/dist/index.es77.js.map +1 -1
- package/dist/index.es78.js +225 -30
- package/dist/index.es78.js.map +1 -1
- package/dist/index.es79.js +29 -11
- package/dist/index.es79.js.map +1 -1
- package/dist/index.es80.js +72 -37
- package/dist/index.es80.js.map +1 -1
- package/dist/index.es81.js +74 -32
- package/dist/index.es81.js.map +1 -1
- package/dist/index.es82.js +46 -226
- package/dist/index.es82.js.map +1 -1
- package/dist/index.es83.js +6 -6
- package/dist/index.es83.js.map +1 -1
- package/dist/index.es84.js +39 -71
- package/dist/index.es84.js.map +1 -1
- package/dist/index.es85.js +54 -73
- package/dist/index.es85.js.map +1 -1
- package/dist/index.es86.js +13 -52
- package/dist/index.es86.js.map +1 -1
- package/dist/index.es87.js +135 -28
- package/dist/index.es87.js.map +1 -1
- package/dist/index.es88.js +20 -42
- package/dist/index.es88.js.map +1 -1
- package/dist/index.es89.js +175 -50
- package/dist/index.es89.js.map +1 -1
- package/dist/index.es90.js +240 -12
- package/dist/index.es90.js.map +1 -1
- package/dist/index.es91.js +348 -130
- package/dist/index.es91.js.map +1 -1
- package/dist/index.es92.js +134 -18
- package/dist/index.es92.js.map +1 -1
- package/dist/index.es93.js +62 -174
- package/dist/index.es93.js.map +1 -1
- package/dist/index.es94.js +30 -234
- package/dist/index.es94.js.map +1 -1
- package/dist/index.es95.js +26 -344
- package/dist/index.es95.js.map +1 -1
- package/dist/index.es96.js +156 -127
- package/dist/index.es96.js.map +1 -1
- package/dist/index.es97.js +196 -63
- package/dist/index.es97.js.map +1 -1
- package/dist/index.es98.js +14 -37
- package/dist/index.es98.js.map +1 -1
- package/dist/index.es99.js +27 -34
- package/dist/index.es99.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es133.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es133.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/
|
|
1
|
+
{"version":3,"file":"index.es133.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/tracers/tracer_langchain.js"],"sourcesContent":["import { __export } from \"../_virtual/rolldown_runtime.js\";\nimport { mergeUsageMetadata } from \"../messages/metadata.js\";\nimport { AIMessage } from \"../messages/ai.js\";\nimport { BaseTracer } from \"./base.js\";\nimport { getDefaultLangChainClientSingleton } from \"../singletons/tracer.js\";\nimport { getCurrentRunTree } from \"langsmith/singletons/traceable\";\nimport { RunTree } from \"langsmith/run_trees\";\nimport { getDefaultProjectName } from \"langsmith\";\n\n//#region src/tracers/tracer_langchain.ts\nvar tracer_langchain_exports = {};\n__export(tracer_langchain_exports, { LangChainTracer: () => LangChainTracer });\n/**\n* Extract usage_metadata from chat generations.\n*\n* Iterates through generations to find and aggregates all usage_metadata\n* found in chat messages. This is typically present in chat model outputs.\n*/\nfunction _getUsageMetadataFromGenerations(generations) {\n\tlet output = void 0;\n\tfor (const generationBatch of generations) for (const generation of generationBatch) if (AIMessage.isInstance(generation.message) && generation.message.usage_metadata !== void 0) output = mergeUsageMetadata(output, generation.message.usage_metadata);\n\treturn output;\n}\nvar LangChainTracer = class LangChainTracer extends BaseTracer {\n\tname = \"langchain_tracer\";\n\tprojectName;\n\texampleId;\n\tclient;\n\treplicas;\n\tusesRunTreeMap = true;\n\tconstructor(fields = {}) {\n\t\tsuper(fields);\n\t\tconst { exampleId, projectName, client, replicas } = fields;\n\t\tthis.projectName = projectName ?? getDefaultProjectName();\n\t\tthis.replicas = replicas;\n\t\tthis.exampleId = exampleId;\n\t\tthis.client = client ?? getDefaultLangChainClientSingleton();\n\t\tconst traceableTree = LangChainTracer.getTraceableRunTree();\n\t\tif (traceableTree) this.updateFromRunTree(traceableTree);\n\t}\n\tasync persistRun(_run) {}\n\tasync onRunCreate(run) {\n\t\tif (!run.extra?.lc_defers_inputs) {\n\t\t\tconst runTree = this.getRunTreeWithTracingConfig(run.id);\n\t\t\tawait runTree?.postRun();\n\t\t}\n\t}\n\tasync onRunUpdate(run) {\n\t\tconst runTree = this.getRunTreeWithTracingConfig(run.id);\n\t\tif (run.extra?.lc_defers_inputs) await runTree?.postRun();\n\t\telse await runTree?.patchRun();\n\t}\n\tonLLMEnd(run) {\n\t\tconst outputs = run.outputs;\n\t\tif (outputs?.generations) {\n\t\t\tconst usageMetadata = _getUsageMetadataFromGenerations(outputs.generations);\n\t\t\tif (usageMetadata !== void 0) {\n\t\t\t\trun.extra = run.extra ?? {};\n\t\t\t\tconst metadata = run.extra.metadata ?? {};\n\t\t\t\tmetadata.usage_metadata = usageMetadata;\n\t\t\t\trun.extra.metadata = metadata;\n\t\t\t}\n\t\t}\n\t}\n\tgetRun(id) {\n\t\treturn this.runTreeMap.get(id);\n\t}\n\tupdateFromRunTree(runTree) {\n\t\tthis.runTreeMap.set(runTree.id, runTree);\n\t\tlet rootRun = runTree;\n\t\tconst visited = /* @__PURE__ */ new Set();\n\t\twhile (rootRun.parent_run) {\n\t\t\tif (visited.has(rootRun.id)) break;\n\t\t\tvisited.add(rootRun.id);\n\t\t\tif (!rootRun.parent_run) break;\n\t\t\trootRun = rootRun.parent_run;\n\t\t}\n\t\tvisited.clear();\n\t\tconst queue = [rootRun];\n\t\twhile (queue.length > 0) {\n\t\t\tconst current = queue.shift();\n\t\t\tif (!current || visited.has(current.id)) continue;\n\t\t\tvisited.add(current.id);\n\t\t\tthis.runTreeMap.set(current.id, current);\n\t\t\tif (current.child_runs) queue.push(...current.child_runs);\n\t\t}\n\t\tthis.client = runTree.client ?? this.client;\n\t\tthis.replicas = runTree.replicas ?? this.replicas;\n\t\tthis.projectName = runTree.project_name ?? this.projectName;\n\t\tthis.exampleId = runTree.reference_example_id ?? this.exampleId;\n\t}\n\tgetRunTreeWithTracingConfig(id) {\n\t\tconst runTree = this.runTreeMap.get(id);\n\t\tif (!runTree) return void 0;\n\t\treturn new RunTree({\n\t\t\t...runTree,\n\t\t\tclient: this.client,\n\t\t\tproject_name: this.projectName,\n\t\t\treplicas: this.replicas,\n\t\t\treference_example_id: this.exampleId,\n\t\t\ttracingEnabled: true\n\t\t});\n\t}\n\tstatic getTraceableRunTree() {\n\t\ttry {\n\t\t\treturn getCurrentRunTree(true);\n\t\t} catch {\n\t\t\treturn void 0;\n\t\t}\n\t}\n};\n\n//#endregion\nexport { LangChainTracer, tracer_langchain_exports };\n//# sourceMappingURL=tracer_langchain.js.map"],"names":["LangChainTracer"],"mappings":";;;;;;;;;;;;AAUG,IAAC,2BAA2B,CAAA;AAC/B,SAAS,0BAA0B,EAAE,iBAAiB,MAAM,gBAAe,CAAE;AAO7E,SAAS,iCAAiC,aAAa;AACtD,MAAI,SAAS;AACb,aAAW,mBAAmB,YAAa,YAAW,cAAc,gBAAiB,KAAI,UAAU,WAAW,WAAW,OAAO,KAAK,WAAW,QAAQ,mBAAmB,OAAQ,UAAS,mBAAmB,QAAQ,WAAW,QAAQ,cAAc;AACxP,SAAO;AACR;AACG,IAAC,kBAAkB,MAAMA,yBAAwB,WAAW;AAAA,EAC9D,OAAO;AAAA,EACP;AAAA,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AI,QAAQ,IAAI,QAAQ,EAAE,EAAG;AAC7B,cAAQ,IAAI,QAAQ,EAAE;AACtB,UAAI,CAAC,QAAQ,WAAY;AACzB,gBAAU,QAAQ;AAAA,IACnB;AACA,YAAQ,MAAK;AACb,UAAM,QAAQ,CAAC,OAAO;AACtB,WAAO,MAAM,SAAS,GAAG;AACxB,YAAM,UAAU,MAAM,MAAK;AAC3B,UAAI,CAAC,WAAW,QAAQ,IAAI,QAAQ,EAAE,EAAG;AACzC,cAAQ,IAAI,QAAQ,EAAE;AACtB,WAAK,WAAW,IAAI,QAAQ,IAAI,OAAO;AACvC,UAAI,QAAQ,WAAY,OAAM,KAAK,GAAG,QAAQ,UAAU;AAAA,IACzD;AACA,SAAK,SAAS,QAAQ,UAAU,KAAK;AACrC,SAAK,WAAW,QAAQ,YAAY,KAAK;AACzC,SAAK,cAAc,QAAQ,gBAAgB,KAAK;AAChD,SAAK,YAAY,QAAQ,wBAAwB,KAAK;AAAA,EACvD;AAAA,EACA,4BAA4B,IAAI;AAC/B,UAAM,UAAU,KAAK,WAAW,IAAI,EAAE;AACtC,QAAI,CAAC,QAAS,QAAO;AACrB,WAAO,IAAI,QAAQ;AAAA,MAClB,GAAG;AAAA,MACH,QAAQ,KAAK;AAAA,MACb,cAAc,KAAK;AAAA,MACnB,UAAU,KAAK;AAAA,MACf,sBAAsB,KAAK;AAAA,MAC3B,gBAAgB;AAAA,IACnB,CAAG;AAAA,EACF;AAAA,EACA,OAAO,sBAAsB;AAC5B,QAAI;AACH,aAAO,kBAAkB,IAAI;AAAA,IAC9B,QAAQ;AACP,aAAO;AAAA,IACR;AAAA,EACD;AACD;","x_google_ignoreList":[0]}
|
package/dist/index.es134.js
CHANGED
|
@@ -1,194 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return
|
|
1
|
+
import { getDefaultLangChainClientSingleton } from "./index.es159.js";
|
|
2
|
+
import { getGlobalAsyncLocalStorageInstance } from "./index.es108.js";
|
|
3
|
+
import PQueueMod from "./index.es110.js";
|
|
4
|
+
let queue;
|
|
5
|
+
function createQueue() {
|
|
6
|
+
const PQueue = "default" in PQueueMod ? PQueueMod.default : PQueueMod;
|
|
7
|
+
return new PQueue({
|
|
8
|
+
autoStart: true,
|
|
9
|
+
concurrency: 1
|
|
10
|
+
});
|
|
8
11
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} catch {
|
|
13
|
-
return fallback;
|
|
14
|
-
}
|
|
12
|
+
function getQueue() {
|
|
13
|
+
if (typeof queue === "undefined") queue = createQueue();
|
|
14
|
+
return queue;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
async function consumeCallback(promiseFn, wait) {
|
|
17
|
+
if (wait === true) {
|
|
18
|
+
const asyncLocalStorageInstance = getGlobalAsyncLocalStorageInstance();
|
|
19
|
+
if (asyncLocalStorageInstance !== void 0) await asyncLocalStorageInstance.run(void 0, async () => promiseFn());
|
|
20
|
+
else await promiseFn();
|
|
21
|
+
} else {
|
|
22
|
+
queue = getQueue();
|
|
23
|
+
queue.add(async () => {
|
|
24
|
+
const asyncLocalStorageInstance = getGlobalAsyncLocalStorageInstance();
|
|
25
|
+
if (asyncLocalStorageInstance !== void 0) await asyncLocalStorageInstance.run(void 0, async () => promiseFn());
|
|
26
|
+
else await promiseFn();
|
|
27
|
+
});
|
|
28
|
+
}
|
|
20
29
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (elapsed$1 < 1e3) return `${elapsed$1}ms`;
|
|
25
|
-
return `${(elapsed$1 / 1e3).toFixed(2)}s`;
|
|
30
|
+
async function awaitAllCallbacks() {
|
|
31
|
+
const defaultClient = getDefaultLangChainClientSingleton();
|
|
32
|
+
await Promise.allSettled([typeof queue !== "undefined" ? queue.onIdle() : Promise.resolve(), defaultClient.awaitPendingTraceBatches()]);
|
|
26
33
|
}
|
|
27
|
-
const { color } = styles;
|
|
28
|
-
var ConsoleCallbackHandler = class extends BaseTracer {
|
|
29
|
-
name = "console_callback_handler";
|
|
30
|
-
/**
|
|
31
|
-
* Method used to persist the run. In this case, it simply returns a
|
|
32
|
-
* resolved promise as there's no persistence logic.
|
|
33
|
-
* @param _run The run to persist.
|
|
34
|
-
* @returns A resolved promise.
|
|
35
|
-
*/
|
|
36
|
-
persistRun(_run) {
|
|
37
|
-
return Promise.resolve();
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Method used to get all the parent runs of a given run.
|
|
41
|
-
* @param run The run whose parents are to be retrieved.
|
|
42
|
-
* @returns An array of parent runs.
|
|
43
|
-
*/
|
|
44
|
-
getParents(run) {
|
|
45
|
-
const parents = [];
|
|
46
|
-
let currentRun = run;
|
|
47
|
-
while (currentRun.parent_run_id) {
|
|
48
|
-
const parent = this.runMap.get(currentRun.parent_run_id);
|
|
49
|
-
if (parent) {
|
|
50
|
-
parents.push(parent);
|
|
51
|
-
currentRun = parent;
|
|
52
|
-
} else break;
|
|
53
|
-
}
|
|
54
|
-
return parents;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Method used to get a string representation of the run's lineage, which
|
|
58
|
-
* is used in logging.
|
|
59
|
-
* @param run The run whose lineage is to be retrieved.
|
|
60
|
-
* @returns A string representation of the run's lineage.
|
|
61
|
-
*/
|
|
62
|
-
getBreadcrumbs(run) {
|
|
63
|
-
const parents = this.getParents(run).reverse();
|
|
64
|
-
const string = [...parents, run].map((parent, i, arr) => {
|
|
65
|
-
const name = `${parent.execution_order}:${parent.run_type}:${parent.name}`;
|
|
66
|
-
return i === arr.length - 1 ? wrap(styles.bold, name) : name;
|
|
67
|
-
}).join(" > ");
|
|
68
|
-
return wrap(color.grey, string);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Method used to log the start of a chain run.
|
|
72
|
-
* @param run The chain run that has started.
|
|
73
|
-
* @returns void
|
|
74
|
-
*/
|
|
75
|
-
onChainStart(run) {
|
|
76
|
-
const crumbs = this.getBreadcrumbs(run);
|
|
77
|
-
console.log(`${wrap(color.green, "[chain/start]")} [${crumbs}] Entering Chain run with input: ${tryJsonStringify(run.inputs, "[inputs]")}`);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Method used to log the end of a chain run.
|
|
81
|
-
* @param run The chain run that has ended.
|
|
82
|
-
* @returns void
|
|
83
|
-
*/
|
|
84
|
-
onChainEnd(run) {
|
|
85
|
-
const crumbs = this.getBreadcrumbs(run);
|
|
86
|
-
console.log(`${wrap(color.cyan, "[chain/end]")} [${crumbs}] [${elapsed(run)}] Exiting Chain run with output: ${tryJsonStringify(run.outputs, "[outputs]")}`);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Method used to log any errors of a chain run.
|
|
90
|
-
* @param run The chain run that has errored.
|
|
91
|
-
* @returns void
|
|
92
|
-
*/
|
|
93
|
-
onChainError(run) {
|
|
94
|
-
const crumbs = this.getBreadcrumbs(run);
|
|
95
|
-
console.log(`${wrap(color.red, "[chain/error]")} [${crumbs}] [${elapsed(run)}] Chain run errored with error: ${tryJsonStringify(run.error, "[error]")}`);
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Method used to log the start of an LLM run.
|
|
99
|
-
* @param run The LLM run that has started.
|
|
100
|
-
* @returns void
|
|
101
|
-
*/
|
|
102
|
-
onLLMStart(run) {
|
|
103
|
-
const crumbs = this.getBreadcrumbs(run);
|
|
104
|
-
const inputs = "prompts" in run.inputs ? { prompts: run.inputs.prompts.map((p) => p.trim()) } : run.inputs;
|
|
105
|
-
console.log(`${wrap(color.green, "[llm/start]")} [${crumbs}] Entering LLM run with input: ${tryJsonStringify(inputs, "[inputs]")}`);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Method used to log the end of an LLM run.
|
|
109
|
-
* @param run The LLM run that has ended.
|
|
110
|
-
* @returns void
|
|
111
|
-
*/
|
|
112
|
-
onLLMEnd(run) {
|
|
113
|
-
const crumbs = this.getBreadcrumbs(run);
|
|
114
|
-
console.log(`${wrap(color.cyan, "[llm/end]")} [${crumbs}] [${elapsed(run)}] Exiting LLM run with output: ${tryJsonStringify(run.outputs, "[response]")}`);
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Method used to log any errors of an LLM run.
|
|
118
|
-
* @param run The LLM run that has errored.
|
|
119
|
-
* @returns void
|
|
120
|
-
*/
|
|
121
|
-
onLLMError(run) {
|
|
122
|
-
const crumbs = this.getBreadcrumbs(run);
|
|
123
|
-
console.log(`${wrap(color.red, "[llm/error]")} [${crumbs}] [${elapsed(run)}] LLM run errored with error: ${tryJsonStringify(run.error, "[error]")}`);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Method used to log the start of a tool run.
|
|
127
|
-
* @param run The tool run that has started.
|
|
128
|
-
* @returns void
|
|
129
|
-
*/
|
|
130
|
-
onToolStart(run) {
|
|
131
|
-
const crumbs = this.getBreadcrumbs(run);
|
|
132
|
-
console.log(`${wrap(color.green, "[tool/start]")} [${crumbs}] Entering Tool run with input: "${formatKVMapItem(run.inputs.input)}"`);
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Method used to log the end of a tool run.
|
|
136
|
-
* @param run The tool run that has ended.
|
|
137
|
-
* @returns void
|
|
138
|
-
*/
|
|
139
|
-
onToolEnd(run) {
|
|
140
|
-
const crumbs = this.getBreadcrumbs(run);
|
|
141
|
-
console.log(`${wrap(color.cyan, "[tool/end]")} [${crumbs}] [${elapsed(run)}] Exiting Tool run with output: "${formatKVMapItem(run.outputs?.output)}"`);
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Method used to log any errors of a tool run.
|
|
145
|
-
* @param run The tool run that has errored.
|
|
146
|
-
* @returns void
|
|
147
|
-
*/
|
|
148
|
-
onToolError(run) {
|
|
149
|
-
const crumbs = this.getBreadcrumbs(run);
|
|
150
|
-
console.log(`${wrap(color.red, "[tool/error]")} [${crumbs}] [${elapsed(run)}] Tool run errored with error: ${tryJsonStringify(run.error, "[error]")}`);
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Method used to log the start of a retriever run.
|
|
154
|
-
* @param run The retriever run that has started.
|
|
155
|
-
* @returns void
|
|
156
|
-
*/
|
|
157
|
-
onRetrieverStart(run) {
|
|
158
|
-
const crumbs = this.getBreadcrumbs(run);
|
|
159
|
-
console.log(`${wrap(color.green, "[retriever/start]")} [${crumbs}] Entering Retriever run with input: ${tryJsonStringify(run.inputs, "[inputs]")}`);
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Method used to log the end of a retriever run.
|
|
163
|
-
* @param run The retriever run that has ended.
|
|
164
|
-
* @returns void
|
|
165
|
-
*/
|
|
166
|
-
onRetrieverEnd(run) {
|
|
167
|
-
const crumbs = this.getBreadcrumbs(run);
|
|
168
|
-
console.log(`${wrap(color.cyan, "[retriever/end]")} [${crumbs}] [${elapsed(run)}] Exiting Retriever run with output: ${tryJsonStringify(run.outputs, "[outputs]")}`);
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Method used to log any errors of a retriever run.
|
|
172
|
-
* @param run The retriever run that has errored.
|
|
173
|
-
* @returns void
|
|
174
|
-
*/
|
|
175
|
-
onRetrieverError(run) {
|
|
176
|
-
const crumbs = this.getBreadcrumbs(run);
|
|
177
|
-
console.log(`${wrap(color.red, "[retriever/error]")} [${crumbs}] [${elapsed(run)}] Retriever run errored with error: ${tryJsonStringify(run.error, "[error]")}`);
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Method used to log the action selected by the agent.
|
|
181
|
-
* @param run The run in which the agent action occurred.
|
|
182
|
-
* @returns void
|
|
183
|
-
*/
|
|
184
|
-
onAgentAction(run) {
|
|
185
|
-
const agentRun = run;
|
|
186
|
-
const crumbs = this.getBreadcrumbs(run);
|
|
187
|
-
console.log(`${wrap(color.blue, "[agent/action]")} [${crumbs}] Agent selected action: ${tryJsonStringify(agentRun.actions[agentRun.actions.length - 1], "[action]")}`);
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
34
|
export {
|
|
191
|
-
|
|
192
|
-
|
|
35
|
+
awaitAllCallbacks,
|
|
36
|
+
consumeCallback
|
|
193
37
|
};
|
|
194
38
|
//# sourceMappingURL=index.es134.js.map
|
package/dist/index.es134.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es134.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/tracers/console.js"],"sourcesContent":["import { __export } from \"../_virtual/rolldown_runtime.js\";\nimport { BaseTracer } from \"./base.js\";\nimport styles from \"ansi-styles\";\n\n//#region src/tracers/console.ts\nvar console_exports = {};\n__export(console_exports, { ConsoleCallbackHandler: () => ConsoleCallbackHandler });\nfunction wrap(style, text) {\n\treturn `${style.open}${text}${style.close}`;\n}\nfunction tryJsonStringify(obj, fallback) {\n\ttry {\n\t\treturn JSON.stringify(obj, null, 2);\n\t} catch {\n\t\treturn fallback;\n\t}\n}\nfunction formatKVMapItem(value) {\n\tif (typeof value === \"string\") return value.trim();\n\tif (value === null || value === void 0) return value;\n\treturn tryJsonStringify(value, value.toString());\n}\nfunction elapsed(run) {\n\tif (!run.end_time) return \"\";\n\tconst elapsed$1 = run.end_time - run.start_time;\n\tif (elapsed$1 < 1e3) return `${elapsed$1}ms`;\n\treturn `${(elapsed$1 / 1e3).toFixed(2)}s`;\n}\nconst { color } = styles;\n/**\n* A tracer that logs all events to the console. It extends from the\n* `BaseTracer` class and overrides its methods to provide custom logging\n* functionality.\n* @example\n* ```typescript\n*\n* const llm = new ChatAnthropic({\n* temperature: 0,\n* tags: [\"example\", \"callbacks\", \"constructor\"],\n* callbacks: [new ConsoleCallbackHandler()],\n* });\n*\n* ```\n*/\nvar ConsoleCallbackHandler = class extends BaseTracer {\n\tname = \"console_callback_handler\";\n\t/**\n\t* Method used to persist the run. In this case, it simply returns a\n\t* resolved promise as there's no persistence logic.\n\t* @param _run The run to persist.\n\t* @returns A resolved promise.\n\t*/\n\tpersistRun(_run) {\n\t\treturn Promise.resolve();\n\t}\n\t/**\n\t* Method used to get all the parent runs of a given run.\n\t* @param run The run whose parents are to be retrieved.\n\t* @returns An array of parent runs.\n\t*/\n\tgetParents(run) {\n\t\tconst parents = [];\n\t\tlet currentRun = run;\n\t\twhile (currentRun.parent_run_id) {\n\t\t\tconst parent = this.runMap.get(currentRun.parent_run_id);\n\t\t\tif (parent) {\n\t\t\t\tparents.push(parent);\n\t\t\t\tcurrentRun = parent;\n\t\t\t} else break;\n\t\t}\n\t\treturn parents;\n\t}\n\t/**\n\t* Method used to get a string representation of the run's lineage, which\n\t* is used in logging.\n\t* @param run The run whose lineage is to be retrieved.\n\t* @returns A string representation of the run's lineage.\n\t*/\n\tgetBreadcrumbs(run) {\n\t\tconst parents = this.getParents(run).reverse();\n\t\tconst string = [...parents, run].map((parent, i, arr) => {\n\t\t\tconst name = `${parent.execution_order}:${parent.run_type}:${parent.name}`;\n\t\t\treturn i === arr.length - 1 ? wrap(styles.bold, name) : name;\n\t\t}).join(\" > \");\n\t\treturn wrap(color.grey, string);\n\t}\n\t/**\n\t* Method used to log the start of a chain run.\n\t* @param run The chain run that has started.\n\t* @returns void\n\t*/\n\tonChainStart(run) {\n\t\tconst crumbs = this.getBreadcrumbs(run);\n\t\tconsole.log(`${wrap(color.green, \"[chain/start]\")} [${crumbs}] Entering Chain run with input: ${tryJsonStringify(run.inputs, \"[inputs]\")}`);\n\t}\n\t/**\n\t* Method used to log the end of a chain run.\n\t* @param run The chain run that has ended.\n\t* @returns void\n\t*/\n\tonChainEnd(run) {\n\t\tconst crumbs = this.getBreadcrumbs(run);\n\t\tconsole.log(`${wrap(color.cyan, \"[chain/end]\")} [${crumbs}] [${elapsed(run)}] Exiting Chain run with output: ${tryJsonStringify(run.outputs, \"[outputs]\")}`);\n\t}\n\t/**\n\t* Method used to log any errors of a chain run.\n\t* @param run The chain run that has errored.\n\t* @returns void\n\t*/\n\tonChainError(run) {\n\t\tconst crumbs = this.getBreadcrumbs(run);\n\t\tconsole.log(`${wrap(color.red, \"[chain/error]\")} [${crumbs}] [${elapsed(run)}] Chain run errored with error: ${tryJsonStringify(run.error, \"[error]\")}`);\n\t}\n\t/**\n\t* Method used to log the start of an LLM run.\n\t* @param run The LLM run that has started.\n\t* @returns void\n\t*/\n\tonLLMStart(run) {\n\t\tconst crumbs = this.getBreadcrumbs(run);\n\t\tconst inputs = \"prompts\" in run.inputs ? { prompts: run.inputs.prompts.map((p) => p.trim()) } : run.inputs;\n\t\tconsole.log(`${wrap(color.green, \"[llm/start]\")} [${crumbs}] Entering LLM run with input: ${tryJsonStringify(inputs, \"[inputs]\")}`);\n\t}\n\t/**\n\t* Method used to log the end of an LLM run.\n\t* @param run The LLM run that has ended.\n\t* @returns void\n\t*/\n\tonLLMEnd(run) {\n\t\tconst crumbs = this.getBreadcrumbs(run);\n\t\tconsole.log(`${wrap(color.cyan, \"[llm/end]\")} [${crumbs}] [${elapsed(run)}] Exiting LLM run with output: ${tryJsonStringify(run.outputs, \"[response]\")}`);\n\t}\n\t/**\n\t* Method used to log any errors of an LLM run.\n\t* @param run The LLM run that has errored.\n\t* @returns void\n\t*/\n\tonLLMError(run) {\n\t\tconst crumbs = this.getBreadcrumbs(run);\n\t\tconsole.log(`${wrap(color.red, \"[llm/error]\")} [${crumbs}] [${elapsed(run)}] LLM run errored with error: ${tryJsonStringify(run.error, \"[error]\")}`);\n\t}\n\t/**\n\t* Method used to log the start of a tool run.\n\t* @param run The tool run that has started.\n\t* @returns void\n\t*/\n\tonToolStart(run) {\n\t\tconst crumbs = this.getBreadcrumbs(run);\n\t\tconsole.log(`${wrap(color.green, \"[tool/start]\")} [${crumbs}] Entering Tool run with input: \"${formatKVMapItem(run.inputs.input)}\"`);\n\t}\n\t/**\n\t* Method used to log the end of a tool run.\n\t* @param run The tool run that has ended.\n\t* @returns void\n\t*/\n\tonToolEnd(run) {\n\t\tconst crumbs = this.getBreadcrumbs(run);\n\t\tconsole.log(`${wrap(color.cyan, \"[tool/end]\")} [${crumbs}] [${elapsed(run)}] Exiting Tool run with output: \"${formatKVMapItem(run.outputs?.output)}\"`);\n\t}\n\t/**\n\t* Method used to log any errors of a tool run.\n\t* @param run The tool run that has errored.\n\t* @returns void\n\t*/\n\tonToolError(run) {\n\t\tconst crumbs = this.getBreadcrumbs(run);\n\t\tconsole.log(`${wrap(color.red, \"[tool/error]\")} [${crumbs}] [${elapsed(run)}] Tool run errored with error: ${tryJsonStringify(run.error, \"[error]\")}`);\n\t}\n\t/**\n\t* Method used to log the start of a retriever run.\n\t* @param run The retriever run that has started.\n\t* @returns void\n\t*/\n\tonRetrieverStart(run) {\n\t\tconst crumbs = this.getBreadcrumbs(run);\n\t\tconsole.log(`${wrap(color.green, \"[retriever/start]\")} [${crumbs}] Entering Retriever run with input: ${tryJsonStringify(run.inputs, \"[inputs]\")}`);\n\t}\n\t/**\n\t* Method used to log the end of a retriever run.\n\t* @param run The retriever run that has ended.\n\t* @returns void\n\t*/\n\tonRetrieverEnd(run) {\n\t\tconst crumbs = this.getBreadcrumbs(run);\n\t\tconsole.log(`${wrap(color.cyan, \"[retriever/end]\")} [${crumbs}] [${elapsed(run)}] Exiting Retriever run with output: ${tryJsonStringify(run.outputs, \"[outputs]\")}`);\n\t}\n\t/**\n\t* Method used to log any errors of a retriever run.\n\t* @param run The retriever run that has errored.\n\t* @returns void\n\t*/\n\tonRetrieverError(run) {\n\t\tconst crumbs = this.getBreadcrumbs(run);\n\t\tconsole.log(`${wrap(color.red, \"[retriever/error]\")} [${crumbs}] [${elapsed(run)}] Retriever run errored with error: ${tryJsonStringify(run.error, \"[error]\")}`);\n\t}\n\t/**\n\t* Method used to log the action selected by the agent.\n\t* @param run The run in which the agent action occurred.\n\t* @returns void\n\t*/\n\tonAgentAction(run) {\n\t\tconst agentRun = run;\n\t\tconst crumbs = this.getBreadcrumbs(run);\n\t\tconsole.log(`${wrap(color.blue, \"[agent/action]\")} [${crumbs}] Agent selected action: ${tryJsonStringify(agentRun.actions[agentRun.actions.length - 1], \"[action]\")}`);\n\t}\n};\n\n//#endregion\nexport { ConsoleCallbackHandler, console_exports };\n//# sourceMappingURL=console.js.map"],"names":[],"mappings":";;;AAKG,IAAC,kBAAkB,CAAA;AACtB,SAAS,iBAAiB,EAAE,wBAAwB,MAAM,uBAAsB,CAAE;AAClF,SAAS,KAAK,OAAO,MAAM;AAC1B,SAAO,GAAG,MAAM,IAAI,GAAG,IAAI,GAAG,MAAM,KAAK;AAC1C;AACA,SAAS,iBAAiB,KAAK,UAAU;AACxC,MAAI;AACH,WAAO,KAAK,UAAU,KAAK,MAAM,CAAC;AAAA,EACnC,QAAQ;AACP,WAAO;AAAA,EACR;AACD;AACA,SAAS,gBAAgB,OAAO;AAC/B,MAAI,OAAO,UAAU,SAAU,QAAO,MAAM,KAAI;AAChD,MAAI,UAAU,QAAQ,UAAU,OAAQ,QAAO;AAC/C,SAAO,iBAAiB,OAAO,MAAM,SAAQ,CAAE;AAChD;AACA,SAAS,QAAQ,KAAK;AACrB,MAAI,CAAC,IAAI,SAAU,QAAO;AAC1B,QAAM,YAAY,IAAI,WAAW,IAAI;AACrC,MAAI,YAAY,IAAK,QAAO,GAAG,SAAS;AACxC,SAAO,IAAI,YAAY,KAAK,QAAQ,CAAC,CAAC;AACvC;AACA,MAAM,EAAE,MAAK,IAAK;AAgBf,IAAC,yBAAyB,cAAc,WAAW;AAAA,EACrD,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOP,WAAW,MAAM;AAChB,WAAO,QAAQ,QAAO;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,WAAW,KAAK;AACf,UAAM,UAAU,CAAA;AAChB,QAAI,aAAa;AACjB,WAAO,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BAA4B,iBAAiB,SAAS,QAAQ,SAAS,QAAQ,SAAS,CAAC,GAAG,UAAU,CAAC,EAAE;AAAA,EACtK;AACD;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"index.es134.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/singletons/callbacks.js"],"sourcesContent":["import { getDefaultLangChainClientSingleton } from \"./tracer.js\";\nimport { getGlobalAsyncLocalStorageInstance } from \"./async_local_storage/globals.js\";\nimport PQueueMod from \"p-queue\";\n\n//#region src/singletons/callbacks.ts\nlet queue;\n/**\n* Creates a queue using the p-queue library. The queue is configured to\n* auto-start and has a concurrency of 1, meaning it will process tasks\n* one at a time.\n*/\nfunction createQueue() {\n\tconst PQueue = \"default\" in PQueueMod ? PQueueMod.default : PQueueMod;\n\treturn new PQueue({\n\t\tautoStart: true,\n\t\tconcurrency: 1\n\t});\n}\nfunction getQueue() {\n\tif (typeof queue === \"undefined\") queue = createQueue();\n\treturn queue;\n}\n/**\n* Consume a promise, either adding it to the queue or waiting for it to resolve\n* @param promiseFn Promise to consume\n* @param wait Whether to wait for the promise to resolve or resolve immediately\n*/\nasync function consumeCallback(promiseFn, wait) {\n\tif (wait === true) {\n\t\tconst asyncLocalStorageInstance = getGlobalAsyncLocalStorageInstance();\n\t\tif (asyncLocalStorageInstance !== void 0) await asyncLocalStorageInstance.run(void 0, async () => promiseFn());\n\t\telse await promiseFn();\n\t} else {\n\t\tqueue = getQueue();\n\t\tqueue.add(async () => {\n\t\t\tconst asyncLocalStorageInstance = getGlobalAsyncLocalStorageInstance();\n\t\t\tif (asyncLocalStorageInstance !== void 0) await asyncLocalStorageInstance.run(void 0, async () => promiseFn());\n\t\t\telse await promiseFn();\n\t\t});\n\t}\n}\n/**\n* Waits for all promises in the queue to resolve. If the queue is\n* undefined, it immediately resolves a promise.\n*/\nasync function awaitAllCallbacks() {\n\tconst defaultClient = getDefaultLangChainClientSingleton();\n\tawait Promise.allSettled([typeof queue !== \"undefined\" ? queue.onIdle() : Promise.resolve(), defaultClient.awaitPendingTraceBatches()]);\n}\n\n//#endregion\nexport { awaitAllCallbacks, consumeCallback };\n//# sourceMappingURL=callbacks.js.map"],"names":[],"mappings":";;;AAKA,IAAI;AAMJ,SAAS,cAAc;AACtB,QAAM,SAAS,aAAa,YAAY,UAAU,UAAU;AAC5D,SAAO,IAAI,OAAO;AAAA,IACjB,WAAW;AAAA,IACX,aAAa;AAAA,EACf,CAAE;AACF;AACA,SAAS,WAAW;AACnB,MAAI,OAAO,UAAU,YAAa,SAAQ,YAAW;AACrD,SAAO;AACR;AAMA,eAAe,gBAAgB,WAAW,MAAM;AAC/C,MAAI,SAAS,MAAM;AAClB,UAAM,4BAA4B,mCAAkC;AACpE,QAAI,8BAA8B,OAAQ,OAAM,0BAA0B,IAAI,QAAQ,YAAY,WAAW;AAAA,QACxG,OAAM,UAAS;AAAA,EACrB,OAAO;AACN,YAAQ,SAAQ;AAChB,UAAM,IAAI,YAAY;AACrB,YAAM,4BAA4B,mCAAkC;AACpE,UAAI,8BAA8B,OAAQ,OAAM,0BAA0B,IAAI,QAAQ,YAAY,WAAW;AAAA,UACxG,OAAM,UAAS;AAAA,IACrB,CAAC;AAAA,EACF;AACD;AAKA,eAAe,oBAAoB;AAClC,QAAM,gBAAgB,mCAAkC;AACxD,QAAM,QAAQ,WAAW,CAAC,OAAO,UAAU,cAAc,MAAM,OAAM,IAAK,QAAQ,QAAO,GAAI,cAAc,yBAAwB,CAAE,CAAC;AACvI;","x_google_ignoreList":[0]}
|
package/dist/index.es135.js
CHANGED
|
@@ -1,113 +1,13 @@
|
|
|
1
|
-
import { __export } from "./index.
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import "uuid";
|
|
9
|
-
import "./index.es111.js";
|
|
10
|
-
import "./index.es112.js";
|
|
11
|
-
import "./index.es113.js";
|
|
12
|
-
import { getDefaultProjectName } from "./index.es160.js";
|
|
13
|
-
var tracer_langchain_exports = {};
|
|
14
|
-
__export(tracer_langchain_exports, { LangChainTracer: () => LangChainTracer });
|
|
15
|
-
function _getUsageMetadataFromGenerations(generations) {
|
|
16
|
-
let output = void 0;
|
|
17
|
-
for (const generationBatch of generations) for (const generation of generationBatch) if (AIMessage.isInstance(generation.message) && generation.message.usage_metadata !== void 0) output = mergeUsageMetadata(output, generation.message.usage_metadata);
|
|
18
|
-
return output;
|
|
19
|
-
}
|
|
20
|
-
var LangChainTracer = class LangChainTracer2 extends BaseTracer {
|
|
21
|
-
name = "langchain_tracer";
|
|
22
|
-
projectName;
|
|
23
|
-
exampleId;
|
|
24
|
-
client;
|
|
25
|
-
replicas;
|
|
26
|
-
usesRunTreeMap = true;
|
|
27
|
-
constructor(fields = {}) {
|
|
28
|
-
super(fields);
|
|
29
|
-
const { exampleId, projectName, client, replicas } = fields;
|
|
30
|
-
this.projectName = projectName ?? getDefaultProjectName();
|
|
31
|
-
this.replicas = replicas;
|
|
32
|
-
this.exampleId = exampleId;
|
|
33
|
-
this.client = client ?? getDefaultLangChainClientSingleton();
|
|
34
|
-
const traceableTree = LangChainTracer2.getTraceableRunTree();
|
|
35
|
-
if (traceableTree) this.updateFromRunTree(traceableTree);
|
|
36
|
-
}
|
|
37
|
-
async persistRun(_run) {
|
|
38
|
-
}
|
|
39
|
-
async onRunCreate(run) {
|
|
40
|
-
if (!run.extra?.lc_defers_inputs) {
|
|
41
|
-
const runTree = this.getRunTreeWithTracingConfig(run.id);
|
|
42
|
-
await runTree?.postRun();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
async onRunUpdate(run) {
|
|
46
|
-
const runTree = this.getRunTreeWithTracingConfig(run.id);
|
|
47
|
-
if (run.extra?.lc_defers_inputs) await runTree?.postRun();
|
|
48
|
-
else await runTree?.patchRun();
|
|
49
|
-
}
|
|
50
|
-
onLLMEnd(run) {
|
|
51
|
-
const outputs = run.outputs;
|
|
52
|
-
if (outputs?.generations) {
|
|
53
|
-
const usageMetadata = _getUsageMetadataFromGenerations(outputs.generations);
|
|
54
|
-
if (usageMetadata !== void 0) {
|
|
55
|
-
run.extra = run.extra ?? {};
|
|
56
|
-
const metadata = run.extra.metadata ?? {};
|
|
57
|
-
metadata.usage_metadata = usageMetadata;
|
|
58
|
-
run.extra.metadata = metadata;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
getRun(id) {
|
|
63
|
-
return this.runTreeMap.get(id);
|
|
64
|
-
}
|
|
65
|
-
updateFromRunTree(runTree) {
|
|
66
|
-
this.runTreeMap.set(runTree.id, runTree);
|
|
67
|
-
let rootRun = runTree;
|
|
68
|
-
const visited = /* @__PURE__ */ new Set();
|
|
69
|
-
while (rootRun.parent_run) {
|
|
70
|
-
if (visited.has(rootRun.id)) break;
|
|
71
|
-
visited.add(rootRun.id);
|
|
72
|
-
if (!rootRun.parent_run) break;
|
|
73
|
-
rootRun = rootRun.parent_run;
|
|
74
|
-
}
|
|
75
|
-
visited.clear();
|
|
76
|
-
const queue = [rootRun];
|
|
77
|
-
while (queue.length > 0) {
|
|
78
|
-
const current = queue.shift();
|
|
79
|
-
if (!current || visited.has(current.id)) continue;
|
|
80
|
-
visited.add(current.id);
|
|
81
|
-
this.runTreeMap.set(current.id, current);
|
|
82
|
-
if (current.child_runs) queue.push(...current.child_runs);
|
|
83
|
-
}
|
|
84
|
-
this.client = runTree.client ?? this.client;
|
|
85
|
-
this.replicas = runTree.replicas ?? this.replicas;
|
|
86
|
-
this.projectName = runTree.project_name ?? this.projectName;
|
|
87
|
-
this.exampleId = runTree.reference_example_id ?? this.exampleId;
|
|
88
|
-
}
|
|
89
|
-
getRunTreeWithTracingConfig(id) {
|
|
90
|
-
const runTree = this.runTreeMap.get(id);
|
|
91
|
-
if (!runTree) return void 0;
|
|
92
|
-
return new RunTree({
|
|
93
|
-
...runTree,
|
|
94
|
-
client: this.client,
|
|
95
|
-
project_name: this.projectName,
|
|
96
|
-
replicas: this.replicas,
|
|
97
|
-
reference_example_id: this.exampleId,
|
|
98
|
-
tracingEnabled: true
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
static getTraceableRunTree() {
|
|
102
|
-
try {
|
|
103
|
-
return getCurrentRunTree(true);
|
|
104
|
-
} catch {
|
|
105
|
-
return void 0;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
};
|
|
1
|
+
import { __export } from "./index.es49.js";
|
|
2
|
+
import { consumeCallback, awaitAllCallbacks } from "./index.es134.js";
|
|
3
|
+
var promises_exports = {};
|
|
4
|
+
__export(promises_exports, {
|
|
5
|
+
awaitAllCallbacks: () => awaitAllCallbacks,
|
|
6
|
+
consumeCallback: () => consumeCallback
|
|
7
|
+
});
|
|
109
8
|
export {
|
|
110
|
-
|
|
111
|
-
|
|
9
|
+
awaitAllCallbacks,
|
|
10
|
+
consumeCallback,
|
|
11
|
+
promises_exports
|
|
112
12
|
};
|
|
113
13
|
//# sourceMappingURL=index.es135.js.map
|
package/dist/index.es135.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es135.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/
|
|
1
|
+
{"version":3,"file":"index.es135.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/callbacks/promises.js"],"sourcesContent":["import { __export } from \"../_virtual/rolldown_runtime.js\";\nimport { awaitAllCallbacks, consumeCallback } from \"../singletons/callbacks.js\";\n\n//#region src/callbacks/promises.ts\nvar promises_exports = {};\n__export(promises_exports, {\n\tawaitAllCallbacks: () => awaitAllCallbacks,\n\tconsumeCallback: () => consumeCallback\n});\n\n//#endregion\nexport { awaitAllCallbacks, consumeCallback, promises_exports };\n//# sourceMappingURL=promises.js.map"],"names":[],"mappings":";;AAIG,IAAC,mBAAmB,CAAA;AACvB,SAAS,kBAAkB;AAAA,EAC1B,mBAAmB,MAAM;AAAA,EACzB,iBAAiB,MAAM;AACxB,CAAC;","x_google_ignoreList":[0]}
|
package/dist/index.es136.js
CHANGED
|
@@ -1,38 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
function getQueue() {
|
|
13
|
-
if (typeof queue === "undefined") queue = createQueue();
|
|
14
|
-
return queue;
|
|
15
|
-
}
|
|
16
|
-
async function consumeCallback(promiseFn, wait) {
|
|
17
|
-
if (wait === true) {
|
|
18
|
-
const asyncLocalStorageInstance = getGlobalAsyncLocalStorageInstance();
|
|
19
|
-
if (asyncLocalStorageInstance !== void 0) await asyncLocalStorageInstance.run(void 0, async () => promiseFn());
|
|
20
|
-
else await promiseFn();
|
|
21
|
-
} else {
|
|
22
|
-
queue = getQueue();
|
|
23
|
-
queue.add(async () => {
|
|
24
|
-
const asyncLocalStorageInstance = getGlobalAsyncLocalStorageInstance();
|
|
25
|
-
if (asyncLocalStorageInstance !== void 0) await asyncLocalStorageInstance.run(void 0, async () => promiseFn());
|
|
26
|
-
else await promiseFn();
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
async function awaitAllCallbacks() {
|
|
31
|
-
const defaultClient = getDefaultLangChainClientSingleton();
|
|
32
|
-
await Promise.allSettled([typeof queue !== "undefined" ? queue.onIdle() : Promise.resolve(), defaultClient.awaitPendingTraceBatches()]);
|
|
33
|
-
}
|
|
1
|
+
import { getEnvironmentVariable } from "./index.es130.js";
|
|
2
|
+
const isTracingEnabled = (tracingEnabled) => {
|
|
3
|
+
const envVars = [
|
|
4
|
+
"LANGSMITH_TRACING_V2",
|
|
5
|
+
"LANGCHAIN_TRACING_V2",
|
|
6
|
+
"LANGSMITH_TRACING",
|
|
7
|
+
"LANGCHAIN_TRACING"
|
|
8
|
+
];
|
|
9
|
+
return !!envVars.find((envVar) => getEnvironmentVariable(envVar) === "true");
|
|
10
|
+
};
|
|
34
11
|
export {
|
|
35
|
-
|
|
36
|
-
consumeCallback
|
|
12
|
+
isTracingEnabled
|
|
37
13
|
};
|
|
38
14
|
//# sourceMappingURL=index.es136.js.map
|
package/dist/index.es136.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es136.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/
|
|
1
|
+
{"version":3,"file":"index.es136.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/utils/callbacks.js"],"sourcesContent":["import { getEnvironmentVariable } from \"./env.js\";\n\n//#region src/utils/callbacks.ts\nconst isTracingEnabled = (tracingEnabled) => {\n\tif (tracingEnabled !== void 0) return tracingEnabled;\n\tconst envVars = [\n\t\t\"LANGSMITH_TRACING_V2\",\n\t\t\"LANGCHAIN_TRACING_V2\",\n\t\t\"LANGSMITH_TRACING\",\n\t\t\"LANGCHAIN_TRACING\"\n\t];\n\treturn !!envVars.find((envVar) => getEnvironmentVariable(envVar) === \"true\");\n};\n\n//#endregion\nexport { isTracingEnabled };\n//# sourceMappingURL=callbacks.js.map"],"names":[],"mappings":";AAGK,MAAC,mBAAmB,CAAC,mBAAmB;AAE5C,QAAM,UAAU;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACC,SAAO,CAAC,CAAC,QAAQ,KAAK,CAAC,WAAW,uBAAuB,MAAM,MAAM,MAAM;AAC5E;","x_google_ignoreList":[0]}
|
package/dist/index.es137.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { getGlobalAsyncLocalStorageInstance, _CONTEXT_VARIABLES_KEY } from "./index.es108.js";
|
|
2
|
+
import "./index.es113.js";
|
|
3
|
+
function getContextVariable(name) {
|
|
4
|
+
const asyncLocalStorageInstance = getGlobalAsyncLocalStorageInstance();
|
|
5
|
+
if (asyncLocalStorageInstance === void 0) return void 0;
|
|
6
|
+
const runTree = asyncLocalStorageInstance.getStore();
|
|
7
|
+
return runTree?.[_CONTEXT_VARIABLES_KEY]?.[name];
|
|
8
|
+
}
|
|
9
|
+
const LC_CONFIGURE_HOOKS_KEY = /* @__PURE__ */ Symbol("lc:configure_hooks");
|
|
10
|
+
const _getConfigureHooks = () => getContextVariable(LC_CONFIGURE_HOOKS_KEY) || [];
|
|
8
11
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
promises_exports
|
|
12
|
+
_getConfigureHooks,
|
|
13
|
+
getContextVariable
|
|
12
14
|
};
|
|
13
15
|
//# sourceMappingURL=index.es137.js.map
|
package/dist/index.es137.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es137.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/
|
|
1
|
+
{"version":3,"file":"index.es137.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/singletons/async_local_storage/context.js"],"sourcesContent":["import { _CONTEXT_VARIABLES_KEY, getGlobalAsyncLocalStorageInstance } from \"./globals.js\";\nimport { RunTree, isRunTree } from \"langsmith/run_trees\";\n\n//#region src/singletons/async_local_storage/context.ts\n/**\n* Set a context variable. Context variables are scoped to any\n* child runnables called by the current runnable, or globally if set outside\n* of any runnable.\n*\n* @remarks\n* This function is only supported in environments that support AsyncLocalStorage,\n* including Node.js, Deno, and Cloudflare Workers.\n*\n* @example\n* ```ts\n* import { RunnableLambda } from \"@langchain/core/runnables\";\n* import {\n* getContextVariable,\n* setContextVariable\n* } from \"@langchain/core/context\";\n*\n* const nested = RunnableLambda.from(() => {\n* // \"bar\" because it was set by a parent\n* console.log(getContextVariable(\"foo\"));\n*\n* // Override to \"baz\", but only for child runnables\n* setContextVariable(\"foo\", \"baz\");\n*\n* // Now \"baz\", but only for child runnables\n* return getContextVariable(\"foo\");\n* });\n*\n* const runnable = RunnableLambda.from(async () => {\n* // Set a context variable named \"foo\"\n* setContextVariable(\"foo\", \"bar\");\n*\n* const res = await nested.invoke({});\n*\n* // Still \"bar\" since child changes do not affect parents\n* console.log(getContextVariable(\"foo\"));\n*\n* return res;\n* });\n*\n* // undefined, because context variable has not been set yet\n* console.log(getContextVariable(\"foo\"));\n*\n* // Final return value is \"baz\"\n* const result = await runnable.invoke({});\n* ```\n*\n* @param name The name of the context variable.\n* @param value The value to set.\n*/\nfunction setContextVariable(name, value) {\n\tconst asyncLocalStorageInstance = getGlobalAsyncLocalStorageInstance();\n\tif (asyncLocalStorageInstance === void 0) throw new Error(`Internal error: Global shared async local storage instance has not been initialized.`);\n\tconst runTree = asyncLocalStorageInstance.getStore();\n\tconst contextVars = { ...runTree?.[_CONTEXT_VARIABLES_KEY] };\n\tcontextVars[name] = value;\n\tlet newValue = {};\n\tif (isRunTree(runTree)) newValue = new RunTree(runTree);\n\tnewValue[_CONTEXT_VARIABLES_KEY] = contextVars;\n\tasyncLocalStorageInstance.enterWith(newValue);\n}\n/**\n* Get the value of a previously set context variable. Context variables\n* are scoped to any child runnables called by the current runnable,\n* or globally if set outside of any runnable.\n*\n* @remarks\n* This function is only supported in environments that support AsyncLocalStorage,\n* including Node.js, Deno, and Cloudflare Workers.\n*\n* @example\n* ```ts\n* import { RunnableLambda } from \"@langchain/core/runnables\";\n* import {\n* getContextVariable,\n* setContextVariable\n* } from \"@langchain/core/context\";\n*\n* const nested = RunnableLambda.from(() => {\n* // \"bar\" because it was set by a parent\n* console.log(getContextVariable(\"foo\"));\n*\n* // Override to \"baz\", but only for child runnables\n* setContextVariable(\"foo\", \"baz\");\n*\n* // Now \"baz\", but only for child runnables\n* return getContextVariable(\"foo\");\n* });\n*\n* const runnable = RunnableLambda.from(async () => {\n* // Set a context variable named \"foo\"\n* setContextVariable(\"foo\", \"bar\");\n*\n* const res = await nested.invoke({});\n*\n* // Still \"bar\" since child changes do not affect parents\n* console.log(getContextVariable(\"foo\"));\n*\n* return res;\n* });\n*\n* // undefined, because context variable has not been set yet\n* console.log(getContextVariable(\"foo\"));\n*\n* // Final return value is \"baz\"\n* const result = await runnable.invoke({});\n* ```\n*\n* @param name The name of the context variable.\n*/\nfunction getContextVariable(name) {\n\tconst asyncLocalStorageInstance = getGlobalAsyncLocalStorageInstance();\n\tif (asyncLocalStorageInstance === void 0) return void 0;\n\tconst runTree = asyncLocalStorageInstance.getStore();\n\treturn runTree?.[_CONTEXT_VARIABLES_KEY]?.[name];\n}\nconst LC_CONFIGURE_HOOKS_KEY = Symbol(\"lc:configure_hooks\");\nconst _getConfigureHooks = () => getContextVariable(LC_CONFIGURE_HOOKS_KEY) || [];\n/**\n* Register a callback configure hook to automatically add callback handlers to all runs.\n*\n* There are two ways to use this:\n*\n* 1. Using a context variable:\n* - Set `contextVar` to specify the variable name\n* - Use `setContextVariable()` to store your handler instance\n*\n* 2. Using an environment variable:\n* - Set both `envVar` and `handlerClass`\n* - The handler will be instantiated when the env var is set to \"true\".\n*\n* @example\n* ```typescript\n* // Method 1: Using context variable\n* import {\n* registerConfigureHook,\n* setContextVariable\n* } from \"@langchain/core/context\";\n*\n* const tracer = new MyCallbackHandler();\n* registerConfigureHook({\n* contextVar: \"my_tracer\",\n* });\n* setContextVariable(\"my_tracer\", tracer);\n*\n* // ...run code here\n*\n* // Method 2: Using environment variable\n* registerConfigureHook({\n* handlerClass: MyCallbackHandler,\n* envVar: \"MY_TRACER_ENABLED\",\n* });\n* process.env.MY_TRACER_ENABLED = \"true\";\n*\n* // ...run code here\n* ```\n*\n* @param config Configuration object for the hook\n* @param config.contextVar Name of the context variable containing the handler instance\n* @param config.inheritable Whether child runs should inherit this handler\n* @param config.handlerClass Optional callback handler class (required if using envVar)\n* @param config.envVar Optional environment variable name to control handler activation\n*/\nconst registerConfigureHook = (config) => {\n\tif (config.envVar && !config.handlerClass) throw new Error(\"If envVar is set, handlerClass must also be set to a non-None value.\");\n\tsetContextVariable(LC_CONFIGURE_HOOKS_KEY, [..._getConfigureHooks(), config]);\n};\n\n//#endregion\nexport { _getConfigureHooks, getContextVariable, registerConfigureHook, setContextVariable };\n//# sourceMappingURL=context.js.map"],"names":[],"mappings":";;AAkHA,SAAS,mBAAmB,MAAM;AACjC,QAAM,4BAA4B,mCAAkC;AACpE,MAAI,8BAA8B,OAAQ,QAAO;AACjD,QAAM,UAAU,0BAA0B,SAAQ;AAClD,SAAO,UAAU,sBAAsB,IAAI,IAAI;AAChD;AACA,MAAM,yBAAyB,uBAAO,oBAAoB;AACrD,MAAC,qBAAqB,MAAM,mBAAmB,sBAAsB,KAAK,CAAA;","x_google_ignoreList":[0]}
|