langchain 0.0.197-rc.0 → 0.0.197-rc.1

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 (202) hide show
  1. package/dist/agents/executor.cjs +351 -1
  2. package/dist/agents/executor.d.ts +61 -3
  3. package/dist/agents/executor.js +350 -1
  4. package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.d.ts +1 -1
  5. package/dist/base_language/count_tokens.cjs +1 -1
  6. package/dist/base_language/count_tokens.d.ts +1 -1
  7. package/dist/base_language/count_tokens.js +1 -1
  8. package/dist/base_language/index.cjs +1 -1
  9. package/dist/base_language/index.d.ts +1 -1
  10. package/dist/base_language/index.js +1 -1
  11. package/dist/cache/base.cjs +1 -1
  12. package/dist/cache/base.d.ts +1 -1
  13. package/dist/cache/base.js +1 -1
  14. package/dist/cache/index.cjs +1 -1
  15. package/dist/cache/index.d.ts +1 -1
  16. package/dist/cache/index.js +1 -1
  17. package/dist/callbacks/base.cjs +1 -1
  18. package/dist/callbacks/base.d.ts +1 -1
  19. package/dist/callbacks/base.js +1 -1
  20. package/dist/callbacks/handlers/console.cjs +1 -1
  21. package/dist/callbacks/handlers/console.d.ts +1 -1
  22. package/dist/callbacks/handlers/console.js +1 -1
  23. package/dist/callbacks/handlers/initialize.cjs +1 -1
  24. package/dist/callbacks/handlers/initialize.d.ts +1 -1
  25. package/dist/callbacks/handlers/initialize.js +1 -1
  26. package/dist/callbacks/handlers/log_stream.cjs +1 -1
  27. package/dist/callbacks/handlers/log_stream.d.ts +1 -1
  28. package/dist/callbacks/handlers/log_stream.js +1 -1
  29. package/dist/callbacks/handlers/run_collector.cjs +1 -1
  30. package/dist/callbacks/handlers/run_collector.d.ts +1 -1
  31. package/dist/callbacks/handlers/run_collector.js +1 -1
  32. package/dist/callbacks/handlers/tracer.cjs +1 -1
  33. package/dist/callbacks/handlers/tracer.d.ts +1 -1
  34. package/dist/callbacks/handlers/tracer.js +1 -1
  35. package/dist/callbacks/handlers/tracer_langchain.cjs +1 -1
  36. package/dist/callbacks/handlers/tracer_langchain.d.ts +1 -1
  37. package/dist/callbacks/handlers/tracer_langchain.js +1 -1
  38. package/dist/callbacks/handlers/tracer_langchain_v1.cjs +1 -1
  39. package/dist/callbacks/handlers/tracer_langchain_v1.d.ts +1 -1
  40. package/dist/callbacks/handlers/tracer_langchain_v1.js +1 -1
  41. package/dist/callbacks/manager.cjs +1 -1
  42. package/dist/callbacks/manager.d.ts +1 -1
  43. package/dist/callbacks/manager.js +1 -1
  44. package/dist/callbacks/promises.cjs +1 -1
  45. package/dist/callbacks/promises.d.ts +1 -1
  46. package/dist/callbacks/promises.js +1 -1
  47. package/dist/chains/base.cjs +16 -0
  48. package/dist/chains/base.d.ts +2 -0
  49. package/dist/chains/base.js +16 -0
  50. package/dist/chains/openai_functions/structured_output.cjs +1 -1
  51. package/dist/chains/openai_functions/structured_output.d.ts +1 -1
  52. package/dist/chains/openai_functions/structured_output.js +1 -1
  53. package/dist/chains/openai_moderation.cjs +2 -2
  54. package/dist/chains/openai_moderation.d.ts +1 -1
  55. package/dist/chains/openai_moderation.js +1 -1
  56. package/dist/chat_models/base.cjs +1 -1
  57. package/dist/chat_models/base.d.ts +1 -1
  58. package/dist/chat_models/base.js +1 -1
  59. package/dist/chat_models/fireworks.d.ts +2 -2
  60. package/dist/chat_models/iflytek_xinghuo/common.d.ts +1 -1
  61. package/dist/chat_models/minimax.d.ts +2 -2
  62. package/dist/chat_models/openai.cjs +4 -698
  63. package/dist/chat_models/openai.d.ts +4 -137
  64. package/dist/chat_models/openai.js +2 -695
  65. package/dist/document.cjs +1 -1
  66. package/dist/document.d.ts +1 -1
  67. package/dist/document.js +1 -1
  68. package/dist/document_loaders/fs/openai_whisper_audio.cjs +2 -2
  69. package/dist/document_loaders/fs/openai_whisper_audio.d.ts +1 -1
  70. package/dist/document_loaders/fs/openai_whisper_audio.js +1 -1
  71. package/dist/document_loaders/web/azure_blob_storage_file.d.ts +1 -1
  72. package/dist/document_loaders/web/s3.d.ts +1 -1
  73. package/dist/embeddings/base.cjs +1 -1
  74. package/dist/embeddings/base.d.ts +1 -1
  75. package/dist/embeddings/base.js +1 -1
  76. package/dist/embeddings/cache_backed.cjs +1 -1
  77. package/dist/embeddings/cache_backed.js +1 -1
  78. package/dist/embeddings/openai.cjs +2 -240
  79. package/dist/embeddings/openai.d.ts +1 -82
  80. package/dist/embeddings/openai.js +1 -239
  81. package/dist/experimental/openai_assistant/index.cjs +3 -3
  82. package/dist/experimental/openai_assistant/index.d.ts +1 -1
  83. package/dist/experimental/openai_assistant/index.js +1 -1
  84. package/dist/experimental/openai_assistant/schema.d.ts +1 -1
  85. package/dist/experimental/openai_files/index.cjs +2 -2
  86. package/dist/experimental/openai_files/index.d.ts +1 -1
  87. package/dist/experimental/openai_files/index.js +1 -1
  88. package/dist/experimental/plan_and_execute/prompt.d.ts +1 -1
  89. package/dist/llms/base.cjs +1 -1
  90. package/dist/llms/base.d.ts +1 -1
  91. package/dist/llms/base.js +1 -1
  92. package/dist/llms/fireworks.d.ts +2 -2
  93. package/dist/llms/openai-chat.cjs +3 -445
  94. package/dist/llms/openai-chat.d.ts +4 -123
  95. package/dist/llms/openai-chat.js +2 -443
  96. package/dist/llms/openai.cjs +6 -530
  97. package/dist/llms/openai.d.ts +4 -123
  98. package/dist/llms/openai.js +2 -525
  99. package/dist/load/index.cjs +4 -2
  100. package/dist/load/index.d.ts +2 -2
  101. package/dist/load/index.js +4 -2
  102. package/dist/load/serializable.cjs +1 -1
  103. package/dist/load/serializable.d.ts +1 -1
  104. package/dist/load/serializable.js +1 -1
  105. package/dist/memory/base.cjs +2 -2
  106. package/dist/memory/base.d.ts +2 -2
  107. package/dist/memory/base.js +2 -2
  108. package/dist/output_parsers/list.cjs +1 -1
  109. package/dist/output_parsers/list.d.ts +1 -1
  110. package/dist/output_parsers/list.js +1 -1
  111. package/dist/output_parsers/openai_functions.cjs +1 -1
  112. package/dist/output_parsers/openai_functions.d.ts +1 -1
  113. package/dist/output_parsers/openai_functions.js +1 -1
  114. package/dist/output_parsers/structured.d.ts +1 -1
  115. package/dist/prompts/base.cjs +3 -3
  116. package/dist/prompts/base.d.ts +3 -3
  117. package/dist/prompts/base.js +3 -3
  118. package/dist/prompts/chat.cjs +2 -2
  119. package/dist/prompts/chat.d.ts +2 -2
  120. package/dist/prompts/chat.js +2 -2
  121. package/dist/prompts/few_shot.cjs +1 -1
  122. package/dist/prompts/few_shot.d.ts +1 -1
  123. package/dist/prompts/few_shot.js +1 -1
  124. package/dist/prompts/index.cjs +1 -1
  125. package/dist/prompts/index.d.ts +1 -1
  126. package/dist/prompts/index.js +1 -1
  127. package/dist/prompts/pipeline.cjs +1 -1
  128. package/dist/prompts/pipeline.d.ts +1 -1
  129. package/dist/prompts/pipeline.js +1 -1
  130. package/dist/prompts/prompt.cjs +1 -1
  131. package/dist/prompts/prompt.d.ts +1 -1
  132. package/dist/prompts/prompt.js +1 -1
  133. package/dist/prompts/selectors/LengthBasedExampleSelector.cjs +1 -1
  134. package/dist/prompts/selectors/LengthBasedExampleSelector.d.ts +1 -1
  135. package/dist/prompts/selectors/LengthBasedExampleSelector.js +1 -1
  136. package/dist/prompts/selectors/SemanticSimilarityExampleSelector.cjs +1 -1
  137. package/dist/prompts/selectors/SemanticSimilarityExampleSelector.d.ts +1 -1
  138. package/dist/prompts/selectors/SemanticSimilarityExampleSelector.js +1 -1
  139. package/dist/prompts/selectors/conditional.cjs +1 -1
  140. package/dist/prompts/selectors/conditional.d.ts +1 -1
  141. package/dist/prompts/selectors/conditional.js +1 -1
  142. package/dist/prompts/serde.d.ts +1 -1
  143. package/dist/prompts/template.cjs +1 -1
  144. package/dist/prompts/template.d.ts +1 -1
  145. package/dist/prompts/template.js +1 -1
  146. package/dist/runnables/index.cjs +1 -1
  147. package/dist/runnables/index.d.ts +1 -1
  148. package/dist/runnables/index.js +1 -1
  149. package/dist/schema/document.cjs +1 -1
  150. package/dist/schema/document.d.ts +1 -1
  151. package/dist/schema/document.js +1 -1
  152. package/dist/schema/index.cjs +7 -7
  153. package/dist/schema/index.d.ts +11 -11
  154. package/dist/schema/index.js +7 -7
  155. package/dist/schema/output_parser.cjs +1 -1
  156. package/dist/schema/output_parser.d.ts +1 -1
  157. package/dist/schema/output_parser.js +1 -1
  158. package/dist/schema/retriever.cjs +1 -1
  159. package/dist/schema/retriever.d.ts +1 -1
  160. package/dist/schema/retriever.js +1 -1
  161. package/dist/schema/runnable/base.cjs +1 -1
  162. package/dist/schema/runnable/base.d.ts +1 -1
  163. package/dist/schema/runnable/base.js +1 -1
  164. package/dist/schema/runnable/branch.cjs +1 -1
  165. package/dist/schema/runnable/branch.d.ts +1 -1
  166. package/dist/schema/runnable/branch.js +1 -1
  167. package/dist/schema/runnable/config.d.ts +1 -1
  168. package/dist/schema/runnable/index.cjs +1 -1
  169. package/dist/schema/runnable/index.d.ts +1 -1
  170. package/dist/schema/runnable/index.js +1 -1
  171. package/dist/schema/runnable/passthrough.cjs +1 -1
  172. package/dist/schema/runnable/passthrough.d.ts +1 -1
  173. package/dist/schema/runnable/passthrough.js +1 -1
  174. package/dist/schema/runnable/router.cjs +1 -1
  175. package/dist/schema/runnable/router.d.ts +1 -1
  176. package/dist/schema/runnable/router.js +1 -1
  177. package/dist/schema/storage.cjs +1 -1
  178. package/dist/schema/storage.d.ts +1 -1
  179. package/dist/schema/storage.js +1 -1
  180. package/dist/tools/base.cjs +4 -108
  181. package/dist/tools/base.d.ts +1 -72
  182. package/dist/tools/base.js +1 -105
  183. package/dist/tools/bingserpapi.d.ts +1 -1
  184. package/dist/tools/convert_to_openai.cjs +4 -38
  185. package/dist/tools/convert_to_openai.d.ts +1 -11
  186. package/dist/tools/convert_to_openai.js +1 -35
  187. package/dist/tools/searchapi.d.ts +1 -1
  188. package/dist/tools/serpapi.d.ts +1 -1
  189. package/dist/tools/serper.d.ts +1 -1
  190. package/dist/types/openai-types.d.ts +1 -133
  191. package/dist/util/async_caller.cjs +1 -1
  192. package/dist/util/async_caller.d.ts +1 -1
  193. package/dist/util/async_caller.js +1 -1
  194. package/dist/util/openai.cjs +2 -18
  195. package/dist/util/openai.d.ts +1 -1
  196. package/dist/util/openai.js +1 -17
  197. package/dist/util/openapi.d.ts +2 -2
  198. package/dist/util/prompt-layer.d.ts +1 -1
  199. package/package.json +6 -5
  200. package/dist/util/openai-format-fndef.cjs +0 -81
  201. package/dist/util/openai-format-fndef.d.ts +0 -44
  202. package/dist/util/openai-format-fndef.js +0 -77
