langchain 0.0.195 → 0.0.197-rc.0

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.
Files changed (236) hide show
  1. package/LICENSE +21 -0
  2. package/dist/agents/openai/index.cjs +6 -2
  3. package/dist/agents/openai/index.js +6 -2
  4. package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.d.ts +1 -1
  5. package/dist/base_language/count_tokens.cjs +5 -70
  6. package/dist/base_language/count_tokens.d.ts +1 -10
  7. package/dist/base_language/count_tokens.js +1 -65
  8. package/dist/base_language/index.cjs +6 -196
  9. package/dist/base_language/index.d.ts +1 -111
  10. package/dist/base_language/index.js +1 -191
  11. package/dist/cache/base.cjs +15 -37
  12. package/dist/cache/base.d.ts +1 -20
  13. package/dist/cache/base.js +1 -33
  14. package/dist/cache/index.cjs +2 -46
  15. package/dist/cache/index.d.ts +1 -29
  16. package/dist/cache/index.js +1 -45
  17. package/dist/callbacks/base.cjs +3 -139
  18. package/dist/callbacks/base.d.ts +1 -266
  19. package/dist/callbacks/base.js +1 -126
  20. package/dist/callbacks/handlers/console.cjs +14 -221
  21. package/dist/callbacks/handlers/console.d.ts +1 -117
  22. package/dist/callbacks/handlers/console.js +1 -217
  23. package/dist/callbacks/handlers/initialize.cjs +15 -30
  24. package/dist/callbacks/handlers/initialize.d.ts +1 -16
  25. package/dist/callbacks/handlers/initialize.js +1 -27
  26. package/dist/callbacks/handlers/log_stream.cjs +15 -293
  27. package/dist/callbacks/handlers/log_stream.d.ts +1 -100
  28. package/dist/callbacks/handlers/log_stream.js +1 -289
  29. package/dist/callbacks/handlers/run_collector.cjs +15 -48
  30. package/dist/callbacks/handlers/run_collector.d.ts +1 -26
  31. package/dist/callbacks/handlers/run_collector.js +1 -46
  32. package/dist/callbacks/handlers/tracer.cjs +15 -375
  33. package/dist/callbacks/handlers/tracer.d.ts +1 -70
  34. package/dist/callbacks/handlers/tracer.js +1 -373
  35. package/dist/callbacks/handlers/tracer_langchain.cjs +15 -104
  36. package/dist/callbacks/handlers/tracer_langchain.d.ts +1 -41
  37. package/dist/callbacks/handlers/tracer_langchain.js +1 -102
  38. package/dist/callbacks/handlers/tracer_langchain_v1.cjs +15 -197
  39. package/dist/callbacks/handlers/tracer_langchain_v1.d.ts +1 -57
  40. package/dist/callbacks/handlers/tracer_langchain_v1.js +1 -195
  41. package/dist/callbacks/manager.cjs +15 -676
  42. package/dist/callbacks/manager.d.ts +1 -180
  43. package/dist/callbacks/manager.js +1 -666
  44. package/dist/callbacks/promises.cjs +14 -42
  45. package/dist/callbacks/promises.d.ts +1 -11
  46. package/dist/callbacks/promises.js +1 -37
  47. package/dist/chains/graph_qa/prompts.d.ts +1 -1
  48. package/dist/chains/openai_functions/structured_output.cjs +2 -2
  49. package/dist/chains/openai_functions/structured_output.d.ts +1 -1
  50. package/dist/chains/openai_functions/structured_output.js +1 -1
  51. package/dist/chat_models/anthropic.cjs +15 -348
  52. package/dist/chat_models/anthropic.d.ts +1 -156
  53. package/dist/chat_models/anthropic.js +1 -346
  54. package/dist/chat_models/baiduwenxin.d.ts +1 -1
  55. package/dist/chat_models/base.cjs +15 -296
  56. package/dist/chat_models/base.d.ts +1 -122
  57. package/dist/chat_models/base.js +1 -292
  58. package/dist/chat_models/bedrock/web.cjs +21 -1
  59. package/dist/chat_models/bedrock/web.d.ts +2 -2
  60. package/dist/chat_models/bedrock/web.js +21 -1
  61. package/dist/chat_models/fireworks.d.ts +1 -1
  62. package/dist/document.cjs +2 -24
  63. package/dist/document.d.ts +1 -12
  64. package/dist/document.js +1 -23
  65. package/dist/document_loaders/web/azure_blob_storage_file.d.ts +1 -1
  66. package/dist/document_loaders/web/github.cjs +105 -0
  67. package/dist/document_loaders/web/github.d.ts +26 -0
  68. package/dist/document_loaders/web/github.js +105 -0
  69. package/dist/document_loaders/web/s3.d.ts +1 -1
  70. package/dist/embeddings/base.cjs +15 -22
  71. package/dist/embeddings/base.d.ts +1 -33
  72. package/dist/embeddings/base.js +1 -20
  73. package/dist/embeddings/cache_backed.cjs +2 -2
  74. package/dist/embeddings/cache_backed.js +1 -1
  75. package/dist/evaluation/agents/trajectory.d.ts +1 -1
  76. package/dist/evaluation/criteria/prompt.d.ts +2 -2
  77. package/dist/evaluation/qa/prompt.d.ts +2 -2
  78. package/dist/experimental/hubs/makersuite/googlemakersuitehub.d.ts +1 -1
  79. package/dist/experimental/plan_and_execute/prompt.d.ts +1 -1
  80. package/dist/llms/base.cjs +15 -278
  81. package/dist/llms/base.d.ts +1 -115
  82. package/dist/llms/base.js +1 -275
  83. package/dist/llms/bedrock/web.cjs +21 -1
  84. package/dist/llms/bedrock/web.d.ts +2 -2
  85. package/dist/llms/bedrock/web.js +21 -1
  86. package/dist/llms/fireworks.d.ts +1 -1
  87. package/dist/load/import_map.cjs +2 -1
  88. package/dist/load/import_map.d.ts +1 -0
  89. package/dist/load/import_map.js +1 -0
  90. package/dist/load/index.cjs +7 -148
  91. package/dist/load/index.js +7 -148
  92. package/dist/load/map_keys.cjs +0 -24
  93. package/dist/load/map_keys.d.ts +0 -6
  94. package/dist/load/map_keys.js +1 -17
  95. package/dist/load/serializable.cjs +15 -178
  96. package/dist/load/serializable.d.ts +1 -66
  97. package/dist/load/serializable.js +1 -175
  98. package/dist/memory/base.cjs +17 -92
  99. package/dist/memory/base.d.ts +2 -68
  100. package/dist/memory/base.js +2 -87
  101. package/dist/output_parsers/list.cjs +4 -122
  102. package/dist/output_parsers/list.d.ts +1 -57
  103. package/dist/output_parsers/list.js +1 -119
  104. package/dist/output_parsers/openai_functions.cjs +2 -2
  105. package/dist/output_parsers/openai_functions.d.ts +1 -1
  106. package/dist/output_parsers/openai_functions.js +1 -1
  107. package/dist/output_parsers/regex.d.ts +1 -1
  108. package/dist/output_parsers/structured.d.ts +1 -1
  109. package/dist/prompts/base.cjs +8 -183
  110. package/dist/prompts/base.d.ts +3 -132
  111. package/dist/prompts/base.js +3 -178
  112. package/dist/prompts/chat.cjs +13 -477
  113. package/dist/prompts/chat.d.ts +2 -219
  114. package/dist/prompts/chat.js +2 -466
  115. package/dist/prompts/few_shot.cjs +3 -352
  116. package/dist/prompts/few_shot.d.ts +1 -192
  117. package/dist/prompts/few_shot.js +1 -350
  118. package/dist/prompts/index.cjs +3 -2
  119. package/dist/prompts/index.d.ts +2 -1
  120. package/dist/prompts/index.js +2 -1
  121. package/dist/prompts/pipeline.cjs +2 -141
  122. package/dist/prompts/pipeline.d.ts +1 -98
  123. package/dist/prompts/pipeline.js +1 -140
  124. package/dist/prompts/prompt.cjs +2 -145
  125. package/dist/prompts/prompt.d.ts +1 -92
  126. package/dist/prompts/prompt.js +1 -144
  127. package/dist/prompts/selectors/LengthBasedExampleSelector.cjs +2 -147
  128. package/dist/prompts/selectors/LengthBasedExampleSelector.d.ts +1 -89
  129. package/dist/prompts/selectors/LengthBasedExampleSelector.js +1 -146
  130. package/dist/prompts/selectors/SemanticSimilarityExampleSelector.cjs +15 -137
  131. package/dist/prompts/selectors/SemanticSimilarityExampleSelector.d.ts +1 -91
  132. package/dist/prompts/selectors/SemanticSimilarityExampleSelector.js +1 -135
  133. package/dist/prompts/selectors/conditional.cjs +5 -73
  134. package/dist/prompts/selectors/conditional.d.ts +1 -63
  135. package/dist/prompts/selectors/conditional.js +1 -69
  136. package/dist/prompts/serde.d.ts +1 -43
  137. package/dist/prompts/template.cjs +8 -88
  138. package/dist/prompts/template.d.ts +1 -36
  139. package/dist/prompts/template.js +1 -83
  140. package/dist/{util/@cfworker/json-schema → runnables}/index.cjs +1 -1
  141. package/dist/runnables/index.d.ts +1 -0
  142. package/dist/runnables/index.js +1 -0
  143. package/dist/schema/document.cjs +3 -34
  144. package/dist/schema/document.d.ts +2 -29
  145. package/dist/schema/document.js +2 -32
  146. package/dist/schema/index.cjs +37 -612
  147. package/dist/schema/index.d.ts +11 -311
  148. package/dist/schema/index.js +8 -583
  149. package/dist/schema/output_parser.cjs +15 -309
  150. package/dist/schema/output_parser.d.ts +1 -173
  151. package/dist/schema/output_parser.js +1 -301
  152. package/dist/schema/retriever.cjs +15 -77
  153. package/dist/schema/retriever.d.ts +1 -43
  154. package/dist/schema/retriever.js +1 -75
  155. package/dist/schema/runnable/base.cjs +10 -1072
  156. package/dist/schema/runnable/base.d.ts +1 -356
  157. package/dist/schema/runnable/base.js +1 -1060
  158. package/dist/schema/runnable/branch.cjs +2 -131
  159. package/dist/schema/runnable/branch.d.ts +1 -94
  160. package/dist/schema/runnable/branch.js +1 -130
  161. package/dist/schema/runnable/config.cjs +0 -6
  162. package/dist/schema/runnable/config.d.ts +1 -3
  163. package/dist/schema/runnable/config.js +1 -4
  164. package/dist/schema/runnable/index.cjs +15 -16
  165. package/dist/schema/runnable/index.d.ts +1 -5
  166. package/dist/schema/runnable/index.js +1 -4
  167. package/dist/schema/runnable/passthrough.cjs +3 -113
  168. package/dist/schema/runnable/passthrough.d.ts +1 -72
  169. package/dist/schema/runnable/passthrough.js +1 -111
  170. package/dist/schema/runnable/router.cjs +2 -71
  171. package/dist/schema/runnable/router.d.ts +1 -29
  172. package/dist/schema/runnable/router.js +1 -70
  173. package/dist/schema/storage.cjs +15 -8
  174. package/dist/schema/storage.d.ts +1 -57
  175. package/dist/schema/storage.js +1 -6
  176. package/dist/tools/bingserpapi.d.ts +1 -1
  177. package/dist/tools/searchapi.d.ts +1 -1
  178. package/dist/tools/serpapi.d.ts +1 -1
  179. package/dist/tools/serper.d.ts +1 -1
  180. package/dist/util/async_caller.cjs +14 -128
  181. package/dist/util/async_caller.d.ts +1 -45
  182. package/dist/util/async_caller.js +1 -124
  183. package/dist/vectorstores/momento_vector_index.cjs +39 -0
  184. package/dist/vectorstores/momento_vector_index.d.ts +17 -1
  185. package/dist/vectorstores/momento_vector_index.js +40 -1
  186. package/dist/vectorstores/mongodb_atlas.cjs +22 -2
  187. package/dist/vectorstores/mongodb_atlas.d.ts +13 -0
  188. package/dist/vectorstores/mongodb_atlas.js +22 -2
  189. package/package.json +18 -11
  190. package/runnables.cjs +1 -0
  191. package/runnables.d.ts +1 -0
  192. package/runnables.js +1 -0
  193. package/dist/util/@cfworker/json-schema/index.d.ts +0 -1
  194. package/dist/util/@cfworker/json-schema/index.js +0 -1
  195. package/dist/util/@cfworker/json-schema/src/deep-compare-strict.cjs +0 -43
  196. package/dist/util/@cfworker/json-schema/src/deep-compare-strict.d.ts +0 -1
  197. package/dist/util/@cfworker/json-schema/src/deep-compare-strict.js +0 -39
  198. package/dist/util/@cfworker/json-schema/src/dereference.cjs +0 -169
  199. package/dist/util/@cfworker/json-schema/src/dereference.d.ts +0 -12
  200. package/dist/util/@cfworker/json-schema/src/dereference.js +0 -165
  201. package/dist/util/@cfworker/json-schema/src/format.cjs +0 -139
  202. package/dist/util/@cfworker/json-schema/src/format.d.ts +0 -2
  203. package/dist/util/@cfworker/json-schema/src/format.js +0 -136
  204. package/dist/util/@cfworker/json-schema/src/index.cjs +0 -24
  205. package/dist/util/@cfworker/json-schema/src/index.d.ts +0 -8
  206. package/dist/util/@cfworker/json-schema/src/index.js +0 -8
  207. package/dist/util/@cfworker/json-schema/src/pointer.cjs +0 -11
  208. package/dist/util/@cfworker/json-schema/src/pointer.d.ts +0 -2
  209. package/dist/util/@cfworker/json-schema/src/pointer.js +0 -6
  210. package/dist/util/@cfworker/json-schema/src/types.cjs +0 -2
  211. package/dist/util/@cfworker/json-schema/src/types.d.ts +0 -72
  212. package/dist/util/@cfworker/json-schema/src/types.js +0 -1
  213. package/dist/util/@cfworker/json-schema/src/ucs2-length.cjs +0 -28
  214. package/dist/util/@cfworker/json-schema/src/ucs2-length.d.ts +0 -6
  215. package/dist/util/@cfworker/json-schema/src/ucs2-length.js +0 -24
  216. package/dist/util/@cfworker/json-schema/src/validate.cjs +0 -808
  217. package/dist/util/@cfworker/json-schema/src/validate.d.ts +0 -3
  218. package/dist/util/@cfworker/json-schema/src/validate.js +0 -804
  219. package/dist/util/@cfworker/json-schema/src/validator.cjs +0 -44
  220. package/dist/util/@cfworker/json-schema/src/validator.d.ts +0 -10
  221. package/dist/util/@cfworker/json-schema/src/validator.js +0 -40
  222. package/dist/util/fast-json-patch/index.cjs +0 -49
  223. package/dist/util/fast-json-patch/index.d.ts +0 -22
  224. package/dist/util/fast-json-patch/index.js +0 -16
  225. package/dist/util/fast-json-patch/src/core.cjs +0 -469
  226. package/dist/util/fast-json-patch/src/core.d.ts +0 -111
  227. package/dist/util/fast-json-patch/src/core.js +0 -459
  228. package/dist/util/fast-json-patch/src/duplex.cjs +0 -237
  229. package/dist/util/fast-json-patch/src/duplex.d.ts +0 -23
  230. package/dist/util/fast-json-patch/src/duplex.js +0 -230
  231. package/dist/util/fast-json-patch/src/helpers.cjs +0 -194
  232. package/dist/util/fast-json-patch/src/helpers.d.ts +0 -36
  233. package/dist/util/fast-json-patch/src/helpers.js +0 -181
  234. package/dist/util/js-sha1/hash.cjs +0 -358
  235. package/dist/util/js-sha1/hash.d.ts +0 -1
  236. package/dist/util/js-sha1/hash.js +0 -355