@@ -1,111 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Tool = exports.StructuredTool = exports.ToolInputParsingException = void 0;
4
- const zod_1 = require("zod");
5
- const manager_js_1 = require("../callbacks/manager.cjs");
6
- const index_js_1 = require("../base_language/index.cjs");
7
- /**
8
- * Custom error class used to handle exceptions related to tool input parsing.
9
- * It extends the built-in `Error` class and adds an optional `output`
10
- * property that can hold the output that caused the exception.
11
- */
12
- class ToolInputParsingException extends Error {
13
- constructor(message, output) {
14
- super(message);
15
- Object.defineProperty(this, "output", {
16
- enumerable: true,
17
- configurable: true,
18
- writable: true,
19
- value: void 0
20
- });
21
- this.output = output;
22
- }
23
- }
24
- exports.ToolInputParsingException = ToolInputParsingException;
25
- /**
26
- * Base class for Tools that accept input of any shape defined by a Zod schema.
27
- */
28
- class StructuredTool extends index_js_1.BaseLangChain {
29
- get lc_namespace() {
30
- return ["langchain", "tools"];
31
- }
32
- constructor(fields) {
33
- super(fields ?? {});
34
- Object.defineProperty(this, "returnDirect", {
35
- enumerable: true,
36
- configurable: true,
37
- writable: true,
38
- value: false
39
- });
40
- }
41
- /**
42
- * Invokes the tool with the provided input and configuration.
43
- * @param input The input for the tool.
44
- * @param config Optional configuration for the tool.
45
- * @returns A Promise that resolves with a string.
46
- */
47
- async invoke(input, config) {
48
- return this.call(input, config);
49
- }
50
- /**
51
- * Calls the tool with the provided argument, configuration, and tags. It
52
- * parses the input according to the schema, handles any errors, and
53
- * manages callbacks.
54
- * @param arg The input argument for the tool.
55
- * @param configArg Optional configuration or callbacks for the tool.
56
- * @param tags Optional tags for the tool.
57
- * @returns A Promise that resolves with a string.
58
- */
59
- async call(arg, configArg,
60
- /** @deprecated */
61
- tags) {
62
- let parsed;
63
- try {
64
- parsed = await this.schema.parseAsync(arg);
65
- }
66
- catch (e) {
67
- throw new ToolInputParsingException(`Received tool input did not match expected schema`, JSON.stringify(arg));
68
- }
69
- const config = (0, manager_js_1.parseCallbackConfigArg)(configArg);
70
- const callbackManager_ = await manager_js_1.CallbackManager.configure(config.callbacks, this.callbacks, config.tags || tags, this.tags, config.metadata, this.metadata, { verbose: this.verbose });
71
- const runManager = await callbackManager_?.handleToolStart(this.toJSON(), typeof parsed === "string" ? parsed : JSON.stringify(parsed), undefined, undefined, undefined, undefined, config.runName);
72
- let result;
73
- try {
74
- result = await this._call(parsed, runManager);
75
- }
76
- catch (e) {
77
- await runManager?.handleToolError(e);
78
- throw e;
79
- }
80
- await runManager?.handleToolEnd(result);
81
- return result;
82
- }
83
- }
84
- exports.StructuredTool = StructuredTool;
85
- /**
86
- * Base class for Tools that accept input as a string.
87
- */
88
- class Tool extends StructuredTool {
89
- constructor(fields) {
90
- super(fields);
91
- Object.defineProperty(this, "schema", {
92
- enumerable: true,
93
- configurable: true,
94
- writable: true,
95
- value: zod_1.z
96
- .object({ input: zod_1.z.string().optional() })
97
- .transform((obj) => obj.input)
98
- });
99
- }
100
- /**
101
- * Calls the tool with the provided argument and callbacks. It handles
102
- * string inputs specifically.
103
- * @param arg The input argument for the tool, which can be a string, undefined, or an input of the tool's schema.
104
- * @param callbacks Optional callbacks for the tool.
105
- * @returns A Promise that resolves with a string.
106
- */
107
- call(arg, callbacks) {
108
- return super.call(typeof arg === "string" || !arg ? { input: arg } : arg, callbacks);
109
- }
110
- }
111
- exports.Tool = Tool;
4
+ var tools_1 = require("@langchain/core/tools");
5
+ Object.defineProperty(exports, "ToolInputParsingException", { enumerable: true, get: function () { return tools_1.ToolInputParsingException; } });
6
+ Object.defineProperty(exports, "StructuredTool", { enumerable: true, get: function () { return tools_1.StructuredTool; } });
7
+ Object.defineProperty(exports, "Tool", { enumerable: true, get: function () { return tools_1.Tool; } });
@@ -1,72 +1 @@
1
- import { z } from "zod";
2
- import { CallbackManagerForToolRun, Callbacks } from "../callbacks/manager.js";
3
- import { BaseLangChain, BaseLangChainParams } from "../base_language/index.js";
4
- import { RunnableConfig } from "../schema/runnable/config.js";
5
- /**
6
- * Parameters for the Tool classes.
7
- */
8
- export interface ToolParams extends BaseLangChainParams {
9
- }
10
- /**
11
- * Custom error class used to handle exceptions related to tool input parsing.
12
- * It extends the built-in `Error` class and adds an optional `output`
13
- * property that can hold the output that caused the exception.
14
- */
15
- export declare class ToolInputParsingException extends Error {
16
- output?: string;
17
- constructor(message: string, output?: string);
18
- }
19
- /**
20
- * Base class for Tools that accept input of any shape defined by a Zod schema.
21
- */
22
- export declare abstract class StructuredTool<T extends z.ZodObject<any, any, any, any> = z.ZodObject<any, any, any, any>> extends BaseLangChain<(z.output<T> extends string ? string : never) | z.input<T>, string> {
23
- abstract schema: T | z.ZodEffects<T>;
24
- get lc_namespace(): string[];
25
- constructor(fields?: ToolParams);
26
- protected abstract _call(arg: z.output<T>, runManager?: CallbackManagerForToolRun): Promise<string>;
27
- /**
28
- * Invokes the tool with the provided input and configuration.
29
- * @param input The input for the tool.
30
- * @param config Optional configuration for the tool.
31
- * @returns A Promise that resolves with a string.
32
- */
33
- invoke(input: (z.output<T> extends string ? string : never) | z.input<T>, config?: RunnableConfig): Promise<string>;
34
- /**
35
- * Calls the tool with the provided argument, configuration, and tags. It
36
- * parses the input according to the schema, handles any errors, and
37
- * manages callbacks.
38
- * @param arg The input argument for the tool.
39
- * @param configArg Optional configuration or callbacks for the tool.
40
- * @param tags Optional tags for the tool.
41
- * @returns A Promise that resolves with a string.
42
- */
43
- call(arg: (z.output<T> extends string ? string : never) | z.input<T>, configArg?: Callbacks | RunnableConfig,
44
- /** @deprecated */
45
- tags?: string[]): Promise<string>;
46
- abstract name: string;
47
- abstract description: string;
48
- returnDirect: boolean;
49
- }
50
- /**
51
- * Base class for Tools that accept input as a string.
52
- */
53
- export declare abstract class Tool extends StructuredTool {
54
- schema: z.ZodEffects<z.ZodObject<{
55
- input: z.ZodOptional<z.ZodString>;
56
- }, "strip", z.ZodTypeAny, {
57
- input?: string | undefined;
58
- }, {
59
- input?: string | undefined;
60
- }>, string | undefined, {
61
- input?: string | undefined;
62
- }>;
63
- constructor(fields?: ToolParams);
64
- /**
65
- * Calls the tool with the provided argument and callbacks. It handles
66
- * string inputs specifically.
67
- * @param arg The input argument for the tool, which can be a string, undefined, or an input of the tool's schema.
68
- * @param callbacks Optional callbacks for the tool.
69
- * @returns A Promise that resolves with a string.
70
- */
71
- call(arg: string | undefined | z.input<this["schema"]>, callbacks?: Callbacks): Promise<string>;
72
- }
1
+ export { type ToolParams, ToolInputParsingException, StructuredTool, Tool, } from "@langchain/core/tools";
@@ -1,105 +1 @@
1
- import { z } from "zod";
2
- import { CallbackManager, parseCallbackConfigArg, } from "../callbacks/manager.js";
3
- import { BaseLangChain } from "../base_language/index.js";
4
- /**
5
- * Custom error class used to handle exceptions related to tool input parsing.
6
- * It extends the built-in `Error` class and adds an optional `output`
7
- * property that can hold the output that caused the exception.
8
- */
9
- export class ToolInputParsingException extends Error {
10
- constructor(message, output) {
11
- super(message);
12
- Object.defineProperty(this, "output", {
13
- enumerable: true,
14
- configurable: true,
15
- writable: true,
16
- value: void 0
17
- });
18
- this.output = output;
19
- }
20
- }
21
- /**
22
- * Base class for Tools that accept input of any shape defined by a Zod schema.
23
- */
24
- export class StructuredTool extends BaseLangChain {
25
- get lc_namespace() {
26
- return ["langchain", "tools"];
27
- }
28
- constructor(fields) {
29
- super(fields ?? {});
30
- Object.defineProperty(this, "returnDirect", {
31
- enumerable: true,
32
- configurable: true,
33
- writable: true,
34
- value: false
35
- });
36
- }
37
- /**
38
- * Invokes the tool with the provided input and configuration.
39
- * @param input The input for the tool.
40
- * @param config Optional configuration for the tool.
41
- * @returns A Promise that resolves with a string.
42
- */
43
- async invoke(input, config) {
44
- return this.call(input, config);
45
- }
46
- /**
47
- * Calls the tool with the provided argument, configuration, and tags. It
48
- * parses the input according to the schema, handles any errors, and
49
- * manages callbacks.
50
- * @param arg The input argument for the tool.
51
- * @param configArg Optional configuration or callbacks for the tool.
52
- * @param tags Optional tags for the tool.
53
- * @returns A Promise that resolves with a string.
54
- */
55
- async call(arg, configArg,
56
- /** @deprecated */
57
- tags) {
58
- let parsed;
59
- try {
60
- parsed = await this.schema.parseAsync(arg);
61
- }
62
- catch (e) {
63
- throw new ToolInputParsingException(`Received tool input did not match expected schema`, JSON.stringify(arg));
64
- }
65
- const config = parseCallbackConfigArg(configArg);
66
- const callbackManager_ = await CallbackManager.configure(config.callbacks, this.callbacks, config.tags || tags, this.tags, config.metadata, this.metadata, { verbose: this.verbose });
67
- const runManager = await callbackManager_?.handleToolStart(this.toJSON(), typeof parsed === "string" ? parsed : JSON.stringify(parsed), undefined, undefined, undefined, undefined, config.runName);
68
- let result;
69
- try {
70
- result = await this._call(parsed, runManager);
71
- }
72
- catch (e) {
73
- await runManager?.handleToolError(e);
74
- throw e;
75
- }
76
- await runManager?.handleToolEnd(result);
77
- return result;
78
- }
79
- }
80
- /**
81
- * Base class for Tools that accept input as a string.
82
- */
83
- export class Tool extends StructuredTool {
84
- constructor(fields) {
85
- super(fields);
86
- Object.defineProperty(this, "schema", {
87
- enumerable: true,
88
- configurable: true,
89
- writable: true,
90
- value: z
91
- .object({ input: z.string().optional() })
92
- .transform((obj) => obj.input)
93
- });
94
- }
95
- /**
96
- * Calls the tool with the provided argument and callbacks. It handles
97
- * string inputs specifically.
98
- * @param arg The input argument for the tool, which can be a string, undefined, or an input of the tool's schema.
99
- * @param callbacks Optional callbacks for the tool.
100
- * @returns A Promise that resolves with a string.
101
- */
102
- call(arg, callbacks) {
103
- return super.call(typeof arg === "string" || !arg ? { input: arg } : arg, callbacks);
104
- }
105
- }
1
+ export { ToolInputParsingException, StructuredTool, Tool, } from "@langchain/core/tools";
@@ -11,7 +11,7 @@ declare class BingSerpAPI extends Tool {
11
11
  /**
12
12
  * Not implemented. Will throw an error if called.
13
13
  */
14
- toJSON(): import("langchain-core/load/serializable").SerializedNotImplemented;
14
+ toJSON(): import("@langchain/core/load/serializable").SerializedNotImplemented;
15
15
  name: string;
16
16
  description: string;
17
17
  key: string;
@@ -1,41 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formatToOpenAIAssistantTool = exports.formatToOpenAITool = exports.formatToOpenAIFunction = void 0;
4
- const zod_to_json_schema_1 = require("zod-to-json-schema");
5
- /**
6
- * Formats a `StructuredTool` instance into a format that is compatible
7
- * with OpenAI's ChatCompletionFunctions. It uses the `zodToJsonSchema`
8
- * function to convert the schema of the `StructuredTool` into a JSON
9
- * schema, which is then used as the parameters for the OpenAI function.
10
- */
11
- function formatToOpenAIFunction(tool) {
12
- return {
13
- name: tool.name,
14
- description: tool.description,
15
- parameters: (0, zod_to_json_schema_1.zodToJsonSchema)(tool.schema),
16
- };
17
- }
18
- exports.formatToOpenAIFunction = formatToOpenAIFunction;
19
- function formatToOpenAITool(tool) {
20
- const schema = (0, zod_to_json_schema_1.zodToJsonSchema)(tool.schema);
21
- return {
22
- type: "function",
23
- function: {
24
- name: tool.name,
25
- description: tool.description,
26
- parameters: schema,
27
- },
28
- };
29
- }
30
- exports.formatToOpenAITool = formatToOpenAITool;
31
- function formatToOpenAIAssistantTool(tool) {
32
- return {
33
- type: "function",
34
- function: {
35
- name: tool.name,
36
- description: tool.description,
37
- parameters: (0, zod_to_json_schema_1.zodToJsonSchema)(tool.schema),
38
- },
39
- };
40
- }
41
- exports.formatToOpenAIAssistantTool = formatToOpenAIAssistantTool;
4
+ var openai_1 = require("@langchain/openai");
5
+ Object.defineProperty(exports, "formatToOpenAIFunction", { enumerable: true, get: function () { return openai_1.formatToOpenAIFunction; } });
6
+ Object.defineProperty(exports, "formatToOpenAITool", { enumerable: true, get: function () { return openai_1.formatToOpenAITool; } });
7
+ Object.defineProperty(exports, "formatToOpenAIAssistantTool", { enumerable: true, get: function () { return openai_1.formatToOpenAIAssistantTool; } });
@@ -1,11 +1 @@
1
- import type { OpenAI as OpenAIClient } from "openai";
2
- import { StructuredTool } from "./base.js";
3
- /**
4
- * Formats a `StructuredTool` instance into a format that is compatible
5
- * with OpenAI's ChatCompletionFunctions. It uses the `zodToJsonSchema`
6
- * function to convert the schema of the `StructuredTool` into a JSON
7
- * schema, which is then used as the parameters for the OpenAI function.
8
- */
9
- export declare function formatToOpenAIFunction(tool: StructuredTool): OpenAIClient.Chat.ChatCompletionCreateParams.Function;
10
- export declare function formatToOpenAITool(tool: StructuredTool): OpenAIClient.Chat.ChatCompletionTool;
11
- export declare function formatToOpenAIAssistantTool(tool: StructuredTool): OpenAIClient.Beta.AssistantCreateParams.AssistantToolsFunction;
1
+ export { formatToOpenAIFunction, formatToOpenAITool, formatToOpenAIAssistantTool, } from "@langchain/openai";
@@ -1,35 +1 @@
1
- import { zodToJsonSchema } from "zod-to-json-schema";
2
- /**
3
- * Formats a `StructuredTool` instance into a format that is compatible
4
- * with OpenAI's ChatCompletionFunctions. It uses the `zodToJsonSchema`
5
- * function to convert the schema of the `StructuredTool` into a JSON
6
- * schema, which is then used as the parameters for the OpenAI function.
7
- */
8
- export function formatToOpenAIFunction(tool) {
9
- return {
10
- name: tool.name,
11
- description: tool.description,
12
- parameters: zodToJsonSchema(tool.schema),
13
- };
14
- }
15
- export function formatToOpenAITool(tool) {
16
- const schema = zodToJsonSchema(tool.schema);
17
- return {
18
- type: "function",
19
- function: {
20
- name: tool.name,
21
- description: tool.description,
22
- parameters: schema,
23
- },
24
- };
25
- }
26
- export function formatToOpenAIAssistantTool(tool) {
27
- return {
28
- type: "function",
29
- function: {
30
- name: tool.name,
31
- description: tool.description,
32
- parameters: zodToJsonSchema(tool.schema),
33
- },
34
- };
35
- }
1
+ export { formatToOpenAIFunction, formatToOpenAITool, formatToOpenAIAssistantTool, } from "@langchain/openai";
@@ -62,7 +62,7 @@ export declare class SearchApi extends Tool {
62
62
  * and will throw an error if called.
63
63
  * @returns Throws an error.
64
64
  */
65
- toJSON(): import("langchain-core/load/serializable").SerializedNotImplemented;
65
+ toJSON(): import("@langchain/core/load/serializable").SerializedNotImplemented;
66
66
  protected apiKey: string;
67
67
  protected params: Partial<SearchApiParameters>;
68
68
  constructor(apiKey?: string | undefined, params?: Partial<SearchApiParameters>);
@@ -281,7 +281,7 @@ type UrlParameters = Record<string, string | number | boolean | undefined | null
281
281
  */
282
282
  export declare class SerpAPI extends Tool {
283
283
  static lc_name(): string;
284
- toJSON(): import("langchain-core/load/serializable").SerializedNotImplemented;
284
+ toJSON(): import("@langchain/core/load/serializable").SerializedNotImplemented;
285
285
  protected key: string;
286
286
  protected params: Partial<SerpAPIParameters>;
287
287
  protected baseUrl: string;
@@ -21,7 +21,7 @@ export declare class Serper extends Tool {
21
21
  * and will throw an error if called.
22
22
  * @returns Throws an error.
23
23
  */
24
- toJSON(): import("langchain-core/load/serializable").SerializedNotImplemented;
24
+ toJSON(): import("@langchain/core/load/serializable").SerializedNotImplemented;
25
25
  protected key: string;
26
26
  protected params: Partial<SerperParameters>;
27
27
  constructor(apiKey?: string | undefined, params?: Partial<SerperParameters>);
@@ -1,135 +1,3 @@
1
- import type { OpenAI as OpenAIClient } from "openai";
2
1
  import { TiktokenModel } from "js-tiktoken/lite";
3
- import { BaseLanguageModelCallOptions } from "../base_language/index.js";
4
2
  export type { TiktokenModel };
5
- export declare interface OpenAIBaseInput {
6
- /** Sampling temperature to use */
7
- temperature: number;
8
- /**
9
- * Maximum number of tokens to generate in the completion. -1 returns as many
10
- * tokens as possible given the prompt and the model's maximum context size.
11
- */
12
- maxTokens?: number;
13
- /** Total probability mass of tokens to consider at each step */
14
- topP: number;
15
- /** Penalizes repeated tokens according to frequency */
16
- frequencyPenalty: number;
17
- /** Penalizes repeated tokens */
18
- presencePenalty: number;
19
- /** Number of completions to generate for each prompt */
20
- n: number;
21
- /** Dictionary used to adjust the probability of specific tokens being generated */
22
- logitBias?: Record<string, number>;
23
- /** Unique string identifier representing your end-user, which can help OpenAI to monitor and detect abuse. */
24
- user?: string;
25
- /** Whether to stream the results or not. Enabling disables tokenUsage reporting */
26
- streaming: boolean;
27
- /** Model name to use */
28
- modelName: string;
29
- /** Holds any additional parameters that are valid to pass to {@link
30
- * https://platform.openai.com/docs/api-reference/completions/create |
31
- * `openai.createCompletion`} that are not explicitly specified on this class.
32
- */
33
- modelKwargs?: Record<string, any>;
34
- /** List of stop words to use when generating */
35
- stop?: string[];
36
- /**
37
- * Timeout to use when making requests to OpenAI.
38
- */
39
- timeout?: number;
40
- /**
41
- * API key to use when making requests to OpenAI. Defaults to the value of
42
- * `OPENAI_API_KEY` environment variable.
43
- */
44
- openAIApiKey?: string;
45
- }
46
- export type OpenAICoreRequestOptions<Req extends object = Record<string, unknown>> = {
47
- path?: string;
48
- query?: Req | undefined;
49
- body?: Req | undefined;
50
- headers?: Record<string, string | null | undefined> | undefined;
51
- maxRetries?: number;
52
- stream?: boolean | undefined;
53
- timeout?: number;
54
- httpAgent?: any;
55
- signal?: AbortSignal | undefined | null;
56
- idempotencyKey?: string;
57
- };
58
- export interface OpenAICallOptions extends BaseLanguageModelCallOptions {
59
- /**
60
- * Additional options to pass to the underlying axios request.
61
- */
62
- options?: OpenAICoreRequestOptions;
63
- }
64
- /**
65
- * Input to OpenAI class.
66
- */
67
- export declare interface OpenAIInput extends OpenAIBaseInput {
68
- /** Generates `bestOf` completions server side and returns the "best" */
69
- bestOf?: number;
70
- /** Batch size to use when passing multiple documents to generate */
71
- batchSize: number;
72
- }
73
- /**
74
- * @deprecated Use "baseURL", "defaultHeaders", and "defaultParams" instead.
75
- */
76
- export interface LegacyOpenAIInput {
77
- /** @deprecated Use baseURL instead */
78
- basePath?: string;
79
- /** @deprecated Use defaultHeaders and defaultQuery instead */
80
- baseOptions?: {
81
- headers?: Record<string, string>;
82
- params?: Record<string, string>;
83
- };
84
- }
85
- export interface OpenAIChatInput extends OpenAIBaseInput {
86
- /** ChatGPT messages to pass as a prefix to the prompt */
87
- prefixMessages?: OpenAIClient.Chat.CreateChatCompletionRequestMessage[];
88
- }
89
- export declare interface AzureOpenAIInput {
90
- /**
91
- * API version to use when making requests to Azure OpenAI.
92
- */
93
- azureOpenAIApiVersion?: string;
94
- /**
95
- * API key to use when making requests to Azure OpenAI.
96
- */
97
- azureOpenAIApiKey?: string;
98
- /**
99
- * Azure OpenAI API instance name to use when making requests to Azure OpenAI.
100
- * this is the name of the instance you created in the Azure portal.
101
- * e.g. "my-openai-instance"
102
- * this will be used in the endpoint URL: https://my-openai-instance.openai.azure.com/openai/deployments/{DeploymentName}/
103
- */
104
- azureOpenAIApiInstanceName?: string;
105
- /**
106
- * Azure OpenAI API deployment name to use for completions when making requests to Azure OpenAI.
107
- * This is the name of the deployment you created in the Azure portal.
108
- * e.g. "my-openai-deployment"
109
- * this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/
110
- */
111
- azureOpenAIApiDeploymentName?: string;
112
- /**
113
- * Azure OpenAI API deployment name to use for embedding when making requests to Azure OpenAI.
114
- * This is the name of the deployment you created in the Azure portal.
115
- * This will fallback to azureOpenAIApiDeploymentName if not provided.
116
- * e.g. "my-openai-deployment"
117
- * this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/
118
- */
119
- azureOpenAIApiEmbeddingsDeploymentName?: string;
120
- /**
121
- * Azure OpenAI API deployment name to use for completions when making requests to Azure OpenAI.
122
- * Completions are only available for gpt-3.5-turbo and text-davinci-003 deployments.
123
- * This is the name of the deployment you created in the Azure portal.
124
- * This will fallback to azureOpenAIApiDeploymentName if not provided.
125
- * e.g. "my-openai-deployment"
126
- * this will be used in the endpoint URL: https://{InstanceName}.openai.azure.com/openai/deployments/my-openai-deployment/
127
- */
128
- azureOpenAIApiCompletionsDeploymentName?: string;
129
- /**
130
- * Custom endpoint for Azure OpenAI API. This is useful in case you have a deployment in another region.
131
- * e.g. setting this value to "https://westeurope.api.cognitive.microsoft.com/openai/deployments"
132
- * will be result in the endpoint URL: https://westeurope.api.cognitive.microsoft.com/openai/deployments/{DeploymentName}/
133
- */
134
- azureOpenAIBasePath?: string;
135
- }
3
+ export type { OpenAIBaseInput, OpenAICoreRequestOptions, OpenAICallOptions, OpenAIInput, LegacyOpenAIInput, OpenAIChatInput, AzureOpenAIInput, } from "@langchain/openai";
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("langchain-core/utils/async_caller"), exports);
17
+ __exportStar(require("@langchain/core/utils/async_caller"), exports);
@@ -1 +1 @@
1
- export * from "langchain-core/utils/async_caller";
1
+ export * from "@langchain/core/utils/async_caller";
@@ -1 +1 @@
1
- export * from "langchain-core/utils/async_caller";
1
+ export * from "@langchain/core/utils/async_caller";
@@ -1,21 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.wrapOpenAIClientError = void 0;
4
- const openai_1 = require("openai");
5
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
- function wrapOpenAIClientError(e) {
7
- let error;
8
- if (e.constructor.name === openai_1.APIConnectionTimeoutError.name) {
9
- error = new Error(e.message);
10
- error.name = "TimeoutError";
11
- }
12
- else if (e.constructor.name === openai_1.APIUserAbortError.name) {
13
- error = new Error(e.message);
14
- error.name = "AbortError";
15
- }
16
- else {
17
- error = e;
18
- }
19
- return error;
20
- }
21
- exports.wrapOpenAIClientError = wrapOpenAIClientError;
4
+ var openai_1 = require("@langchain/openai");
5
+ Object.defineProperty(exports, "wrapOpenAIClientError", { enumerable: true, get: function () { return openai_1.wrapOpenAIClientError; } });
@@ -1 +1 @@
1
- export declare function wrapOpenAIClientError(e: any): any;
1
+ export { wrapOpenAIClientError } from "@langchain/openai";
@@ -1,17 +1 @@
1
- import { APIConnectionTimeoutError, APIUserAbortError } from "openai";
2
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
- export function wrapOpenAIClientError(e) {
4
- let error;
5
- if (e.constructor.name === APIConnectionTimeoutError.name) {
6
- error = new Error(e.message);
7
- error.name = "TimeoutError";
8
- }
9
- else if (e.constructor.name === APIUserAbortError.name) {
10
- error = new Error(e.message);
11
- error.name = "AbortError";
12
- }
13
- else {
14
- error = e;
15
- }
16
- return error;
17
- }
1
+ export { wrapOpenAIClientError } from "@langchain/openai";
@@ -7,7 +7,7 @@ export declare class OpenAPISpec {
7
7
  getParametersStrict(): Record<string, OpenAPIV3.ParameterObject | OpenAPIV3_1.ReferenceObject>;
8
8
  getSchemasStrict(): Record<string, OpenAPIV3_1.SchemaObject>;
9
9
  getRequestBodiesStrict(): Record<string, OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.RequestBodyObject>;
10
- getPathStrict(path: string): Omit<OpenAPIV3.PathItemObject<{}>, "parameters" | "servers"> & {
10
+ getPathStrict(path: string): Omit<OpenAPIV3.PathItemObject<{}>, "servers" | "parameters"> & {
11
11
  servers?: OpenAPIV3_1.ServerObject[] | undefined;
12
12
  parameters?: (OpenAPIV3.ParameterObject | OpenAPIV3_1.ReferenceObject)[] | undefined;
13
13
  } & {
@@ -59,7 +59,7 @@ export declare class OpenAPISpec {
59
59
  deprecated?: boolean | undefined;
60
60
  security?: OpenAPIV3.SecurityRequirementObject[] | undefined;
61
61
  servers?: OpenAPIV3.ServerObject[] | undefined;
62
- }, "callbacks" | "parameters" | "servers" | "responses" | "requestBody"> & {
62
+ }, "callbacks" | "servers" | "parameters" | "responses" | "requestBody"> & {
63
63
  parameters?: (OpenAPIV3.ParameterObject | OpenAPIV3_1.ReferenceObject)[] | undefined;
64
64
  requestBody?: OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.RequestBodyObject | undefined;
65
65
  responses?: OpenAPIV3_1.ResponsesObject | undefined;
@@ -1,3 +1,3 @@
1
- import type { OpenAI as OpenAIClient } from "openai";
1
+ import type { OpenAIClient } from "@langchain/openai";
2
2
  import { AsyncCaller } from "../util/async_caller.js";
3
3
  export declare const promptLayerTrackRequest: (callerFunc: AsyncCaller, functionName: string, kwargs: OpenAIClient.CompletionCreateParams | OpenAIClient.Chat.CompletionCreateParams, plTags: string[] | undefined, requestResponse: any, startTime: number, endTime: number, apiKey: string | undefined) => Promise<any>;