@@ -1,117 +1 @@
1
- import { BaseTracer, Run } from "./tracer.js";
2
- /**
3
- * A tracer that logs all events to the console. It extends from the
4
- * `BaseTracer` class and overrides its methods to provide custom logging
5
- * functionality.
6
- * @example
7
- * ```typescript
8
- *
9
- * const llm = new ChatAnthropic({
10
- * temperature: 0,
11
- * tags: ["example", "callbacks", "constructor"],
12
- * callbacks: [new ConsoleCallbackHandler()],
13
- * });
14
- *
15
- * ```
16
- */
17
- export declare class ConsoleCallbackHandler extends BaseTracer {
18
- name: "console_callback_handler";
19
- /**
20
- * Method used to persist the run. In this case, it simply returns a
21
- * resolved promise as there's no persistence logic.
22
- * @param _run The run to persist.
23
- * @returns A resolved promise.
24
- */
25
- protected persistRun(_run: Run): Promise<void>;
26
- /**
27
- * Method used to get all the parent runs of a given run.
28
- * @param run The run whose parents are to be retrieved.
29
- * @returns An array of parent runs.
30
- */
31
- getParents(run: Run): Run[];
32
- /**
33
- * Method used to get a string representation of the run's lineage, which
34
- * is used in logging.
35
- * @param run The run whose lineage is to be retrieved.
36
- * @returns A string representation of the run's lineage.
37
- */
38
- getBreadcrumbs(run: Run): string;
39
- /**
40
- * Method used to log the start of a chain run.
41
- * @param run The chain run that has started.
42
- * @returns void
43
- */
44
- onChainStart(run: Run): void;
45
- /**
46
- * Method used to log the end of a chain run.
47
- * @param run The chain run that has ended.
48
- * @returns void
49
- */
50
- onChainEnd(run: Run): void;
51
- /**
52
- * Method used to log any errors of a chain run.
53
- * @param run The chain run that has errored.
54
- * @returns void
55
- */
56
- onChainError(run: Run): void;
57
- /**
58
- * Method used to log the start of an LLM run.
59
- * @param run The LLM run that has started.
60
- * @returns void
61
- */
62
- onLLMStart(run: Run): void;
63
- /**
64
- * Method used to log the end of an LLM run.
65
- * @param run The LLM run that has ended.
66
- * @returns void
67
- */
68
- onLLMEnd(run: Run): void;
69
- /**
70
- * Method used to log any errors of an LLM run.
71
- * @param run The LLM run that has errored.
72
- * @returns void
73
- */
74
- onLLMError(run: Run): void;
75
- /**
76
- * Method used to log the start of a tool run.
77
- * @param run The tool run that has started.
78
- * @returns void
79
- */
80
- onToolStart(run: Run): void;
81
- /**
82
- * Method used to log the end of a tool run.
83
- * @param run The tool run that has ended.
84
- * @returns void
85
- */
86
- onToolEnd(run: Run): void;
87
- /**
88
- * Method used to log any errors of a tool run.
89
- * @param run The tool run that has errored.
90
- * @returns void
91
- */
92
- onToolError(run: Run): void;
93
- /**
94
- * Method used to log the start of a retriever run.
95
- * @param run The retriever run that has started.
96
- * @returns void
97
- */
98
- onRetrieverStart(run: Run): void;
99
- /**
100
- * Method used to log the end of a retriever run.
101
- * @param run The retriever run that has ended.
102
- * @returns void
103
- */
104
- onRetrieverEnd(run: Run): void;
105
- /**
106
- * Method used to log any errors of a retriever run.
107
- * @param run The retriever run that has errored.
108
- * @returns void
109
- */
110
- onRetrieverError(run: Run): void;
111
- /**
112
- * Method used to log the action selected by the agent.
113
- * @param run The run in which the agent action occurred.
114
- * @returns void
115
- */
116
- onAgentAction(run: Run): void;
117
- }
1
+ export * from "langchain-core/tracers/console";
@@ -1,217 +1 @@
1
- import styles from "ansi-styles";
2
- import { BaseTracer } from "./tracer.js";
3
- function wrap(style, text) {
4
- return `${style.open}${text}${style.close}`;
5
- }
6
- function tryJsonStringify(obj, fallback) {
7
- try {
8
- return JSON.stringify(obj, null, 2);
9
- }
10
- catch (err) {
11
- return fallback;
12
- }
13
- }
14
- function elapsed(run) {
15
- if (!run.end_time)
16
- return "";
17
- const elapsed = run.end_time - run.start_time;
18
- if (elapsed < 1000) {
19
- return `${elapsed}ms`;
20
- }
21
- return `${(elapsed / 1000).toFixed(2)}s`;
22
- }
23
- const { color } = styles;
24
- /**
25
- * A tracer that logs all events to the console. It extends from the
26
- * `BaseTracer` class and overrides its methods to provide custom logging
27
- * functionality.
28
- * @example
29
- * ```typescript
30
- *
31
- * const llm = new ChatAnthropic({
32
- * temperature: 0,
33
- * tags: ["example", "callbacks", "constructor"],
34
- * callbacks: [new ConsoleCallbackHandler()],
35
- * });
36
- *
37
- * ```
38
- */
39
- export class ConsoleCallbackHandler extends BaseTracer {
40
- constructor() {
41
- super(...arguments);
42
- Object.defineProperty(this, "name", {
43
- enumerable: true,
44
- configurable: true,
45
- writable: true,
46
- value: "console_callback_handler"
47
- });
48
- }
49
- /**
50
- * Method used to persist the run. In this case, it simply returns a
51
- * resolved promise as there's no persistence logic.
52
- * @param _run The run to persist.
53
- * @returns A resolved promise.
54
- */
55
- persistRun(_run) {
56
- return Promise.resolve();
57
- }
58
- // utility methods
59
- /**
60
- * Method used to get all the parent runs of a given run.
61
- * @param run The run whose parents are to be retrieved.
62
- * @returns An array of parent runs.
63
- */
64
- getParents(run) {
65
- const parents = [];
66
- let currentRun = run;
67
- while (currentRun.parent_run_id) {
68
- const parent = this.runMap.get(currentRun.parent_run_id);
69
- if (parent) {
70
- parents.push(parent);
71
- currentRun = parent;
72
- }
73
- else {
74
- break;
75
- }
76
- }
77
- return parents;
78
- }
79
- /**
80
- * Method used to get a string representation of the run's lineage, which
81
- * is used in logging.
82
- * @param run The run whose lineage is to be retrieved.
83
- * @returns A string representation of the run's lineage.
84
- */
85
- getBreadcrumbs(run) {
86
- const parents = this.getParents(run).reverse();
87
- const string = [...parents, run]
88
- .map((parent, i, arr) => {
89
- const name = `${parent.execution_order}:${parent.run_type}:${parent.name}`;
90
- return i === arr.length - 1 ? wrap(styles.bold, name) : name;
91
- })
92
- .join(" > ");
93
- return wrap(color.grey, string);
94
- }
95
- // logging methods
96
- /**
97
- * Method used to log the start of a chain run.
98
- * @param run The chain run that has started.
99
- * @returns void
100
- */
101
- onChainStart(run) {
102
- const crumbs = this.getBreadcrumbs(run);
103
- console.log(`${wrap(color.green, "[chain/start]")} [${crumbs}] Entering Chain run with input: ${tryJsonStringify(run.inputs, "[inputs]")}`);
104
- }
105
- /**
106
- * Method used to log the end of a chain run.
107
- * @param run The chain run that has ended.
108
- * @returns void
109
- */
110
- onChainEnd(run) {
111
- const crumbs = this.getBreadcrumbs(run);
112
- console.log(`${wrap(color.cyan, "[chain/end]")} [${crumbs}] [${elapsed(run)}] Exiting Chain run with output: ${tryJsonStringify(run.outputs, "[outputs]")}`);
113
- }
114
- /**
115
- * Method used to log any errors of a chain run.
116
- * @param run The chain run that has errored.
117
- * @returns void
118
- */
119
- onChainError(run) {
120
- const crumbs = this.getBreadcrumbs(run);
121
- console.log(`${wrap(color.red, "[chain/error]")} [${crumbs}] [${elapsed(run)}] Chain run errored with error: ${tryJsonStringify(run.error, "[error]")}`);
122
- }
123
- /**
124
- * Method used to log the start of an LLM run.
125
- * @param run The LLM run that has started.
126
- * @returns void
127
- */
128
- onLLMStart(run) {
129
- const crumbs = this.getBreadcrumbs(run);
130
- const inputs = "prompts" in run.inputs
131
- ? { prompts: run.inputs.prompts.map((p) => p.trim()) }
132
- : run.inputs;
133
- console.log(`${wrap(color.green, "[llm/start]")} [${crumbs}] Entering LLM run with input: ${tryJsonStringify(inputs, "[inputs]")}`);
134
- }
135
- /**
136
- * Method used to log the end of an LLM run.
137
- * @param run The LLM run that has ended.
138
- * @returns void
139
- */
140
- onLLMEnd(run) {
141
- const crumbs = this.getBreadcrumbs(run);
142
- console.log(`${wrap(color.cyan, "[llm/end]")} [${crumbs}] [${elapsed(run)}] Exiting LLM run with output: ${tryJsonStringify(run.outputs, "[response]")}`);
143
- }
144
- /**
145
- * Method used to log any errors of an LLM run.
146
- * @param run The LLM run that has errored.
147
- * @returns void
148
- */
149
- onLLMError(run) {
150
- const crumbs = this.getBreadcrumbs(run);
151
- console.log(`${wrap(color.red, "[llm/error]")} [${crumbs}] [${elapsed(run)}] LLM run errored with error: ${tryJsonStringify(run.error, "[error]")}`);
152
- }
153
- /**
154
- * Method used to log the start of a tool run.
155
- * @param run The tool run that has started.
156
- * @returns void
157
- */
158
- onToolStart(run) {
159
- const crumbs = this.getBreadcrumbs(run);
160
- console.log(`${wrap(color.green, "[tool/start]")} [${crumbs}] Entering Tool run with input: "${run.inputs.input?.trim()}"`);
161
- }
162
- /**
163
- * Method used to log the end of a tool run.
164
- * @param run The tool run that has ended.
165
- * @returns void
166
- */
167
- onToolEnd(run) {
168
- const crumbs = this.getBreadcrumbs(run);
169
- console.log(`${wrap(color.cyan, "[tool/end]")} [${crumbs}] [${elapsed(run)}] Exiting Tool run with output: "${run.outputs?.output?.trim()}"`);
170
- }
171
- /**
172
- * Method used to log any errors of a tool run.
173
- * @param run The tool run that has errored.
174
- * @returns void
175
- */
176
- onToolError(run) {
177
- const crumbs = this.getBreadcrumbs(run);
178
- console.log(`${wrap(color.red, "[tool/error]")} [${crumbs}] [${elapsed(run)}] Tool run errored with error: ${tryJsonStringify(run.error, "[error]")}`);
179
- }
180
- /**
181
- * Method used to log the start of a retriever run.
182
- * @param run The retriever run that has started.
183
- * @returns void
184
- */
185
- onRetrieverStart(run) {
186
- const crumbs = this.getBreadcrumbs(run);
187
- console.log(`${wrap(color.green, "[retriever/start]")} [${crumbs}] Entering Retriever run with input: ${tryJsonStringify(run.inputs, "[inputs]")}`);
188
- }
189
- /**
190
- * Method used to log the end of a retriever run.
191
- * @param run The retriever run that has ended.
192
- * @returns void
193
- */
194
- onRetrieverEnd(run) {
195
- const crumbs = this.getBreadcrumbs(run);
196
- console.log(`${wrap(color.cyan, "[retriever/end]")} [${crumbs}] [${elapsed(run)}] Exiting Retriever run with output: ${tryJsonStringify(run.outputs, "[outputs]")}`);
197
- }
198
- /**
199
- * Method used to log any errors of a retriever run.
200
- * @param run The retriever run that has errored.
201
- * @returns void
202
- */
203
- onRetrieverError(run) {
204
- const crumbs = this.getBreadcrumbs(run);
205
- console.log(`${wrap(color.red, "[retriever/error]")} [${crumbs}] [${elapsed(run)}] Retriever run errored with error: ${tryJsonStringify(run.error, "[error]")}`);
206
- }
207
- /**
208
- * Method used to log the action selected by the agent.
209
- * @param run The run in which the agent action occurred.
210
- * @returns void
211
- */
212
- onAgentAction(run) {
213
- const agentRun = run;
214
- const crumbs = this.getBreadcrumbs(run);
215
- console.log(`${wrap(color.blue, "[agent/action]")} [${crumbs}] Agent selected action: ${tryJsonStringify(agentRun.actions[agentRun.actions.length - 1], "[action]")}`);
216
- }
217
- }
1
+ export * from "langchain-core/tracers/console";
@@ -1,32 +1,17 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTracingV2CallbackHandler = exports.getTracingCallbackHandler = void 0;
4
- const tracer_langchain_js_1 = require("./tracer_langchain.cjs");
5
- const tracer_langchain_v1_js_1 = require("./tracer_langchain_v1.cjs");
6
- /**
7
- * Function that returns an instance of `LangChainTracerV1`. If a session
8
- * is provided, it loads that session into the tracer; otherwise, it loads
9
- * a default session.
10
- * @param session Optional session to load into the tracer.
11
- * @returns An instance of `LangChainTracerV1`.
12
- */
13
- async function getTracingCallbackHandler(session) {
14
- const tracer = new tracer_langchain_v1_js_1.LangChainTracerV1();
15
- if (session) {
16
- await tracer.loadSession(session);
17
- }
18
- else {
19
- await tracer.loadDefaultSession();
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
20
7
  }
21
- return tracer;
22
- }
23
- exports.getTracingCallbackHandler = getTracingCallbackHandler;
24
- /**
25
- * Function that returns an instance of `LangChainTracer`. It does not
26
- * load any session data.
27
- * @returns An instance of `LangChainTracer`.
28
- */
29
- async function getTracingV2CallbackHandler() {
30
- return new tracer_langchain_js_1.LangChainTracer();
31
- }
32
- exports.getTracingV2CallbackHandler = getTracingV2CallbackHandler;
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("langchain-core/tracers/initialize"), exports);
@@ -1,16 +1 @@
1
- import { LangChainTracer } from "./tracer_langchain.js";
2
- import { LangChainTracerV1 } from "./tracer_langchain_v1.js";
3
- /**
4
- * Function that returns an instance of `LangChainTracerV1`. If a session
5
- * is provided, it loads that session into the tracer; otherwise, it loads
6
- * a default session.
7
- * @param session Optional session to load into the tracer.
8
- * @returns An instance of `LangChainTracerV1`.
9
- */
10
- export declare function getTracingCallbackHandler(session?: string): Promise<LangChainTracerV1>;
11
- /**
12
- * Function that returns an instance of `LangChainTracer`. It does not
13
- * load any session data.
14
- * @returns An instance of `LangChainTracer`.
15
- */
16
- export declare function getTracingV2CallbackHandler(): Promise<LangChainTracer>;
1
+ export * from "langchain-core/tracers/initialize";
@@ -1,27 +1 @@
1
- import { LangChainTracer } from "./tracer_langchain.js";
2
- import { LangChainTracerV1 } from "./tracer_langchain_v1.js";
3
- /**
4
- * Function that returns an instance of `LangChainTracerV1`. If a session
5
- * is provided, it loads that session into the tracer; otherwise, it loads
6
- * a default session.
7
- * @param session Optional session to load into the tracer.
8
- * @returns An instance of `LangChainTracerV1`.
9
- */
10
- export async function getTracingCallbackHandler(session) {
11
- const tracer = new LangChainTracerV1();
12
- if (session) {
13
- await tracer.loadSession(session);
14
- }
15
- else {
16
- await tracer.loadDefaultSession();
17
- }
18
- return tracer;
19
- }
20
- /**
21
- * Function that returns an instance of `LangChainTracer`. It does not
22
- * load any session data.
23
- * @returns An instance of `LangChainTracer`.
24
- */
25
- export async function getTracingV2CallbackHandler() {
26
- return new LangChainTracer();
27
- }
1
+ export * from "langchain-core/tracers/initialize";