@langchain/openai 1.2.13 → 1.3.0-dev-1773709997654

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 (247) hide show
  1. package/dist/azure/chat_models/common.cjs +2 -3
  2. package/dist/azure/chat_models/common.cjs.map +1 -1
  3. package/dist/azure/chat_models/common.d.ts +0 -1
  4. package/dist/azure/chat_models/common.d.ts.map +1 -1
  5. package/dist/azure/chat_models/common.js +1 -2
  6. package/dist/azure/chat_models/common.js.map +1 -1
  7. package/dist/azure/chat_models/completions.cjs +3 -4
  8. package/dist/azure/chat_models/completions.cjs.map +1 -1
  9. package/dist/azure/chat_models/completions.js +1 -2
  10. package/dist/azure/chat_models/completions.js.map +1 -1
  11. package/dist/azure/chat_models/index.cjs +5 -6
  12. package/dist/azure/chat_models/index.cjs.map +1 -1
  13. package/dist/azure/chat_models/index.js +1 -2
  14. package/dist/azure/chat_models/index.js.map +1 -1
  15. package/dist/azure/chat_models/responses.cjs +3 -4
  16. package/dist/azure/chat_models/responses.cjs.map +1 -1
  17. package/dist/azure/chat_models/responses.js +1 -2
  18. package/dist/azure/chat_models/responses.js.map +1 -1
  19. package/dist/azure/embeddings.cjs +4 -5
  20. package/dist/azure/embeddings.cjs.map +1 -1
  21. package/dist/azure/embeddings.d.cts +2 -2
  22. package/dist/azure/embeddings.d.cts.map +1 -1
  23. package/dist/azure/embeddings.d.ts +2 -2
  24. package/dist/azure/embeddings.d.ts.map +1 -1
  25. package/dist/azure/embeddings.js +1 -2
  26. package/dist/azure/embeddings.js.map +1 -1
  27. package/dist/azure/llms.cjs +3 -4
  28. package/dist/azure/llms.cjs.map +1 -1
  29. package/dist/azure/llms.js +1 -2
  30. package/dist/azure/llms.js.map +1 -1
  31. package/dist/chat_models/base.cjs +15 -10
  32. package/dist/chat_models/base.cjs.map +1 -1
  33. package/dist/chat_models/base.d.cts +20 -20
  34. package/dist/chat_models/base.d.cts.map +1 -1
  35. package/dist/chat_models/base.d.ts +20 -20
  36. package/dist/chat_models/base.d.ts.map +1 -1
  37. package/dist/chat_models/base.js +11 -6
  38. package/dist/chat_models/base.js.map +1 -1
  39. package/dist/chat_models/completions.cjs +6 -7
  40. package/dist/chat_models/completions.cjs.map +1 -1
  41. package/dist/chat_models/completions.d.cts +6 -6
  42. package/dist/chat_models/completions.d.cts.map +1 -1
  43. package/dist/chat_models/completions.d.ts +6 -6
  44. package/dist/chat_models/completions.d.ts.map +1 -1
  45. package/dist/chat_models/completions.js +1 -2
  46. package/dist/chat_models/completions.js.map +1 -1
  47. package/dist/chat_models/index.cjs +6 -7
  48. package/dist/chat_models/index.cjs.map +1 -1
  49. package/dist/chat_models/index.js +1 -2
  50. package/dist/chat_models/index.js.map +1 -1
  51. package/dist/chat_models/profiles.cjs +1 -2
  52. package/dist/chat_models/profiles.cjs.map +1 -1
  53. package/dist/chat_models/profiles.js +1 -1
  54. package/dist/chat_models/responses.cjs +17 -14
  55. package/dist/chat_models/responses.cjs.map +1 -1
  56. package/dist/chat_models/responses.d.cts +8 -8
  57. package/dist/chat_models/responses.d.cts.map +1 -1
  58. package/dist/chat_models/responses.d.ts +8 -8
  59. package/dist/chat_models/responses.d.ts.map +1 -1
  60. package/dist/chat_models/responses.js +13 -10
  61. package/dist/chat_models/responses.js.map +1 -1
  62. package/dist/converters/completions.cjs +3 -4
  63. package/dist/converters/completions.cjs.map +1 -1
  64. package/dist/converters/completions.d.cts +8 -8
  65. package/dist/converters/completions.d.cts.map +1 -1
  66. package/dist/converters/completions.d.ts +8 -8
  67. package/dist/converters/completions.d.ts.map +1 -1
  68. package/dist/converters/completions.js +1 -2
  69. package/dist/converters/completions.js.map +1 -1
  70. package/dist/converters/index.cjs +2 -2
  71. package/dist/converters/index.js +3 -4
  72. package/dist/converters/responses.cjs +15 -11
  73. package/dist/converters/responses.cjs.map +1 -1
  74. package/dist/converters/responses.d.cts +8 -8
  75. package/dist/converters/responses.d.cts.map +1 -1
  76. package/dist/converters/responses.d.ts +8 -8
  77. package/dist/converters/responses.d.ts.map +1 -1
  78. package/dist/converters/responses.js +12 -8
  79. package/dist/converters/responses.js.map +1 -1
  80. package/dist/embeddings.cjs +3 -4
  81. package/dist/embeddings.cjs.map +1 -1
  82. package/dist/embeddings.d.cts +4 -4
  83. package/dist/embeddings.d.cts.map +1 -1
  84. package/dist/embeddings.d.ts +4 -4
  85. package/dist/embeddings.d.ts.map +1 -1
  86. package/dist/embeddings.js +3 -4
  87. package/dist/embeddings.js.map +1 -1
  88. package/dist/index.cjs +33 -34
  89. package/dist/index.d.cts +2 -1
  90. package/dist/index.d.ts +2 -2
  91. package/dist/index.js +1 -2
  92. package/dist/llms.cjs +4 -5
  93. package/dist/llms.cjs.map +1 -1
  94. package/dist/llms.d.cts +7 -7
  95. package/dist/llms.d.cts.map +1 -1
  96. package/dist/llms.d.ts +7 -7
  97. package/dist/llms.d.ts.map +1 -1
  98. package/dist/llms.js +4 -5
  99. package/dist/llms.js.map +1 -1
  100. package/dist/tools/applyPatch.cjs +1 -2
  101. package/dist/tools/applyPatch.cjs.map +1 -1
  102. package/dist/tools/applyPatch.d.cts +6 -6
  103. package/dist/tools/applyPatch.d.cts.map +1 -1
  104. package/dist/tools/applyPatch.d.ts +6 -6
  105. package/dist/tools/applyPatch.d.ts.map +1 -1
  106. package/dist/tools/applyPatch.js +1 -2
  107. package/dist/tools/applyPatch.js.map +1 -1
  108. package/dist/tools/codeInterpreter.cjs +1 -2
  109. package/dist/tools/codeInterpreter.cjs.map +1 -1
  110. package/dist/tools/codeInterpreter.d.cts +2 -2
  111. package/dist/tools/codeInterpreter.d.cts.map +1 -1
  112. package/dist/tools/codeInterpreter.d.ts +2 -2
  113. package/dist/tools/codeInterpreter.d.ts.map +1 -1
  114. package/dist/tools/codeInterpreter.js +1 -1
  115. package/dist/tools/computerUse.cjs +1 -2
  116. package/dist/tools/computerUse.cjs.map +1 -1
  117. package/dist/tools/computerUse.d.cts +12 -12
  118. package/dist/tools/computerUse.d.cts.map +1 -1
  119. package/dist/tools/computerUse.d.ts +12 -12
  120. package/dist/tools/computerUse.d.ts.map +1 -1
  121. package/dist/tools/computerUse.js +1 -2
  122. package/dist/tools/computerUse.js.map +1 -1
  123. package/dist/tools/custom.cjs +1 -2
  124. package/dist/tools/custom.cjs.map +1 -1
  125. package/dist/tools/custom.d.cts +2 -2
  126. package/dist/tools/custom.d.cts.map +1 -1
  127. package/dist/tools/custom.d.ts +2 -2
  128. package/dist/tools/custom.d.ts.map +1 -1
  129. package/dist/tools/custom.js +1 -2
  130. package/dist/tools/custom.js.map +1 -1
  131. package/dist/tools/dalle.cjs +1 -2
  132. package/dist/tools/dalle.cjs.map +1 -1
  133. package/dist/tools/dalle.d.cts +3 -3
  134. package/dist/tools/dalle.d.cts.map +1 -1
  135. package/dist/tools/dalle.d.ts +3 -3
  136. package/dist/tools/dalle.d.ts.map +1 -1
  137. package/dist/tools/dalle.js +3 -4
  138. package/dist/tools/dalle.js.map +1 -1
  139. package/dist/tools/fileSearch.cjs +1 -2
  140. package/dist/tools/fileSearch.cjs.map +1 -1
  141. package/dist/tools/fileSearch.d.cts +2 -2
  142. package/dist/tools/fileSearch.d.cts.map +1 -1
  143. package/dist/tools/fileSearch.d.ts +2 -2
  144. package/dist/tools/fileSearch.d.ts.map +1 -1
  145. package/dist/tools/fileSearch.js +1 -1
  146. package/dist/tools/fileSearch.js.map +1 -1
  147. package/dist/tools/imageGeneration.cjs +1 -2
  148. package/dist/tools/imageGeneration.cjs.map +1 -1
  149. package/dist/tools/imageGeneration.d.cts +2 -2
  150. package/dist/tools/imageGeneration.d.cts.map +1 -1
  151. package/dist/tools/imageGeneration.d.ts +2 -2
  152. package/dist/tools/imageGeneration.d.ts.map +1 -1
  153. package/dist/tools/imageGeneration.js +1 -1
  154. package/dist/tools/imageGeneration.js.map +1 -1
  155. package/dist/tools/index.cjs +14 -13
  156. package/dist/tools/index.cjs.map +1 -1
  157. package/dist/tools/index.d.cts +2 -0
  158. package/dist/tools/index.d.cts.map +1 -1
  159. package/dist/tools/index.d.ts +2 -0
  160. package/dist/tools/index.d.ts.map +1 -1
  161. package/dist/tools/index.js +5 -4
  162. package/dist/tools/index.js.map +1 -1
  163. package/dist/tools/localShell.cjs +1 -2
  164. package/dist/tools/localShell.cjs.map +1 -1
  165. package/dist/tools/localShell.d.cts +4 -4
  166. package/dist/tools/localShell.d.cts.map +1 -1
  167. package/dist/tools/localShell.d.ts +4 -4
  168. package/dist/tools/localShell.d.ts.map +1 -1
  169. package/dist/tools/localShell.js +1 -2
  170. package/dist/tools/localShell.js.map +1 -1
  171. package/dist/tools/mcp.cjs +1 -2
  172. package/dist/tools/mcp.cjs.map +1 -1
  173. package/dist/tools/mcp.d.cts +2 -2
  174. package/dist/tools/mcp.d.cts.map +1 -1
  175. package/dist/tools/mcp.d.ts +2 -2
  176. package/dist/tools/mcp.d.ts.map +1 -1
  177. package/dist/tools/mcp.js +1 -1
  178. package/dist/tools/mcp.js.map +1 -1
  179. package/dist/tools/shell.cjs +1 -2
  180. package/dist/tools/shell.cjs.map +1 -1
  181. package/dist/tools/shell.d.cts +5 -5
  182. package/dist/tools/shell.d.cts.map +1 -1
  183. package/dist/tools/shell.d.ts +5 -5
  184. package/dist/tools/shell.d.ts.map +1 -1
  185. package/dist/tools/shell.js +1 -2
  186. package/dist/tools/shell.js.map +1 -1
  187. package/dist/tools/toolSearch.cjs +67 -0
  188. package/dist/tools/toolSearch.cjs.map +1 -0
  189. package/dist/tools/toolSearch.d.cts +79 -0
  190. package/dist/tools/toolSearch.d.cts.map +1 -0
  191. package/dist/tools/toolSearch.d.ts +79 -0
  192. package/dist/tools/toolSearch.d.ts.map +1 -0
  193. package/dist/tools/toolSearch.js +67 -0
  194. package/dist/tools/toolSearch.js.map +1 -0
  195. package/dist/tools/webSearch.cjs +1 -2
  196. package/dist/tools/webSearch.cjs.map +1 -1
  197. package/dist/tools/webSearch.d.cts +2 -2
  198. package/dist/tools/webSearch.d.cts.map +1 -1
  199. package/dist/tools/webSearch.d.ts +2 -2
  200. package/dist/tools/webSearch.d.ts.map +1 -1
  201. package/dist/tools/webSearch.js +1 -1
  202. package/dist/tools/webSearch.js.map +1 -1
  203. package/dist/types.d.cts +10 -10
  204. package/dist/types.d.cts.map +1 -1
  205. package/dist/types.d.ts +10 -10
  206. package/dist/types.d.ts.map +1 -1
  207. package/dist/utils/azure.cjs +2 -3
  208. package/dist/utils/azure.cjs.map +1 -1
  209. package/dist/utils/azure.js +1 -2
  210. package/dist/utils/azure.js.map +1 -1
  211. package/dist/utils/client.cjs +2 -3
  212. package/dist/utils/client.cjs.map +1 -1
  213. package/dist/utils/client.js +1 -2
  214. package/dist/utils/client.js.map +1 -1
  215. package/dist/utils/errors.cjs +1 -2
  216. package/dist/utils/errors.cjs.map +1 -1
  217. package/dist/utils/errors.js +1 -1
  218. package/dist/utils/errors.js.map +1 -1
  219. package/dist/utils/misc.cjs +1 -2
  220. package/dist/utils/misc.cjs.map +1 -1
  221. package/dist/utils/misc.d.cts +2 -2
  222. package/dist/utils/misc.d.cts.map +1 -1
  223. package/dist/utils/misc.d.ts +2 -2
  224. package/dist/utils/misc.d.ts.map +1 -1
  225. package/dist/utils/misc.js +1 -2
  226. package/dist/utils/misc.js.map +1 -1
  227. package/dist/utils/output.cjs +1 -2
  228. package/dist/utils/output.cjs.map +1 -1
  229. package/dist/utils/output.js +1 -2
  230. package/dist/utils/output.js.map +1 -1
  231. package/dist/utils/prompts.cjs +2 -3
  232. package/dist/utils/prompts.cjs.map +1 -1
  233. package/dist/utils/prompts.d.cts +2 -2
  234. package/dist/utils/prompts.d.cts.map +1 -1
  235. package/dist/utils/prompts.d.ts +2 -2
  236. package/dist/utils/prompts.d.ts.map +1 -1
  237. package/dist/utils/prompts.js +1 -2
  238. package/dist/utils/prompts.js.map +1 -1
  239. package/dist/utils/tools.cjs +3 -4
  240. package/dist/utils/tools.cjs.map +1 -1
  241. package/dist/utils/tools.d.cts +5 -5
  242. package/dist/utils/tools.d.cts.map +1 -1
  243. package/dist/utils/tools.d.ts +5 -6
  244. package/dist/utils/tools.d.ts.map +1 -1
  245. package/dist/utils/tools.js +3 -4
  246. package/dist/utils/tools.js.map +1 -1
  247. package/package.json +4 -4
@@ -1,9 +1,9 @@
1
- import OpenAI from "openai";
1
+ import OpenAI$1 from "openai";
2
2
  import { DynamicTool, ToolRunnableConfig } from "@langchain/core/tools";
3
3
  import { RunnableFunc } from "@langchain/core/runnables";
4
4
 
5
5
  //#region src/tools/custom.d.ts
6
- type CustomToolFields = Omit<OpenAI.Responses.CustomTool, "type">;
6
+ type CustomToolFields = Omit<OpenAI$1.Responses.CustomTool, "type">;
7
7
  declare function customTool(func: RunnableFunc<string, string, ToolRunnableConfig>, fields: CustomToolFields): DynamicTool<string>;
8
8
  //#endregion
9
9
  export { customTool };
@@ -1 +1 @@
1
- {"version":3,"file":"custom.d.cts","names":[],"sources":["../../src/tools/custom.ts"],"mappings":";;;;;KASY,gBAAA,GAAmB,IAAA,CAAK,MAAA,CAAO,SAAA,CAAU,UAAA;AAAA,iBAErC,UAAA,CACd,IAAA,EAAM,YAAA,iBAA6B,kBAAA,GACnC,MAAA,EAAQ,gBAAA,GACP,WAAA"}
1
+ {"version":3,"file":"custom.d.cts","names":[],"sources":["../../src/tools/custom.ts"],"mappings":";;;;;KASY,gBAAA,GAAmB,IAAA,CAAK,QAAA,CAAO,SAAA,CAAU,UAAA;AAAA,iBAErC,UAAA,CACd,IAAA,EAAM,YAAA,iBAA6B,kBAAA,GACnC,MAAA,EAAQ,gBAAA,GACP,WAAA"}
@@ -1,9 +1,9 @@
1
- import OpenAI from "openai";
1
+ import OpenAI$1 from "openai";
2
2
  import { RunnableFunc } from "@langchain/core/runnables";
3
3
  import { DynamicTool, ToolRunnableConfig } from "@langchain/core/tools";
4
4
 
5
5
  //#region src/tools/custom.d.ts
6
- type CustomToolFields = Omit<OpenAI.Responses.CustomTool, "type">;
6
+ type CustomToolFields = Omit<OpenAI$1.Responses.CustomTool, "type">;
7
7
  declare function customTool(func: RunnableFunc<string, string, ToolRunnableConfig>, fields: CustomToolFields): DynamicTool<string>;
8
8
  //#endregion
9
9
  export { customTool };
@@ -1 +1 @@
1
- {"version":3,"file":"custom.d.ts","names":[],"sources":["../../src/tools/custom.ts"],"mappings":";;;;;KASY,gBAAA,GAAmB,IAAA,CAAK,MAAA,CAAO,SAAA,CAAU,UAAA;AAAA,iBAErC,UAAA,CACd,IAAA,EAAM,YAAA,iBAA6B,kBAAA,GACnC,MAAA,EAAQ,gBAAA,GACP,WAAA"}
1
+ {"version":3,"file":"custom.d.ts","names":[],"sources":["../../src/tools/custom.ts"],"mappings":";;;;;KASY,gBAAA,GAAmB,IAAA,CAAK,QAAA,CAAO,SAAA,CAAU,UAAA;AAAA,iBAErC,UAAA,CACd,IAAA,EAAM,YAAA,iBAA6B,kBAAA,GACnC,MAAA,EAAQ,gBAAA,GACP,WAAA"}
@@ -1,7 +1,6 @@
1
1
  import { patchConfig, pickRunnableConfigKeys } from "@langchain/core/runnables";
2
2
  import { DynamicTool } from "@langchain/core/tools";
3
3
  import { AsyncLocalStorageProviderSingleton } from "@langchain/core/singletons";
4
-
5
4
  //#region src/tools/custom.ts
6
5
  function customTool(func, fields) {
7
6
  return new DynamicTool({
@@ -20,7 +19,7 @@ function customTool(func, fields) {
20
19
  })
21
20
  });
22
21
  }
23
-
24
22
  //#endregion
25
23
  export { customTool };
24
+
26
25
  //# sourceMappingURL=custom.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"custom.js","names":[],"sources":["../../src/tools/custom.ts"],"sourcesContent":["import {\n patchConfig,\n pickRunnableConfigKeys,\n RunnableFunc,\n} from \"@langchain/core/runnables\";\nimport { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\nimport { DynamicTool, ToolRunnableConfig } from \"@langchain/core/tools\";\nimport OpenAI from \"openai\";\n\nexport type CustomToolFields = Omit<OpenAI.Responses.CustomTool, \"type\">;\n\nexport function customTool(\n func: RunnableFunc<string, string, ToolRunnableConfig>,\n fields: CustomToolFields\n): DynamicTool<string> {\n return new DynamicTool({\n ...fields,\n description: \"\",\n metadata: {\n customTool: fields,\n },\n func: async (input, runManager, config) =>\n new Promise<string>((resolve, reject) => {\n const childConfig = patchConfig(config, {\n callbacks: runManager?.getChild(),\n });\n // eslint-disable-next-line no-void\n void AsyncLocalStorageProviderSingleton.runWithConfig(\n pickRunnableConfigKeys(childConfig),\n async () => {\n try {\n resolve(func(input, childConfig));\n } catch (e) {\n reject(e);\n }\n }\n );\n }),\n });\n}\n"],"mappings":";;;;;AAWA,SAAgB,WACd,MACA,QACqB;AACrB,QAAO,IAAI,YAAY;EACrB,GAAG;EACH,aAAa;EACb,UAAU,EACR,YAAY,QACb;EACD,MAAM,OAAO,OAAO,YAAY,WAC9B,IAAI,SAAiB,SAAS,WAAW;GACvC,MAAM,cAAc,YAAY,QAAQ,EACtC,WAAW,YAAY,UAAU,EAClC,CAAC;AAEF,GAAK,mCAAmC,cACtC,uBAAuB,YAAY,EACnC,YAAY;AACV,QAAI;AACF,aAAQ,KAAK,OAAO,YAAY,CAAC;aAC1B,GAAG;AACV,YAAO,EAAE;;KAGd;IACD;EACL,CAAC"}
1
+ {"version":3,"file":"custom.js","names":[],"sources":["../../src/tools/custom.ts"],"sourcesContent":["import {\n patchConfig,\n pickRunnableConfigKeys,\n RunnableFunc,\n} from \"@langchain/core/runnables\";\nimport { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\nimport { DynamicTool, ToolRunnableConfig } from \"@langchain/core/tools\";\nimport OpenAI from \"openai\";\n\nexport type CustomToolFields = Omit<OpenAI.Responses.CustomTool, \"type\">;\n\nexport function customTool(\n func: RunnableFunc<string, string, ToolRunnableConfig>,\n fields: CustomToolFields\n): DynamicTool<string> {\n return new DynamicTool({\n ...fields,\n description: \"\",\n metadata: {\n customTool: fields,\n },\n func: async (input, runManager, config) =>\n new Promise<string>((resolve, reject) => {\n const childConfig = patchConfig(config, {\n callbacks: runManager?.getChild(),\n });\n // eslint-disable-next-line no-void\n void AsyncLocalStorageProviderSingleton.runWithConfig(\n pickRunnableConfigKeys(childConfig),\n async () => {\n try {\n resolve(func(input, childConfig));\n } catch (e) {\n reject(e);\n }\n }\n );\n }),\n });\n}\n"],"mappings":";;;;AAWA,SAAgB,WACd,MACA,QACqB;AACrB,QAAO,IAAI,YAAY;EACrB,GAAG;EACH,aAAa;EACb,UAAU,EACR,YAAY,QACb;EACD,MAAM,OAAO,OAAO,YAAY,WAC9B,IAAI,SAAiB,SAAS,WAAW;GACvC,MAAM,cAAc,YAAY,QAAQ,EACtC,WAAW,YAAY,UAAU,EAClC,CAAC;AAEG,sCAAmC,cACtC,uBAAuB,YAAY,EACnC,YAAY;AACV,QAAI;AACF,aAAQ,KAAK,OAAO,YAAY,CAAC;aAC1B,GAAG;AACV,YAAO,EAAE;;KAGd;IACD;EACL,CAAC"}
@@ -1,7 +1,6 @@
1
1
  let openai = require("openai");
2
2
  let _langchain_core_utils_env = require("@langchain/core/utils/env");
3
3
  let _langchain_core_tools = require("@langchain/core/tools");
4
-
5
4
  //#region src/tools/dalle.ts
6
5
  /**
7
6
  * A tool for generating images with Open AIs Dall-E 2 or 3 API.
@@ -94,7 +93,7 @@ var DallEAPIWrapper = class extends _langchain_core_tools.Tool {
94
93
  return data;
95
94
  }
96
95
  };
97
-
98
96
  //#endregion
99
97
  exports.DallEAPIWrapper = DallEAPIWrapper;
98
+
100
99
  //# sourceMappingURL=dalle.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"dalle.cjs","names":["Tool","OpenAIClient"],"sources":["../../src/tools/dalle.ts"],"sourcesContent":["import { getEnvironmentVariable } from \"@langchain/core/utils/env\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { Tool, ToolParams } from \"@langchain/core/tools\";\nimport {\n MessageContentComplex,\n MessageContentImageUrl,\n} from \"@langchain/core/messages\";\n\n/**\n * @see https://platform.openai.com/docs/api-reference/images/create\n */\nexport type OpenAIImageModelId =\n | OpenAIClient.ImageModel\n | (string & NonNullable<unknown>);\n\n/**\n * An interface for the Dall-E API Wrapper.\n */\nexport interface DallEAPIWrapperParams extends ToolParams {\n /**\n * The OpenAI API key\n * Alias for `apiKey`\n */\n openAIApiKey?: string;\n /**\n * The OpenAI API key\n */\n apiKey?: string;\n /**\n * The model to use.\n * Alias for `model`\n * @params \"dall-e-2\" | \"dall-e-3\"\n * @default \"dall-e-3\"\n * @deprecated Use `model` instead.\n */\n modelName?: OpenAIImageModelId;\n /**\n * The model to use.\n * @params \"dall-e-2\" | \"dall-e-3\"\n * @default \"dall-e-3\"\n */\n model?: OpenAIImageModelId;\n /**\n * The style of the generated images. Must be one of vivid or natural.\n * Vivid causes the model to lean towards generating hyper-real and dramatic images.\n * Natural causes the model to produce more natural, less hyper-real looking images.\n * @default \"vivid\"\n */\n style?: \"natural\" | \"vivid\";\n /**\n * The quality of the image that will be generated. ‘hd’ creates images with finer\n * details and greater consistency across the image.\n * @default \"standard\"\n */\n quality?: \"standard\" | \"hd\";\n /**\n * The number of images to generate.\n * Must be between 1 and 10.\n * For dall-e-3, only `n: 1` is supported.\n * @default 1\n */\n n?: number;\n /**\n * The size of the generated images.\n * Must be one of 256x256, 512x512, or 1024x1024 for DALL·E-2 models.\n * Must be one of 1024x1024, 1792x1024, or 1024x1792 for DALL·E-3 models.\n * @default \"1024x1024\"\n */\n size?: \"256x256\" | \"512x512\" | \"1024x1024\" | \"1792x1024\" | \"1024x1792\";\n /**\n * The format in which the generated images are returned.\n * Must be one of \"url\" or \"b64_json\".\n * @default \"url\"\n */\n dallEResponseFormat?: \"url\" | \"b64_json\";\n /**\n * @deprecated Use dallEResponseFormat instead for the Dall-E response type.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n responseFormat?: any;\n /**\n * A unique identifier representing your end-user, which will help\n * OpenAI to monitor and detect abuse.\n */\n user?: string;\n /**\n * The organization to use\n */\n organization?: string;\n /**\n * The base URL of the OpenAI API.\n */\n baseUrl?: string;\n}\n\n/**\n * A tool for generating images with Open AIs Dall-E 2 or 3 API.\n */\nexport class DallEAPIWrapper extends Tool {\n static lc_name() {\n return \"DallEAPIWrapper\";\n }\n\n name = \"dalle_api_wrapper\";\n\n description =\n \"A wrapper around OpenAI DALL-E API. Useful for when you need to generate images from a text description. Input should be an image description.\";\n\n protected client: OpenAIClient;\n\n static readonly toolName = \"dalle_api_wrapper\";\n\n private model = \"dall-e-3\";\n\n private style: \"natural\" | \"vivid\" = \"vivid\";\n\n private quality: \"standard\" | \"hd\" = \"standard\";\n\n private n = 1;\n\n private size:\n | \"256x256\"\n | \"512x512\"\n | \"1024x1024\"\n | \"1792x1024\"\n | \"1024x1792\" = \"1024x1024\";\n\n private dallEResponseFormat: \"url\" | \"b64_json\" = \"url\";\n\n private user?: string;\n\n constructor(fields?: DallEAPIWrapperParams) {\n // Shim for new base tool param name\n if (\n fields?.responseFormat !== undefined &&\n [\"url\", \"b64_json\"].includes(fields.responseFormat)\n ) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n fields.dallEResponseFormat = fields.responseFormat as any;\n fields.responseFormat = \"content\";\n }\n super(fields);\n const openAIApiKey =\n fields?.apiKey ??\n fields?.openAIApiKey ??\n getEnvironmentVariable(\"OPENAI_API_KEY\");\n\n const organization =\n fields?.organization ?? getEnvironmentVariable(\"OPENAI_ORGANIZATION\");\n\n const clientConfig = {\n apiKey: openAIApiKey,\n organization,\n dangerouslyAllowBrowser: true,\n baseURL: fields?.baseUrl,\n };\n this.client = new OpenAIClient(clientConfig);\n this.model = fields?.model ?? fields?.modelName ?? this.model;\n this.style = fields?.style ?? this.style;\n this.quality = fields?.quality ?? this.quality;\n this.n = fields?.n ?? this.n;\n this.size = fields?.size ?? this.size;\n this.dallEResponseFormat =\n fields?.dallEResponseFormat ?? this.dallEResponseFormat;\n this.user = fields?.user;\n }\n\n /**\n * Processes the API response if multiple images are generated.\n * Returns a list of MessageContentImageUrl objects. If the response\n * format is `url`, then the `image_url` field will contain the URL.\n * If it is `b64_json`, then the `image_url` field will contain an object\n * with a `url` field with the base64 encoded image.\n *\n * @param {OpenAIClient.Images.ImagesResponse[]} response The API response\n * @returns {MessageContentImageUrl[]}\n */\n private processMultipleGeneratedUrls(\n response: OpenAIClient.Images.ImagesResponse[]\n ): MessageContentImageUrl[] {\n if (this.dallEResponseFormat === \"url\") {\n return response.flatMap((res) => {\n const imageUrlContent =\n res.data\n ?.flatMap((item) => {\n if (!item.url) return [];\n return {\n type: \"image_url\" as const,\n image_url: item.url,\n };\n })\n .filter(\n (item) =>\n item !== undefined &&\n item.type === \"image_url\" &&\n typeof item.image_url === \"string\" &&\n item.image_url !== undefined\n ) ?? [];\n return imageUrlContent;\n });\n } else {\n return response.flatMap((res) => {\n const b64Content =\n res.data\n ?.flatMap((item) => {\n if (!item.b64_json) return [];\n return {\n type: \"image_url\" as const,\n image_url: {\n url: item.b64_json,\n },\n };\n })\n .filter(\n (item) =>\n item !== undefined &&\n item.type === \"image_url\" &&\n typeof item.image_url === \"object\" &&\n \"url\" in item.image_url &&\n typeof item.image_url.url === \"string\" &&\n item.image_url.url !== undefined\n ) ?? [];\n return b64Content;\n });\n }\n }\n\n /** @ignore */\n async _call(input: string): Promise<string | MessageContentComplex[]> {\n const generateImageFields = {\n model: this.model,\n prompt: input,\n n: 1,\n size: this.size,\n response_format: this.dallEResponseFormat,\n style: this.style,\n quality: this.quality,\n user: this.user,\n };\n\n if (this.n > 1) {\n const results = await Promise.all(\n Array.from({ length: this.n }).map(() =>\n this.client.images.generate(generateImageFields)\n )\n );\n\n return this.processMultipleGeneratedUrls(results);\n }\n\n const response = await this.client.images.generate(generateImageFields);\n\n let data = \"\";\n if (this.dallEResponseFormat === \"url\") {\n [data] =\n response.data\n ?.map((item) => item.url)\n .filter((url): url is string => url !== \"undefined\") ?? [];\n } else {\n [data] =\n response.data\n ?.map((item) => item.b64_json)\n .filter((b64_json): b64_json is string => b64_json !== \"undefined\") ??\n [];\n }\n return data;\n }\n}\n"],"mappings":";;;;;;;;AAkGA,IAAa,kBAAb,cAAqCA,2BAAK;CACxC,OAAO,UAAU;AACf,SAAO;;CAGT,OAAO;CAEP,cACE;CAEF,AAAU;CAEV,OAAgB,WAAW;CAE3B,AAAQ,QAAQ;CAEhB,AAAQ,QAA6B;CAErC,AAAQ,UAA6B;CAErC,AAAQ,IAAI;CAEZ,AAAQ,OAKU;CAElB,AAAQ,sBAA0C;CAElD,AAAQ;CAER,YAAY,QAAgC;AAE1C,MACE,QAAQ,mBAAmB,UAC3B,CAAC,OAAO,WAAW,CAAC,SAAS,OAAO,eAAe,EACnD;AAEA,UAAO,sBAAsB,OAAO;AACpC,UAAO,iBAAiB;;AAE1B,QAAM,OAAO;AAeb,OAAK,SAAS,IAAIC,cANG;GACnB,QARA,QAAQ,UACR,QAAQ,sEACe,iBAAiB;GAOxC,cAJA,QAAQ,sEAAuC,sBAAsB;GAKrE,yBAAyB;GACzB,SAAS,QAAQ;GAClB,CAC2C;AAC5C,OAAK,QAAQ,QAAQ,SAAS,QAAQ,aAAa,KAAK;AACxD,OAAK,QAAQ,QAAQ,SAAS,KAAK;AACnC,OAAK,UAAU,QAAQ,WAAW,KAAK;AACvC,OAAK,IAAI,QAAQ,KAAK,KAAK;AAC3B,OAAK,OAAO,QAAQ,QAAQ,KAAK;AACjC,OAAK,sBACH,QAAQ,uBAAuB,KAAK;AACtC,OAAK,OAAO,QAAQ;;;;;;;;;;;;CAatB,AAAQ,6BACN,UAC0B;AAC1B,MAAI,KAAK,wBAAwB,MAC/B,QAAO,SAAS,SAAS,QAAQ;AAiB/B,UAfE,IAAI,MACA,SAAS,SAAS;AAClB,QAAI,CAAC,KAAK,IAAK,QAAO,EAAE;AACxB,WAAO;KACL,MAAM;KACN,WAAW,KAAK;KACjB;KACD,CACD,QACE,SACC,SAAS,UACT,KAAK,SAAS,eACd,OAAO,KAAK,cAAc,YAC1B,KAAK,cAAc,OACtB,IAAI,EAAE;IAEX;MAEF,QAAO,SAAS,SAAS,QAAQ;AAqB/B,UAnBE,IAAI,MACA,SAAS,SAAS;AAClB,QAAI,CAAC,KAAK,SAAU,QAAO,EAAE;AAC7B,WAAO;KACL,MAAM;KACN,WAAW,EACT,KAAK,KAAK,UACX;KACF;KACD,CACD,QACE,SACC,SAAS,UACT,KAAK,SAAS,eACd,OAAO,KAAK,cAAc,YAC1B,SAAS,KAAK,aACd,OAAO,KAAK,UAAU,QAAQ,YAC9B,KAAK,UAAU,QAAQ,OAC1B,IAAI,EAAE;IAEX;;;CAKN,MAAM,MAAM,OAA0D;EACpE,MAAM,sBAAsB;GAC1B,OAAO,KAAK;GACZ,QAAQ;GACR,GAAG;GACH,MAAM,KAAK;GACX,iBAAiB,KAAK;GACtB,OAAO,KAAK;GACZ,SAAS,KAAK;GACd,MAAM,KAAK;GACZ;AAED,MAAI,KAAK,IAAI,GAAG;GACd,MAAM,UAAU,MAAM,QAAQ,IAC5B,MAAM,KAAK,EAAE,QAAQ,KAAK,GAAG,CAAC,CAAC,UAC7B,KAAK,OAAO,OAAO,SAAS,oBAAoB,CACjD,CACF;AAED,UAAO,KAAK,6BAA6B,QAAQ;;EAGnD,MAAM,WAAW,MAAM,KAAK,OAAO,OAAO,SAAS,oBAAoB;EAEvE,IAAI,OAAO;AACX,MAAI,KAAK,wBAAwB,MAC/B,EAAC,QACC,SAAS,MACL,KAAK,SAAS,KAAK,IAAI,CACxB,QAAQ,QAAuB,QAAQ,YAAY,IAAI,EAAE;MAE9D,EAAC,QACC,SAAS,MACL,KAAK,SAAS,KAAK,SAAS,CAC7B,QAAQ,aAAiC,aAAa,YAAY,IACrE,EAAE;AAEN,SAAO"}
1
+ {"version":3,"file":"dalle.cjs","names":["Tool","OpenAIClient"],"sources":["../../src/tools/dalle.ts"],"sourcesContent":["import { getEnvironmentVariable } from \"@langchain/core/utils/env\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { Tool, ToolParams } from \"@langchain/core/tools\";\nimport {\n MessageContentComplex,\n MessageContentImageUrl,\n} from \"@langchain/core/messages\";\n\n/**\n * @see https://platform.openai.com/docs/api-reference/images/create\n */\nexport type OpenAIImageModelId =\n | OpenAIClient.ImageModel\n | (string & NonNullable<unknown>);\n\n/**\n * An interface for the Dall-E API Wrapper.\n */\nexport interface DallEAPIWrapperParams extends ToolParams {\n /**\n * The OpenAI API key\n * Alias for `apiKey`\n */\n openAIApiKey?: string;\n /**\n * The OpenAI API key\n */\n apiKey?: string;\n /**\n * The model to use.\n * Alias for `model`\n * @params \"dall-e-2\" | \"dall-e-3\"\n * @default \"dall-e-3\"\n * @deprecated Use `model` instead.\n */\n modelName?: OpenAIImageModelId;\n /**\n * The model to use.\n * @params \"dall-e-2\" | \"dall-e-3\"\n * @default \"dall-e-3\"\n */\n model?: OpenAIImageModelId;\n /**\n * The style of the generated images. Must be one of vivid or natural.\n * Vivid causes the model to lean towards generating hyper-real and dramatic images.\n * Natural causes the model to produce more natural, less hyper-real looking images.\n * @default \"vivid\"\n */\n style?: \"natural\" | \"vivid\";\n /**\n * The quality of the image that will be generated. ‘hd’ creates images with finer\n * details and greater consistency across the image.\n * @default \"standard\"\n */\n quality?: \"standard\" | \"hd\";\n /**\n * The number of images to generate.\n * Must be between 1 and 10.\n * For dall-e-3, only `n: 1` is supported.\n * @default 1\n */\n n?: number;\n /**\n * The size of the generated images.\n * Must be one of 256x256, 512x512, or 1024x1024 for DALL·E-2 models.\n * Must be one of 1024x1024, 1792x1024, or 1024x1792 for DALL·E-3 models.\n * @default \"1024x1024\"\n */\n size?: \"256x256\" | \"512x512\" | \"1024x1024\" | \"1792x1024\" | \"1024x1792\";\n /**\n * The format in which the generated images are returned.\n * Must be one of \"url\" or \"b64_json\".\n * @default \"url\"\n */\n dallEResponseFormat?: \"url\" | \"b64_json\";\n /**\n * @deprecated Use dallEResponseFormat instead for the Dall-E response type.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n responseFormat?: any;\n /**\n * A unique identifier representing your end-user, which will help\n * OpenAI to monitor and detect abuse.\n */\n user?: string;\n /**\n * The organization to use\n */\n organization?: string;\n /**\n * The base URL of the OpenAI API.\n */\n baseUrl?: string;\n}\n\n/**\n * A tool for generating images with Open AIs Dall-E 2 or 3 API.\n */\nexport class DallEAPIWrapper extends Tool {\n static lc_name() {\n return \"DallEAPIWrapper\";\n }\n\n name = \"dalle_api_wrapper\";\n\n description =\n \"A wrapper around OpenAI DALL-E API. Useful for when you need to generate images from a text description. Input should be an image description.\";\n\n protected client: OpenAIClient;\n\n static readonly toolName = \"dalle_api_wrapper\";\n\n private model = \"dall-e-3\";\n\n private style: \"natural\" | \"vivid\" = \"vivid\";\n\n private quality: \"standard\" | \"hd\" = \"standard\";\n\n private n = 1;\n\n private size:\n | \"256x256\"\n | \"512x512\"\n | \"1024x1024\"\n | \"1792x1024\"\n | \"1024x1792\" = \"1024x1024\";\n\n private dallEResponseFormat: \"url\" | \"b64_json\" = \"url\";\n\n private user?: string;\n\n constructor(fields?: DallEAPIWrapperParams) {\n // Shim for new base tool param name\n if (\n fields?.responseFormat !== undefined &&\n [\"url\", \"b64_json\"].includes(fields.responseFormat)\n ) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n fields.dallEResponseFormat = fields.responseFormat as any;\n fields.responseFormat = \"content\";\n }\n super(fields);\n const openAIApiKey =\n fields?.apiKey ??\n fields?.openAIApiKey ??\n getEnvironmentVariable(\"OPENAI_API_KEY\");\n\n const organization =\n fields?.organization ?? getEnvironmentVariable(\"OPENAI_ORGANIZATION\");\n\n const clientConfig = {\n apiKey: openAIApiKey,\n organization,\n dangerouslyAllowBrowser: true,\n baseURL: fields?.baseUrl,\n };\n this.client = new OpenAIClient(clientConfig);\n this.model = fields?.model ?? fields?.modelName ?? this.model;\n this.style = fields?.style ?? this.style;\n this.quality = fields?.quality ?? this.quality;\n this.n = fields?.n ?? this.n;\n this.size = fields?.size ?? this.size;\n this.dallEResponseFormat =\n fields?.dallEResponseFormat ?? this.dallEResponseFormat;\n this.user = fields?.user;\n }\n\n /**\n * Processes the API response if multiple images are generated.\n * Returns a list of MessageContentImageUrl objects. If the response\n * format is `url`, then the `image_url` field will contain the URL.\n * If it is `b64_json`, then the `image_url` field will contain an object\n * with a `url` field with the base64 encoded image.\n *\n * @param {OpenAIClient.Images.ImagesResponse[]} response The API response\n * @returns {MessageContentImageUrl[]}\n */\n private processMultipleGeneratedUrls(\n response: OpenAIClient.Images.ImagesResponse[]\n ): MessageContentImageUrl[] {\n if (this.dallEResponseFormat === \"url\") {\n return response.flatMap((res) => {\n const imageUrlContent =\n res.data\n ?.flatMap((item) => {\n if (!item.url) return [];\n return {\n type: \"image_url\" as const,\n image_url: item.url,\n };\n })\n .filter(\n (item) =>\n item !== undefined &&\n item.type === \"image_url\" &&\n typeof item.image_url === \"string\" &&\n item.image_url !== undefined\n ) ?? [];\n return imageUrlContent;\n });\n } else {\n return response.flatMap((res) => {\n const b64Content =\n res.data\n ?.flatMap((item) => {\n if (!item.b64_json) return [];\n return {\n type: \"image_url\" as const,\n image_url: {\n url: item.b64_json,\n },\n };\n })\n .filter(\n (item) =>\n item !== undefined &&\n item.type === \"image_url\" &&\n typeof item.image_url === \"object\" &&\n \"url\" in item.image_url &&\n typeof item.image_url.url === \"string\" &&\n item.image_url.url !== undefined\n ) ?? [];\n return b64Content;\n });\n }\n }\n\n /** @ignore */\n async _call(input: string): Promise<string | MessageContentComplex[]> {\n const generateImageFields = {\n model: this.model,\n prompt: input,\n n: 1,\n size: this.size,\n response_format: this.dallEResponseFormat,\n style: this.style,\n quality: this.quality,\n user: this.user,\n };\n\n if (this.n > 1) {\n const results = await Promise.all(\n Array.from({ length: this.n }).map(() =>\n this.client.images.generate(generateImageFields)\n )\n );\n\n return this.processMultipleGeneratedUrls(results);\n }\n\n const response = await this.client.images.generate(generateImageFields);\n\n let data = \"\";\n if (this.dallEResponseFormat === \"url\") {\n [data] =\n response.data\n ?.map((item) => item.url)\n .filter((url): url is string => url !== \"undefined\") ?? [];\n } else {\n [data] =\n response.data\n ?.map((item) => item.b64_json)\n .filter((b64_json): b64_json is string => b64_json !== \"undefined\") ??\n [];\n }\n return data;\n }\n}\n"],"mappings":";;;;;;;AAkGA,IAAa,kBAAb,cAAqCA,sBAAAA,KAAK;CACxC,OAAO,UAAU;AACf,SAAO;;CAGT,OAAO;CAEP,cACE;CAEF;CAEA,OAAgB,WAAW;CAE3B,QAAgB;CAEhB,QAAqC;CAErC,UAAqC;CAErC,IAAY;CAEZ,OAKkB;CAElB,sBAAkD;CAElD;CAEA,YAAY,QAAgC;AAE1C,MACE,QAAQ,mBAAmB,KAAA,KAC3B,CAAC,OAAO,WAAW,CAAC,SAAS,OAAO,eAAe,EACnD;AAEA,UAAO,sBAAsB,OAAO;AACpC,UAAO,iBAAiB;;AAE1B,QAAM,OAAO;AAeb,OAAK,SAAS,IAAIC,OAAAA,OANG;GACnB,QARA,QAAQ,UACR,QAAQ,iBAAA,GAAA,0BAAA,wBACe,iBAAiB;GAOxC,cAJA,QAAQ,iBAAA,GAAA,0BAAA,wBAAuC,sBAAsB;GAKrE,yBAAyB;GACzB,SAAS,QAAQ;GAClB,CAC2C;AAC5C,OAAK,QAAQ,QAAQ,SAAS,QAAQ,aAAa,KAAK;AACxD,OAAK,QAAQ,QAAQ,SAAS,KAAK;AACnC,OAAK,UAAU,QAAQ,WAAW,KAAK;AACvC,OAAK,IAAI,QAAQ,KAAK,KAAK;AAC3B,OAAK,OAAO,QAAQ,QAAQ,KAAK;AACjC,OAAK,sBACH,QAAQ,uBAAuB,KAAK;AACtC,OAAK,OAAO,QAAQ;;;;;;;;;;;;CAatB,6BACE,UAC0B;AAC1B,MAAI,KAAK,wBAAwB,MAC/B,QAAO,SAAS,SAAS,QAAQ;AAiB/B,UAfE,IAAI,MACA,SAAS,SAAS;AAClB,QAAI,CAAC,KAAK,IAAK,QAAO,EAAE;AACxB,WAAO;KACL,MAAM;KACN,WAAW,KAAK;KACjB;KACD,CACD,QACE,SACC,SAAS,KAAA,KACT,KAAK,SAAS,eACd,OAAO,KAAK,cAAc,YAC1B,KAAK,cAAc,KAAA,EACtB,IAAI,EAAE;IAEX;MAEF,QAAO,SAAS,SAAS,QAAQ;AAqB/B,UAnBE,IAAI,MACA,SAAS,SAAS;AAClB,QAAI,CAAC,KAAK,SAAU,QAAO,EAAE;AAC7B,WAAO;KACL,MAAM;KACN,WAAW,EACT,KAAK,KAAK,UACX;KACF;KACD,CACD,QACE,SACC,SAAS,KAAA,KACT,KAAK,SAAS,eACd,OAAO,KAAK,cAAc,YAC1B,SAAS,KAAK,aACd,OAAO,KAAK,UAAU,QAAQ,YAC9B,KAAK,UAAU,QAAQ,KAAA,EAC1B,IAAI,EAAE;IAEX;;;CAKN,MAAM,MAAM,OAA0D;EACpE,MAAM,sBAAsB;GAC1B,OAAO,KAAK;GACZ,QAAQ;GACR,GAAG;GACH,MAAM,KAAK;GACX,iBAAiB,KAAK;GACtB,OAAO,KAAK;GACZ,SAAS,KAAK;GACd,MAAM,KAAK;GACZ;AAED,MAAI,KAAK,IAAI,GAAG;GACd,MAAM,UAAU,MAAM,QAAQ,IAC5B,MAAM,KAAK,EAAE,QAAQ,KAAK,GAAG,CAAC,CAAC,UAC7B,KAAK,OAAO,OAAO,SAAS,oBAAoB,CACjD,CACF;AAED,UAAO,KAAK,6BAA6B,QAAQ;;EAGnD,MAAM,WAAW,MAAM,KAAK,OAAO,OAAO,SAAS,oBAAoB;EAEvE,IAAI,OAAO;AACX,MAAI,KAAK,wBAAwB,MAC/B,EAAC,QACC,SAAS,MACL,KAAK,SAAS,KAAK,IAAI,CACxB,QAAQ,QAAuB,QAAQ,YAAY,IAAI,EAAE;MAE9D,EAAC,QACC,SAAS,MACL,KAAK,SAAS,KAAK,SAAS,CAC7B,QAAQ,aAAiC,aAAa,YAAY,IACrE,EAAE;AAEN,SAAO"}
@@ -1,4 +1,4 @@
1
- import { OpenAI as OpenAI$1 } from "openai";
1
+ import { OpenAI } from "openai";
2
2
  import { MessageContentComplex } from "@langchain/core/messages";
3
3
  import { Tool, ToolParams } from "@langchain/core/tools";
4
4
 
@@ -6,7 +6,7 @@ import { Tool, ToolParams } from "@langchain/core/tools";
6
6
  /**
7
7
  * @see https://platform.openai.com/docs/api-reference/images/create
8
8
  */
9
- type OpenAIImageModelId = OpenAI$1.ImageModel | (string & NonNullable<unknown>);
9
+ type OpenAIImageModelId = OpenAI.ImageModel | (string & NonNullable<unknown>);
10
10
  /**
11
11
  * An interface for the Dall-E API Wrapper.
12
12
  */
@@ -92,7 +92,7 @@ declare class DallEAPIWrapper extends Tool {
92
92
  static lc_name(): string;
93
93
  name: string;
94
94
  description: string;
95
- protected client: OpenAI$1;
95
+ protected client: OpenAI;
96
96
  static readonly toolName = "dalle_api_wrapper";
97
97
  private model;
98
98
  private style;
@@ -1 +1 @@
1
- {"version":3,"file":"dalle.d.cts","names":[],"sources":["../../src/tools/dalle.ts"],"mappings":";;;;;;;AAWA;KAAY,kBAAA,GACR,QAAA,CAAa,UAAA,aACH,WAAA;;;;UAKG,qBAAA,SAA8B,UAAA;EALjC;;;AAKd;EAKE,YAAA;;;;EAIA,MAAA;EATuD;;;;;;;EAiBvD,SAAA,GAAY,kBAAA;EAMJ;;;;;EAAR,KAAA,GAAQ,kBAAA;EAsCR;;;;;;EA/BA,KAAA;EAkD2B;;;;;EA5C3B,OAAA;EA4CmC;;;;;;EArCnC,CAAA;EA+CU;;;;;;EAxCV,IAAA;EAoDQ;;;;;EA9CR,mBAAA;EAuGQ;;;EAlGR,cAAA;EAqJ6C;;;;EAhJ7C,IAAA;;;;EAIA,YAAA;;;;EAIA,OAAA;AAAA;;;;cAMW,eAAA,SAAwB,IAAA;EAAA,OAC5B,OAAA,CAAA;EAIP,IAAA;EAEA,WAAA;EAAA,UAGU,MAAA,EAAQ,QAAA;EAAA,gBAEF,QAAA;EAAA,QAER,KAAA;EAAA,QAEA,KAAA;EAAA,QAEA,OAAA;EAAA,QAEA,CAAA;EAAA,QAEA,IAAA;EAAA,QAOA,mBAAA;EAAA,QAEA,IAAA;EAER,WAAA,CAAY,MAAA,GAAS,qBAAA;;;;;;;;;;;UA8Cb,4BAAA;;EAmDF,KAAA,CAAM,KAAA,WAAgB,OAAA,UAAiB,qBAAA;AAAA"}
1
+ {"version":3,"file":"dalle.d.cts","names":[],"sources":["../../src/tools/dalle.ts"],"mappings":";;;;;;;AAWA;KAAY,kBAAA,GACR,MAAA,CAAa,UAAA,aACH,WAAA;;;;UAKG,qBAAA,SAA8B,UAAA;EALjC;;;AAKd;EAKE,YAAA;;;;EAIA,MAAA;EATuD;;;;;;;EAiBvD,SAAA,GAAY,kBAAA;EAMJ;;;;;EAAR,KAAA,GAAQ,kBAAA;EAsCR;;;;;;EA/BA,KAAA;EAkD2B;;;;;EA5C3B,OAAA;EA4CmC;;;;;;EArCnC,CAAA;EA+CU;;;;;;EAxCV,IAAA;EAoDQ;;;;;EA9CR,mBAAA;EAuGQ;;;EAlGR,cAAA;EAqJ6C;;;;EAhJ7C,IAAA;;;;EAIA,YAAA;;;;EAIA,OAAA;AAAA;;;;cAMW,eAAA,SAAwB,IAAA;EAAA,OAC5B,OAAA,CAAA;EAIP,IAAA;EAEA,WAAA;EAAA,UAGU,MAAA,EAAQ,MAAA;EAAA,gBAEF,QAAA;EAAA,QAER,KAAA;EAAA,QAEA,KAAA;EAAA,QAEA,OAAA;EAAA,QAEA,CAAA;EAAA,QAEA,IAAA;EAAA,QAOA,mBAAA;EAAA,QAEA,IAAA;EAER,WAAA,CAAY,MAAA,GAAS,qBAAA;;;;;;;;;;;UA8Cb,4BAAA;;EAmDF,KAAA,CAAM,KAAA,WAAgB,OAAA,UAAiB,qBAAA;AAAA"}
@@ -1,4 +1,4 @@
1
- import { OpenAI as OpenAI$1 } from "openai";
1
+ import { OpenAI } from "openai";
2
2
  import { MessageContentComplex } from "@langchain/core/messages";
3
3
  import { Tool, ToolParams } from "@langchain/core/tools";
4
4
 
@@ -6,7 +6,7 @@ import { Tool, ToolParams } from "@langchain/core/tools";
6
6
  /**
7
7
  * @see https://platform.openai.com/docs/api-reference/images/create
8
8
  */
9
- type OpenAIImageModelId = OpenAI$1.ImageModel | (string & NonNullable<unknown>);
9
+ type OpenAIImageModelId = OpenAI.ImageModel | (string & NonNullable<unknown>);
10
10
  /**
11
11
  * An interface for the Dall-E API Wrapper.
12
12
  */
@@ -92,7 +92,7 @@ declare class DallEAPIWrapper extends Tool {
92
92
  static lc_name(): string;
93
93
  name: string;
94
94
  description: string;
95
- protected client: OpenAI$1;
95
+ protected client: OpenAI;
96
96
  static readonly toolName = "dalle_api_wrapper";
97
97
  private model;
98
98
  private style;
@@ -1 +1 @@
1
- {"version":3,"file":"dalle.d.ts","names":[],"sources":["../../src/tools/dalle.ts"],"mappings":";;;;;;;AAWA;KAAY,kBAAA,GACR,QAAA,CAAa,UAAA,aACH,WAAA;;;;UAKG,qBAAA,SAA8B,UAAA;EALjC;;;AAKd;EAKE,YAAA;;;;EAIA,MAAA;EATuD;;;;;;;EAiBvD,SAAA,GAAY,kBAAA;EAMJ;;;;;EAAR,KAAA,GAAQ,kBAAA;EAsCR;;;;;;EA/BA,KAAA;EAkD2B;;;;;EA5C3B,OAAA;EA4CmC;;;;;;EArCnC,CAAA;EA+CU;;;;;;EAxCV,IAAA;EAoDQ;;;;;EA9CR,mBAAA;EAuGQ;;;EAlGR,cAAA;EAqJ6C;;;;EAhJ7C,IAAA;;;;EAIA,YAAA;;;;EAIA,OAAA;AAAA;;;;cAMW,eAAA,SAAwB,IAAA;EAAA,OAC5B,OAAA,CAAA;EAIP,IAAA;EAEA,WAAA;EAAA,UAGU,MAAA,EAAQ,QAAA;EAAA,gBAEF,QAAA;EAAA,QAER,KAAA;EAAA,QAEA,KAAA;EAAA,QAEA,OAAA;EAAA,QAEA,CAAA;EAAA,QAEA,IAAA;EAAA,QAOA,mBAAA;EAAA,QAEA,IAAA;EAER,WAAA,CAAY,MAAA,GAAS,qBAAA;;;;;;;;;;;UA8Cb,4BAAA;;EAmDF,KAAA,CAAM,KAAA,WAAgB,OAAA,UAAiB,qBAAA;AAAA"}
1
+ {"version":3,"file":"dalle.d.ts","names":[],"sources":["../../src/tools/dalle.ts"],"mappings":";;;;;;;AAWA;KAAY,kBAAA,GACR,MAAA,CAAa,UAAA,aACH,WAAA;;;;UAKG,qBAAA,SAA8B,UAAA;EALjC;;;AAKd;EAKE,YAAA;;;;EAIA,MAAA;EATuD;;;;;;;EAiBvD,SAAA,GAAY,kBAAA;EAMJ;;;;;EAAR,KAAA,GAAQ,kBAAA;EAsCR;;;;;;EA/BA,KAAA;EAkD2B;;;;;EA5C3B,OAAA;EA4CmC;;;;;;EArCnC,CAAA;EA+CU;;;;;;EAxCV,IAAA;EAoDQ;;;;;EA9CR,mBAAA;EAuGQ;;;EAlGR,cAAA;EAqJ6C;;;;EAhJ7C,IAAA;;;;EAIA,YAAA;;;;EAIA,OAAA;AAAA;;;;cAMW,eAAA,SAAwB,IAAA;EAAA,OAC5B,OAAA,CAAA;EAIP,IAAA;EAEA,WAAA;EAAA,UAGU,MAAA,EAAQ,MAAA;EAAA,gBAEF,QAAA;EAAA,QAER,KAAA;EAAA,QAEA,KAAA;EAAA,QAEA,OAAA;EAAA,QAEA,CAAA;EAAA,QAEA,IAAA;EAAA,QAOA,mBAAA;EAAA,QAEA,IAAA;EAER,WAAA,CAAY,MAAA,GAAS,qBAAA;;;;;;;;;;;UA8Cb,4BAAA;;EAmDF,KAAA,CAAM,KAAA,WAAgB,OAAA,UAAiB,qBAAA;AAAA"}
@@ -1,7 +1,6 @@
1
- import { OpenAI as OpenAI$1 } from "openai";
1
+ import { OpenAI } from "openai";
2
2
  import { getEnvironmentVariable } from "@langchain/core/utils/env";
3
3
  import { Tool } from "@langchain/core/tools";
4
-
5
4
  //#region src/tools/dalle.ts
6
5
  /**
7
6
  * A tool for generating images with Open AIs Dall-E 2 or 3 API.
@@ -27,7 +26,7 @@ var DallEAPIWrapper = class extends Tool {
27
26
  fields.responseFormat = "content";
28
27
  }
29
28
  super(fields);
30
- this.client = new OpenAI$1({
29
+ this.client = new OpenAI({
31
30
  apiKey: fields?.apiKey ?? fields?.openAIApiKey ?? getEnvironmentVariable("OPENAI_API_KEY"),
32
31
  organization: fields?.organization ?? getEnvironmentVariable("OPENAI_ORGANIZATION"),
33
32
  dangerouslyAllowBrowser: true,
@@ -94,7 +93,7 @@ var DallEAPIWrapper = class extends Tool {
94
93
  return data;
95
94
  }
96
95
  };
97
-
98
96
  //#endregion
99
97
  export { DallEAPIWrapper };
98
+
100
99
  //# sourceMappingURL=dalle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dalle.js","names":["OpenAIClient"],"sources":["../../src/tools/dalle.ts"],"sourcesContent":["import { getEnvironmentVariable } from \"@langchain/core/utils/env\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { Tool, ToolParams } from \"@langchain/core/tools\";\nimport {\n MessageContentComplex,\n MessageContentImageUrl,\n} from \"@langchain/core/messages\";\n\n/**\n * @see https://platform.openai.com/docs/api-reference/images/create\n */\nexport type OpenAIImageModelId =\n | OpenAIClient.ImageModel\n | (string & NonNullable<unknown>);\n\n/**\n * An interface for the Dall-E API Wrapper.\n */\nexport interface DallEAPIWrapperParams extends ToolParams {\n /**\n * The OpenAI API key\n * Alias for `apiKey`\n */\n openAIApiKey?: string;\n /**\n * The OpenAI API key\n */\n apiKey?: string;\n /**\n * The model to use.\n * Alias for `model`\n * @params \"dall-e-2\" | \"dall-e-3\"\n * @default \"dall-e-3\"\n * @deprecated Use `model` instead.\n */\n modelName?: OpenAIImageModelId;\n /**\n * The model to use.\n * @params \"dall-e-2\" | \"dall-e-3\"\n * @default \"dall-e-3\"\n */\n model?: OpenAIImageModelId;\n /**\n * The style of the generated images. Must be one of vivid or natural.\n * Vivid causes the model to lean towards generating hyper-real and dramatic images.\n * Natural causes the model to produce more natural, less hyper-real looking images.\n * @default \"vivid\"\n */\n style?: \"natural\" | \"vivid\";\n /**\n * The quality of the image that will be generated. ‘hd’ creates images with finer\n * details and greater consistency across the image.\n * @default \"standard\"\n */\n quality?: \"standard\" | \"hd\";\n /**\n * The number of images to generate.\n * Must be between 1 and 10.\n * For dall-e-3, only `n: 1` is supported.\n * @default 1\n */\n n?: number;\n /**\n * The size of the generated images.\n * Must be one of 256x256, 512x512, or 1024x1024 for DALL·E-2 models.\n * Must be one of 1024x1024, 1792x1024, or 1024x1792 for DALL·E-3 models.\n * @default \"1024x1024\"\n */\n size?: \"256x256\" | \"512x512\" | \"1024x1024\" | \"1792x1024\" | \"1024x1792\";\n /**\n * The format in which the generated images are returned.\n * Must be one of \"url\" or \"b64_json\".\n * @default \"url\"\n */\n dallEResponseFormat?: \"url\" | \"b64_json\";\n /**\n * @deprecated Use dallEResponseFormat instead for the Dall-E response type.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n responseFormat?: any;\n /**\n * A unique identifier representing your end-user, which will help\n * OpenAI to monitor and detect abuse.\n */\n user?: string;\n /**\n * The organization to use\n */\n organization?: string;\n /**\n * The base URL of the OpenAI API.\n */\n baseUrl?: string;\n}\n\n/**\n * A tool for generating images with Open AIs Dall-E 2 or 3 API.\n */\nexport class DallEAPIWrapper extends Tool {\n static lc_name() {\n return \"DallEAPIWrapper\";\n }\n\n name = \"dalle_api_wrapper\";\n\n description =\n \"A wrapper around OpenAI DALL-E API. Useful for when you need to generate images from a text description. Input should be an image description.\";\n\n protected client: OpenAIClient;\n\n static readonly toolName = \"dalle_api_wrapper\";\n\n private model = \"dall-e-3\";\n\n private style: \"natural\" | \"vivid\" = \"vivid\";\n\n private quality: \"standard\" | \"hd\" = \"standard\";\n\n private n = 1;\n\n private size:\n | \"256x256\"\n | \"512x512\"\n | \"1024x1024\"\n | \"1792x1024\"\n | \"1024x1792\" = \"1024x1024\";\n\n private dallEResponseFormat: \"url\" | \"b64_json\" = \"url\";\n\n private user?: string;\n\n constructor(fields?: DallEAPIWrapperParams) {\n // Shim for new base tool param name\n if (\n fields?.responseFormat !== undefined &&\n [\"url\", \"b64_json\"].includes(fields.responseFormat)\n ) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n fields.dallEResponseFormat = fields.responseFormat as any;\n fields.responseFormat = \"content\";\n }\n super(fields);\n const openAIApiKey =\n fields?.apiKey ??\n fields?.openAIApiKey ??\n getEnvironmentVariable(\"OPENAI_API_KEY\");\n\n const organization =\n fields?.organization ?? getEnvironmentVariable(\"OPENAI_ORGANIZATION\");\n\n const clientConfig = {\n apiKey: openAIApiKey,\n organization,\n dangerouslyAllowBrowser: true,\n baseURL: fields?.baseUrl,\n };\n this.client = new OpenAIClient(clientConfig);\n this.model = fields?.model ?? fields?.modelName ?? this.model;\n this.style = fields?.style ?? this.style;\n this.quality = fields?.quality ?? this.quality;\n this.n = fields?.n ?? this.n;\n this.size = fields?.size ?? this.size;\n this.dallEResponseFormat =\n fields?.dallEResponseFormat ?? this.dallEResponseFormat;\n this.user = fields?.user;\n }\n\n /**\n * Processes the API response if multiple images are generated.\n * Returns a list of MessageContentImageUrl objects. If the response\n * format is `url`, then the `image_url` field will contain the URL.\n * If it is `b64_json`, then the `image_url` field will contain an object\n * with a `url` field with the base64 encoded image.\n *\n * @param {OpenAIClient.Images.ImagesResponse[]} response The API response\n * @returns {MessageContentImageUrl[]}\n */\n private processMultipleGeneratedUrls(\n response: OpenAIClient.Images.ImagesResponse[]\n ): MessageContentImageUrl[] {\n if (this.dallEResponseFormat === \"url\") {\n return response.flatMap((res) => {\n const imageUrlContent =\n res.data\n ?.flatMap((item) => {\n if (!item.url) return [];\n return {\n type: \"image_url\" as const,\n image_url: item.url,\n };\n })\n .filter(\n (item) =>\n item !== undefined &&\n item.type === \"image_url\" &&\n typeof item.image_url === \"string\" &&\n item.image_url !== undefined\n ) ?? [];\n return imageUrlContent;\n });\n } else {\n return response.flatMap((res) => {\n const b64Content =\n res.data\n ?.flatMap((item) => {\n if (!item.b64_json) return [];\n return {\n type: \"image_url\" as const,\n image_url: {\n url: item.b64_json,\n },\n };\n })\n .filter(\n (item) =>\n item !== undefined &&\n item.type === \"image_url\" &&\n typeof item.image_url === \"object\" &&\n \"url\" in item.image_url &&\n typeof item.image_url.url === \"string\" &&\n item.image_url.url !== undefined\n ) ?? [];\n return b64Content;\n });\n }\n }\n\n /** @ignore */\n async _call(input: string): Promise<string | MessageContentComplex[]> {\n const generateImageFields = {\n model: this.model,\n prompt: input,\n n: 1,\n size: this.size,\n response_format: this.dallEResponseFormat,\n style: this.style,\n quality: this.quality,\n user: this.user,\n };\n\n if (this.n > 1) {\n const results = await Promise.all(\n Array.from({ length: this.n }).map(() =>\n this.client.images.generate(generateImageFields)\n )\n );\n\n return this.processMultipleGeneratedUrls(results);\n }\n\n const response = await this.client.images.generate(generateImageFields);\n\n let data = \"\";\n if (this.dallEResponseFormat === \"url\") {\n [data] =\n response.data\n ?.map((item) => item.url)\n .filter((url): url is string => url !== \"undefined\") ?? [];\n } else {\n [data] =\n response.data\n ?.map((item) => item.b64_json)\n .filter((b64_json): b64_json is string => b64_json !== \"undefined\") ??\n [];\n }\n return data;\n }\n}\n"],"mappings":";;;;;;;;AAkGA,IAAa,kBAAb,cAAqC,KAAK;CACxC,OAAO,UAAU;AACf,SAAO;;CAGT,OAAO;CAEP,cACE;CAEF,AAAU;CAEV,OAAgB,WAAW;CAE3B,AAAQ,QAAQ;CAEhB,AAAQ,QAA6B;CAErC,AAAQ,UAA6B;CAErC,AAAQ,IAAI;CAEZ,AAAQ,OAKU;CAElB,AAAQ,sBAA0C;CAElD,AAAQ;CAER,YAAY,QAAgC;AAE1C,MACE,QAAQ,mBAAmB,UAC3B,CAAC,OAAO,WAAW,CAAC,SAAS,OAAO,eAAe,EACnD;AAEA,UAAO,sBAAsB,OAAO;AACpC,UAAO,iBAAiB;;AAE1B,QAAM,OAAO;AAeb,OAAK,SAAS,IAAIA,SANG;GACnB,QARA,QAAQ,UACR,QAAQ,gBACR,uBAAuB,iBAAiB;GAOxC,cAJA,QAAQ,gBAAgB,uBAAuB,sBAAsB;GAKrE,yBAAyB;GACzB,SAAS,QAAQ;GAClB,CAC2C;AAC5C,OAAK,QAAQ,QAAQ,SAAS,QAAQ,aAAa,KAAK;AACxD,OAAK,QAAQ,QAAQ,SAAS,KAAK;AACnC,OAAK,UAAU,QAAQ,WAAW,KAAK;AACvC,OAAK,IAAI,QAAQ,KAAK,KAAK;AAC3B,OAAK,OAAO,QAAQ,QAAQ,KAAK;AACjC,OAAK,sBACH,QAAQ,uBAAuB,KAAK;AACtC,OAAK,OAAO,QAAQ;;;;;;;;;;;;CAatB,AAAQ,6BACN,UAC0B;AAC1B,MAAI,KAAK,wBAAwB,MAC/B,QAAO,SAAS,SAAS,QAAQ;AAiB/B,UAfE,IAAI,MACA,SAAS,SAAS;AAClB,QAAI,CAAC,KAAK,IAAK,QAAO,EAAE;AACxB,WAAO;KACL,MAAM;KACN,WAAW,KAAK;KACjB;KACD,CACD,QACE,SACC,SAAS,UACT,KAAK,SAAS,eACd,OAAO,KAAK,cAAc,YAC1B,KAAK,cAAc,OACtB,IAAI,EAAE;IAEX;MAEF,QAAO,SAAS,SAAS,QAAQ;AAqB/B,UAnBE,IAAI,MACA,SAAS,SAAS;AAClB,QAAI,CAAC,KAAK,SAAU,QAAO,EAAE;AAC7B,WAAO;KACL,MAAM;KACN,WAAW,EACT,KAAK,KAAK,UACX;KACF;KACD,CACD,QACE,SACC,SAAS,UACT,KAAK,SAAS,eACd,OAAO,KAAK,cAAc,YAC1B,SAAS,KAAK,aACd,OAAO,KAAK,UAAU,QAAQ,YAC9B,KAAK,UAAU,QAAQ,OAC1B,IAAI,EAAE;IAEX;;;CAKN,MAAM,MAAM,OAA0D;EACpE,MAAM,sBAAsB;GAC1B,OAAO,KAAK;GACZ,QAAQ;GACR,GAAG;GACH,MAAM,KAAK;GACX,iBAAiB,KAAK;GACtB,OAAO,KAAK;GACZ,SAAS,KAAK;GACd,MAAM,KAAK;GACZ;AAED,MAAI,KAAK,IAAI,GAAG;GACd,MAAM,UAAU,MAAM,QAAQ,IAC5B,MAAM,KAAK,EAAE,QAAQ,KAAK,GAAG,CAAC,CAAC,UAC7B,KAAK,OAAO,OAAO,SAAS,oBAAoB,CACjD,CACF;AAED,UAAO,KAAK,6BAA6B,QAAQ;;EAGnD,MAAM,WAAW,MAAM,KAAK,OAAO,OAAO,SAAS,oBAAoB;EAEvE,IAAI,OAAO;AACX,MAAI,KAAK,wBAAwB,MAC/B,EAAC,QACC,SAAS,MACL,KAAK,SAAS,KAAK,IAAI,CACxB,QAAQ,QAAuB,QAAQ,YAAY,IAAI,EAAE;MAE9D,EAAC,QACC,SAAS,MACL,KAAK,SAAS,KAAK,SAAS,CAC7B,QAAQ,aAAiC,aAAa,YAAY,IACrE,EAAE;AAEN,SAAO"}
1
+ {"version":3,"file":"dalle.js","names":["OpenAIClient"],"sources":["../../src/tools/dalle.ts"],"sourcesContent":["import { getEnvironmentVariable } from \"@langchain/core/utils/env\";\nimport { OpenAI as OpenAIClient } from \"openai\";\nimport { Tool, ToolParams } from \"@langchain/core/tools\";\nimport {\n MessageContentComplex,\n MessageContentImageUrl,\n} from \"@langchain/core/messages\";\n\n/**\n * @see https://platform.openai.com/docs/api-reference/images/create\n */\nexport type OpenAIImageModelId =\n | OpenAIClient.ImageModel\n | (string & NonNullable<unknown>);\n\n/**\n * An interface for the Dall-E API Wrapper.\n */\nexport interface DallEAPIWrapperParams extends ToolParams {\n /**\n * The OpenAI API key\n * Alias for `apiKey`\n */\n openAIApiKey?: string;\n /**\n * The OpenAI API key\n */\n apiKey?: string;\n /**\n * The model to use.\n * Alias for `model`\n * @params \"dall-e-2\" | \"dall-e-3\"\n * @default \"dall-e-3\"\n * @deprecated Use `model` instead.\n */\n modelName?: OpenAIImageModelId;\n /**\n * The model to use.\n * @params \"dall-e-2\" | \"dall-e-3\"\n * @default \"dall-e-3\"\n */\n model?: OpenAIImageModelId;\n /**\n * The style of the generated images. Must be one of vivid or natural.\n * Vivid causes the model to lean towards generating hyper-real and dramatic images.\n * Natural causes the model to produce more natural, less hyper-real looking images.\n * @default \"vivid\"\n */\n style?: \"natural\" | \"vivid\";\n /**\n * The quality of the image that will be generated. ‘hd’ creates images with finer\n * details and greater consistency across the image.\n * @default \"standard\"\n */\n quality?: \"standard\" | \"hd\";\n /**\n * The number of images to generate.\n * Must be between 1 and 10.\n * For dall-e-3, only `n: 1` is supported.\n * @default 1\n */\n n?: number;\n /**\n * The size of the generated images.\n * Must be one of 256x256, 512x512, or 1024x1024 for DALL·E-2 models.\n * Must be one of 1024x1024, 1792x1024, or 1024x1792 for DALL·E-3 models.\n * @default \"1024x1024\"\n */\n size?: \"256x256\" | \"512x512\" | \"1024x1024\" | \"1792x1024\" | \"1024x1792\";\n /**\n * The format in which the generated images are returned.\n * Must be one of \"url\" or \"b64_json\".\n * @default \"url\"\n */\n dallEResponseFormat?: \"url\" | \"b64_json\";\n /**\n * @deprecated Use dallEResponseFormat instead for the Dall-E response type.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n responseFormat?: any;\n /**\n * A unique identifier representing your end-user, which will help\n * OpenAI to monitor and detect abuse.\n */\n user?: string;\n /**\n * The organization to use\n */\n organization?: string;\n /**\n * The base URL of the OpenAI API.\n */\n baseUrl?: string;\n}\n\n/**\n * A tool for generating images with Open AIs Dall-E 2 or 3 API.\n */\nexport class DallEAPIWrapper extends Tool {\n static lc_name() {\n return \"DallEAPIWrapper\";\n }\n\n name = \"dalle_api_wrapper\";\n\n description =\n \"A wrapper around OpenAI DALL-E API. Useful for when you need to generate images from a text description. Input should be an image description.\";\n\n protected client: OpenAIClient;\n\n static readonly toolName = \"dalle_api_wrapper\";\n\n private model = \"dall-e-3\";\n\n private style: \"natural\" | \"vivid\" = \"vivid\";\n\n private quality: \"standard\" | \"hd\" = \"standard\";\n\n private n = 1;\n\n private size:\n | \"256x256\"\n | \"512x512\"\n | \"1024x1024\"\n | \"1792x1024\"\n | \"1024x1792\" = \"1024x1024\";\n\n private dallEResponseFormat: \"url\" | \"b64_json\" = \"url\";\n\n private user?: string;\n\n constructor(fields?: DallEAPIWrapperParams) {\n // Shim for new base tool param name\n if (\n fields?.responseFormat !== undefined &&\n [\"url\", \"b64_json\"].includes(fields.responseFormat)\n ) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n fields.dallEResponseFormat = fields.responseFormat as any;\n fields.responseFormat = \"content\";\n }\n super(fields);\n const openAIApiKey =\n fields?.apiKey ??\n fields?.openAIApiKey ??\n getEnvironmentVariable(\"OPENAI_API_KEY\");\n\n const organization =\n fields?.organization ?? getEnvironmentVariable(\"OPENAI_ORGANIZATION\");\n\n const clientConfig = {\n apiKey: openAIApiKey,\n organization,\n dangerouslyAllowBrowser: true,\n baseURL: fields?.baseUrl,\n };\n this.client = new OpenAIClient(clientConfig);\n this.model = fields?.model ?? fields?.modelName ?? this.model;\n this.style = fields?.style ?? this.style;\n this.quality = fields?.quality ?? this.quality;\n this.n = fields?.n ?? this.n;\n this.size = fields?.size ?? this.size;\n this.dallEResponseFormat =\n fields?.dallEResponseFormat ?? this.dallEResponseFormat;\n this.user = fields?.user;\n }\n\n /**\n * Processes the API response if multiple images are generated.\n * Returns a list of MessageContentImageUrl objects. If the response\n * format is `url`, then the `image_url` field will contain the URL.\n * If it is `b64_json`, then the `image_url` field will contain an object\n * with a `url` field with the base64 encoded image.\n *\n * @param {OpenAIClient.Images.ImagesResponse[]} response The API response\n * @returns {MessageContentImageUrl[]}\n */\n private processMultipleGeneratedUrls(\n response: OpenAIClient.Images.ImagesResponse[]\n ): MessageContentImageUrl[] {\n if (this.dallEResponseFormat === \"url\") {\n return response.flatMap((res) => {\n const imageUrlContent =\n res.data\n ?.flatMap((item) => {\n if (!item.url) return [];\n return {\n type: \"image_url\" as const,\n image_url: item.url,\n };\n })\n .filter(\n (item) =>\n item !== undefined &&\n item.type === \"image_url\" &&\n typeof item.image_url === \"string\" &&\n item.image_url !== undefined\n ) ?? [];\n return imageUrlContent;\n });\n } else {\n return response.flatMap((res) => {\n const b64Content =\n res.data\n ?.flatMap((item) => {\n if (!item.b64_json) return [];\n return {\n type: \"image_url\" as const,\n image_url: {\n url: item.b64_json,\n },\n };\n })\n .filter(\n (item) =>\n item !== undefined &&\n item.type === \"image_url\" &&\n typeof item.image_url === \"object\" &&\n \"url\" in item.image_url &&\n typeof item.image_url.url === \"string\" &&\n item.image_url.url !== undefined\n ) ?? [];\n return b64Content;\n });\n }\n }\n\n /** @ignore */\n async _call(input: string): Promise<string | MessageContentComplex[]> {\n const generateImageFields = {\n model: this.model,\n prompt: input,\n n: 1,\n size: this.size,\n response_format: this.dallEResponseFormat,\n style: this.style,\n quality: this.quality,\n user: this.user,\n };\n\n if (this.n > 1) {\n const results = await Promise.all(\n Array.from({ length: this.n }).map(() =>\n this.client.images.generate(generateImageFields)\n )\n );\n\n return this.processMultipleGeneratedUrls(results);\n }\n\n const response = await this.client.images.generate(generateImageFields);\n\n let data = \"\";\n if (this.dallEResponseFormat === \"url\") {\n [data] =\n response.data\n ?.map((item) => item.url)\n .filter((url): url is string => url !== \"undefined\") ?? [];\n } else {\n [data] =\n response.data\n ?.map((item) => item.b64_json)\n .filter((b64_json): b64_json is string => b64_json !== \"undefined\") ??\n [];\n }\n return data;\n }\n}\n"],"mappings":";;;;;;;AAkGA,IAAa,kBAAb,cAAqC,KAAK;CACxC,OAAO,UAAU;AACf,SAAO;;CAGT,OAAO;CAEP,cACE;CAEF;CAEA,OAAgB,WAAW;CAE3B,QAAgB;CAEhB,QAAqC;CAErC,UAAqC;CAErC,IAAY;CAEZ,OAKkB;CAElB,sBAAkD;CAElD;CAEA,YAAY,QAAgC;AAE1C,MACE,QAAQ,mBAAmB,KAAA,KAC3B,CAAC,OAAO,WAAW,CAAC,SAAS,OAAO,eAAe,EACnD;AAEA,UAAO,sBAAsB,OAAO;AACpC,UAAO,iBAAiB;;AAE1B,QAAM,OAAO;AAeb,OAAK,SAAS,IAAIA,OANG;GACnB,QARA,QAAQ,UACR,QAAQ,gBACR,uBAAuB,iBAAiB;GAOxC,cAJA,QAAQ,gBAAgB,uBAAuB,sBAAsB;GAKrE,yBAAyB;GACzB,SAAS,QAAQ;GAClB,CAC2C;AAC5C,OAAK,QAAQ,QAAQ,SAAS,QAAQ,aAAa,KAAK;AACxD,OAAK,QAAQ,QAAQ,SAAS,KAAK;AACnC,OAAK,UAAU,QAAQ,WAAW,KAAK;AACvC,OAAK,IAAI,QAAQ,KAAK,KAAK;AAC3B,OAAK,OAAO,QAAQ,QAAQ,KAAK;AACjC,OAAK,sBACH,QAAQ,uBAAuB,KAAK;AACtC,OAAK,OAAO,QAAQ;;;;;;;;;;;;CAatB,6BACE,UAC0B;AAC1B,MAAI,KAAK,wBAAwB,MAC/B,QAAO,SAAS,SAAS,QAAQ;AAiB/B,UAfE,IAAI,MACA,SAAS,SAAS;AAClB,QAAI,CAAC,KAAK,IAAK,QAAO,EAAE;AACxB,WAAO;KACL,MAAM;KACN,WAAW,KAAK;KACjB;KACD,CACD,QACE,SACC,SAAS,KAAA,KACT,KAAK,SAAS,eACd,OAAO,KAAK,cAAc,YAC1B,KAAK,cAAc,KAAA,EACtB,IAAI,EAAE;IAEX;MAEF,QAAO,SAAS,SAAS,QAAQ;AAqB/B,UAnBE,IAAI,MACA,SAAS,SAAS;AAClB,QAAI,CAAC,KAAK,SAAU,QAAO,EAAE;AAC7B,WAAO;KACL,MAAM;KACN,WAAW,EACT,KAAK,KAAK,UACX;KACF;KACD,CACD,QACE,SACC,SAAS,KAAA,KACT,KAAK,SAAS,eACd,OAAO,KAAK,cAAc,YAC1B,SAAS,KAAK,aACd,OAAO,KAAK,UAAU,QAAQ,YAC9B,KAAK,UAAU,QAAQ,KAAA,EAC1B,IAAI,EAAE;IAEX;;;CAKN,MAAM,MAAM,OAA0D;EACpE,MAAM,sBAAsB;GAC1B,OAAO,KAAK;GACZ,QAAQ;GACR,GAAG;GACH,MAAM,KAAK;GACX,iBAAiB,KAAK;GACtB,OAAO,KAAK;GACZ,SAAS,KAAK;GACd,MAAM,KAAK;GACZ;AAED,MAAI,KAAK,IAAI,GAAG;GACd,MAAM,UAAU,MAAM,QAAQ,IAC5B,MAAM,KAAK,EAAE,QAAQ,KAAK,GAAG,CAAC,CAAC,UAC7B,KAAK,OAAO,OAAO,SAAS,oBAAoB,CACjD,CACF;AAED,UAAO,KAAK,6BAA6B,QAAQ;;EAGnD,MAAM,WAAW,MAAM,KAAK,OAAO,OAAO,SAAS,oBAAoB;EAEvE,IAAI,OAAO;AACX,MAAI,KAAK,wBAAwB,MAC/B,EAAC,QACC,SAAS,MACL,KAAK,SAAS,KAAK,IAAI,CACxB,QAAQ,QAAuB,QAAQ,YAAY,IAAI,EAAE;MAE9D,EAAC,QACC,SAAS,MACL,KAAK,SAAS,KAAK,SAAS,CAC7B,QAAQ,aAAiC,aAAa,YAAY,IACrE,EAAE;AAEN,SAAO"}
@@ -1,4 +1,3 @@
1
-
2
1
  //#region src/tools/fileSearch.ts
3
2
  /**
4
3
  * Converts ranking options to the API format.
@@ -131,7 +130,7 @@ function fileSearch(options) {
131
130
  ranking_options: convertRankingOptions(options.rankingOptions)
132
131
  };
133
132
  }
134
-
135
133
  //#endregion
136
134
  exports.fileSearch = fileSearch;
135
+
137
136
  //# sourceMappingURL=fileSearch.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"fileSearch.cjs","names":[],"sources":["../../src/tools/fileSearch.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Comparison operators for file attribute filtering.\n */\nexport type FileSearchComparisonType =\n | \"eq\"\n | \"ne\"\n | \"gt\"\n | \"gte\"\n | \"lt\"\n | \"lte\";\n\n/**\n * A filter used to compare a specified attribute key to a given value.\n */\nexport interface FileSearchComparisonFilter {\n /**\n * The comparison operator to use.\n * - `eq`: equals\n * - `ne`: not equal\n * - `gt`: greater than\n * - `gte`: greater than or equal\n * - `lt`: less than\n * - `lte`: less than or equal\n */\n type: FileSearchComparisonType;\n /**\n * The attribute key to compare against.\n */\n key: string;\n /**\n * The value to compare against the attribute key.\n * Supports string, number, boolean, or array of strings/numbers.\n */\n value: string | number | boolean | Array<string | number>;\n}\n\n/**\n * Combine multiple filters using `and` or `or`.\n */\nexport interface FileSearchCompoundFilter {\n /**\n * Type of operation: `and` or `or`.\n */\n type: \"and\" | \"or\";\n /**\n * Array of filters to combine.\n */\n filters: Array<FileSearchComparisonFilter | FileSearchCompoundFilter>;\n}\n\n/**\n * Filter type for file search - can be a comparison or compound filter.\n */\nexport type FileSearchFilter =\n | FileSearchComparisonFilter\n | FileSearchCompoundFilter;\n\n/**\n * Weights for hybrid search balancing semantic and keyword matches.\n */\nexport interface FileSearchHybridSearchWeights {\n /**\n * The weight of semantic embedding matches (0-1).\n */\n embeddingWeight: number;\n /**\n * The weight of keyword/text matches (0-1).\n */\n textWeight: number;\n}\n\n/**\n * Ranking options for file search results.\n */\nexport interface FileSearchRankingOptions {\n /**\n * The ranker to use for the file search.\n * - `auto`: Automatically select the best ranker\n * - `default-2024-11-15`: Default ranker as of November 2024\n */\n ranker?: \"auto\" | \"default-2024-11-15\";\n /**\n * The score threshold for results (0-1).\n * Numbers closer to 1 return only the most relevant results but may return fewer.\n */\n scoreThreshold?: number;\n /**\n * Weights that control how reciprocal rank fusion balances semantic\n * embedding matches versus sparse keyword matches when hybrid search is enabled.\n */\n hybridSearch?: FileSearchHybridSearchWeights;\n}\n\n/**\n * Options for the File Search tool.\n */\nexport interface FileSearchOptions {\n /**\n * The IDs of the vector stores to search.\n * You must have previously created vector stores and uploaded files to them.\n */\n vectorStoreIds: string[];\n /**\n * The maximum number of results to return.\n * Must be between 1 and 50 inclusive.\n */\n maxNumResults?: number;\n /**\n * A filter to apply based on file attributes/metadata.\n * Use this to narrow down search results to specific categories or file types.\n */\n filters?: FileSearchFilter;\n /**\n * Ranking options to customize how results are scored and ordered.\n */\n rankingOptions?: FileSearchRankingOptions;\n}\n\n/**\n * OpenAI File Search tool type for the Responses API.\n */\nexport type FileSearchTool = OpenAIClient.Responses.FileSearchTool;\n\n/**\n * Converts ranking options to the API format.\n */\nfunction convertRankingOptions(\n options: FileSearchRankingOptions | undefined\n): OpenAIClient.Responses.FileSearchTool.RankingOptions | undefined {\n if (!options) return undefined;\n return {\n ranker: options.ranker,\n score_threshold: options.scoreThreshold,\n hybrid_search: options.hybridSearch\n ? {\n embedding_weight: options.hybridSearch.embeddingWeight,\n text_weight: options.hybridSearch.textWeight,\n }\n : undefined,\n };\n}\n\n/**\n * Creates a File Search tool that allows models to search your files\n * for relevant information using semantic and keyword search.\n *\n * File Search enables models to retrieve information from a knowledge base\n * of previously uploaded files stored in vector stores. This is a hosted tool\n * managed by OpenAI - you don't need to implement the search execution yourself.\n *\n * **Prerequisites**: Before using File Search, you must:\n * 1. Upload files to the File API with `purpose: \"assistants\"`\n * 2. Create a vector store\n * 3. Add files to the vector store\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-file-search | OpenAI File Search Documentation}\n *\n * @param options - Configuration options for the File Search tool\n * @returns A File Search tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-4.1\" });\n *\n * // Basic usage with a vector store\n * const response = await model.invoke(\n * \"What is deep research by OpenAI?\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"]\n * })]\n * }\n * );\n *\n * // Limit the number of results for lower latency\n * const response = await model.invoke(\n * \"Find information about pricing\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"],\n * maxNumResults: 5\n * })]\n * }\n * );\n *\n * // With metadata filtering\n * const response = await model.invoke(\n * \"Find recent blog posts about AI\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"],\n * filters: {\n * type: \"eq\",\n * key: \"category\",\n * value: \"blog\"\n * }\n * })]\n * }\n * );\n *\n * // With compound filters (AND/OR)\n * const response = await model.invoke(\n * \"Find technical docs from 2024\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"],\n * filters: {\n * type: \"and\",\n * filters: [\n * { type: \"eq\", key: \"category\", value: \"technical\" },\n * { type: \"gte\", key: \"year\", value: 2024 }\n * ]\n * }\n * })]\n * }\n * );\n *\n * // With ranking options for more relevant results\n * const response = await model.invoke(\n * \"Find the most relevant information\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"],\n * rankingOptions: {\n * scoreThreshold: 0.8,\n * ranker: \"auto\"\n * }\n * })]\n * }\n * );\n *\n * // Search multiple vector stores\n * const response = await model.invoke(\n * \"Search across all knowledge bases\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\", \"vs_def456\"]\n * })]\n * }\n * );\n * ```\n *\n * @remarks\n * - Vector stores must be created and populated before using this tool\n * - The tool returns file citations in the response annotations\n * - Use `include: [\"file_search_call.results\"]` in the API call to get search results\n * - Supported file types include PDF, DOCX, TXT, MD, and many code file formats\n */\nexport function fileSearch(options: FileSearchOptions): ServerTool {\n return {\n type: \"file_search\",\n vector_store_ids: options.vectorStoreIds,\n max_num_results: options.maxNumResults,\n filters: options.filters as FileSearchTool[\"filters\"],\n ranking_options: convertRankingOptions(options.rankingOptions),\n } satisfies FileSearchTool;\n}\n"],"mappings":";;;;;AAiIA,SAAS,sBACP,SACkE;AAClE,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO;EACL,QAAQ,QAAQ;EAChB,iBAAiB,QAAQ;EACzB,eAAe,QAAQ,eACnB;GACE,kBAAkB,QAAQ,aAAa;GACvC,aAAa,QAAQ,aAAa;GACnC,GACD;EACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+GH,SAAgB,WAAW,SAAwC;AACjE,QAAO;EACL,MAAM;EACN,kBAAkB,QAAQ;EAC1B,iBAAiB,QAAQ;EACzB,SAAS,QAAQ;EACjB,iBAAiB,sBAAsB,QAAQ,eAAe;EAC/D"}
1
+ {"version":3,"file":"fileSearch.cjs","names":[],"sources":["../../src/tools/fileSearch.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Comparison operators for file attribute filtering.\n */\nexport type FileSearchComparisonType =\n | \"eq\"\n | \"ne\"\n | \"gt\"\n | \"gte\"\n | \"lt\"\n | \"lte\";\n\n/**\n * A filter used to compare a specified attribute key to a given value.\n */\nexport interface FileSearchComparisonFilter {\n /**\n * The comparison operator to use.\n * - `eq`: equals\n * - `ne`: not equal\n * - `gt`: greater than\n * - `gte`: greater than or equal\n * - `lt`: less than\n * - `lte`: less than or equal\n */\n type: FileSearchComparisonType;\n /**\n * The attribute key to compare against.\n */\n key: string;\n /**\n * The value to compare against the attribute key.\n * Supports string, number, boolean, or array of strings/numbers.\n */\n value: string | number | boolean | Array<string | number>;\n}\n\n/**\n * Combine multiple filters using `and` or `or`.\n */\nexport interface FileSearchCompoundFilter {\n /**\n * Type of operation: `and` or `or`.\n */\n type: \"and\" | \"or\";\n /**\n * Array of filters to combine.\n */\n filters: Array<FileSearchComparisonFilter | FileSearchCompoundFilter>;\n}\n\n/**\n * Filter type for file search - can be a comparison or compound filter.\n */\nexport type FileSearchFilter =\n | FileSearchComparisonFilter\n | FileSearchCompoundFilter;\n\n/**\n * Weights for hybrid search balancing semantic and keyword matches.\n */\nexport interface FileSearchHybridSearchWeights {\n /**\n * The weight of semantic embedding matches (0-1).\n */\n embeddingWeight: number;\n /**\n * The weight of keyword/text matches (0-1).\n */\n textWeight: number;\n}\n\n/**\n * Ranking options for file search results.\n */\nexport interface FileSearchRankingOptions {\n /**\n * The ranker to use for the file search.\n * - `auto`: Automatically select the best ranker\n * - `default-2024-11-15`: Default ranker as of November 2024\n */\n ranker?: \"auto\" | \"default-2024-11-15\";\n /**\n * The score threshold for results (0-1).\n * Numbers closer to 1 return only the most relevant results but may return fewer.\n */\n scoreThreshold?: number;\n /**\n * Weights that control how reciprocal rank fusion balances semantic\n * embedding matches versus sparse keyword matches when hybrid search is enabled.\n */\n hybridSearch?: FileSearchHybridSearchWeights;\n}\n\n/**\n * Options for the File Search tool.\n */\nexport interface FileSearchOptions {\n /**\n * The IDs of the vector stores to search.\n * You must have previously created vector stores and uploaded files to them.\n */\n vectorStoreIds: string[];\n /**\n * The maximum number of results to return.\n * Must be between 1 and 50 inclusive.\n */\n maxNumResults?: number;\n /**\n * A filter to apply based on file attributes/metadata.\n * Use this to narrow down search results to specific categories or file types.\n */\n filters?: FileSearchFilter;\n /**\n * Ranking options to customize how results are scored and ordered.\n */\n rankingOptions?: FileSearchRankingOptions;\n}\n\n/**\n * OpenAI File Search tool type for the Responses API.\n */\nexport type FileSearchTool = OpenAIClient.Responses.FileSearchTool;\n\n/**\n * Converts ranking options to the API format.\n */\nfunction convertRankingOptions(\n options: FileSearchRankingOptions | undefined\n): OpenAIClient.Responses.FileSearchTool.RankingOptions | undefined {\n if (!options) return undefined;\n return {\n ranker: options.ranker,\n score_threshold: options.scoreThreshold,\n hybrid_search: options.hybridSearch\n ? {\n embedding_weight: options.hybridSearch.embeddingWeight,\n text_weight: options.hybridSearch.textWeight,\n }\n : undefined,\n };\n}\n\n/**\n * Creates a File Search tool that allows models to search your files\n * for relevant information using semantic and keyword search.\n *\n * File Search enables models to retrieve information from a knowledge base\n * of previously uploaded files stored in vector stores. This is a hosted tool\n * managed by OpenAI - you don't need to implement the search execution yourself.\n *\n * **Prerequisites**: Before using File Search, you must:\n * 1. Upload files to the File API with `purpose: \"assistants\"`\n * 2. Create a vector store\n * 3. Add files to the vector store\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-file-search | OpenAI File Search Documentation}\n *\n * @param options - Configuration options for the File Search tool\n * @returns A File Search tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-4.1\" });\n *\n * // Basic usage with a vector store\n * const response = await model.invoke(\n * \"What is deep research by OpenAI?\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"]\n * })]\n * }\n * );\n *\n * // Limit the number of results for lower latency\n * const response = await model.invoke(\n * \"Find information about pricing\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"],\n * maxNumResults: 5\n * })]\n * }\n * );\n *\n * // With metadata filtering\n * const response = await model.invoke(\n * \"Find recent blog posts about AI\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"],\n * filters: {\n * type: \"eq\",\n * key: \"category\",\n * value: \"blog\"\n * }\n * })]\n * }\n * );\n *\n * // With compound filters (AND/OR)\n * const response = await model.invoke(\n * \"Find technical docs from 2024\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"],\n * filters: {\n * type: \"and\",\n * filters: [\n * { type: \"eq\", key: \"category\", value: \"technical\" },\n * { type: \"gte\", key: \"year\", value: 2024 }\n * ]\n * }\n * })]\n * }\n * );\n *\n * // With ranking options for more relevant results\n * const response = await model.invoke(\n * \"Find the most relevant information\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"],\n * rankingOptions: {\n * scoreThreshold: 0.8,\n * ranker: \"auto\"\n * }\n * })]\n * }\n * );\n *\n * // Search multiple vector stores\n * const response = await model.invoke(\n * \"Search across all knowledge bases\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\", \"vs_def456\"]\n * })]\n * }\n * );\n * ```\n *\n * @remarks\n * - Vector stores must be created and populated before using this tool\n * - The tool returns file citations in the response annotations\n * - Use `include: [\"file_search_call.results\"]` in the API call to get search results\n * - Supported file types include PDF, DOCX, TXT, MD, and many code file formats\n */\nexport function fileSearch(options: FileSearchOptions): ServerTool {\n return {\n type: \"file_search\",\n vector_store_ids: options.vectorStoreIds,\n max_num_results: options.maxNumResults,\n filters: options.filters as FileSearchTool[\"filters\"],\n ranking_options: convertRankingOptions(options.rankingOptions),\n } satisfies FileSearchTool;\n}\n"],"mappings":";;;;AAiIA,SAAS,sBACP,SACkE;AAClE,KAAI,CAAC,QAAS,QAAO,KAAA;AACrB,QAAO;EACL,QAAQ,QAAQ;EAChB,iBAAiB,QAAQ;EACzB,eAAe,QAAQ,eACnB;GACE,kBAAkB,QAAQ,aAAa;GACvC,aAAa,QAAQ,aAAa;GACnC,GACD,KAAA;EACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+GH,SAAgB,WAAW,SAAwC;AACjE,QAAO;EACL,MAAM;EACN,kBAAkB,QAAQ;EAC1B,iBAAiB,QAAQ;EACzB,SAAS,QAAQ;EACjB,iBAAiB,sBAAsB,QAAQ,eAAe;EAC/D"}
@@ -1,4 +1,4 @@
1
- import { OpenAI as OpenAI$1 } from "openai";
1
+ import { OpenAI } from "openai";
2
2
  import { ServerTool } from "@langchain/core/tools";
3
3
 
4
4
  //#region src/tools/fileSearch.d.ts
@@ -108,7 +108,7 @@ interface FileSearchOptions {
108
108
  /**
109
109
  * OpenAI File Search tool type for the Responses API.
110
110
  */
111
- type FileSearchTool = OpenAI$1.Responses.FileSearchTool;
111
+ type FileSearchTool = OpenAI.Responses.FileSearchTool;
112
112
  /**
113
113
  * Creates a File Search tool that allows models to search your files
114
114
  * for relevant information using semantic and keyword search.
@@ -1 +1 @@
1
- {"version":3,"file":"fileSearch.d.cts","names":[],"sources":["../../src/tools/fileSearch.ts"],"mappings":";;;;;;AAMA;KAAY,wBAAA;;;;UAWK,0BAAA;EAA0B;;;;;;;;;EAUzC,IAAA,EAAM,wBAAA;EAeS;;;EAXf,GAAA;EAmB4C;;;;EAd5C,KAAA,8BAAmC,KAAA;AAAA;;;;UAMpB,wBAAA;EAQqD;AAMtE;;EAVE,IAAA;EAWE;;AAMJ;EAbE,OAAA,EAAS,KAAA,CAAM,0BAAA,GAA6B,wBAAA;AAAA;;;AA2B9C;KArBY,gBAAA,GACR,0BAAA,GACA,wBAAA;;;;UAKa,6BAAA;EA8Bf;;;EA1BA,eAAA;EAgCe;;;EA5Bf,UAAA;AAAA;;;;UAMe,wBAAA;EAyCE;;;AAMnB;;EAzCE,MAAA;EAyCgE;;;;EApChE,cAAA;EAoCgE;AAiIlE;;;EAhKE,YAAA,GAAe,6BAAA;AAAA;;;;UAMA,iBAAA;;;;;EAKf,cAAA;;;;;EAKA,aAAA;;;;;EAKA,OAAA,GAAU,gBAAA;;;;EAIV,cAAA,GAAiB,wBAAA;AAAA;;;;KAMP,cAAA,GAAiB,QAAA,CAAa,SAAA,CAAU,cAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiIpC,UAAA,CAAW,OAAA,EAAS,iBAAA,GAAoB,UAAA"}
1
+ {"version":3,"file":"fileSearch.d.cts","names":[],"sources":["../../src/tools/fileSearch.ts"],"mappings":";;;;;;AAMA;KAAY,wBAAA;;;;UAWK,0BAAA;EAA0B;;;;;;;;;EAUzC,IAAA,EAAM,wBAAA;EAeS;;;EAXf,GAAA;EAmB4C;;;;EAd5C,KAAA,8BAAmC,KAAA;AAAA;;;;UAMpB,wBAAA;EAQqD;AAMtE;;EAVE,IAAA;EAWE;;AAMJ;EAbE,OAAA,EAAS,KAAA,CAAM,0BAAA,GAA6B,wBAAA;AAAA;;;AA2B9C;KArBY,gBAAA,GACR,0BAAA,GACA,wBAAA;;;;UAKa,6BAAA;EA8Bf;;;EA1BA,eAAA;EAgCe;;;EA5Bf,UAAA;AAAA;;;;UAMe,wBAAA;EAyCE;;;AAMnB;;EAzCE,MAAA;EAyCgE;;;;EApChE,cAAA;EAoCgE;AAiIlE;;;EAhKE,YAAA,GAAe,6BAAA;AAAA;;;;UAMA,iBAAA;;;;;EAKf,cAAA;;;;;EAKA,aAAA;;;;;EAKA,OAAA,GAAU,gBAAA;;;;EAIV,cAAA,GAAiB,wBAAA;AAAA;;;;KAMP,cAAA,GAAiB,MAAA,CAAa,SAAA,CAAU,cAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiIpC,UAAA,CAAW,OAAA,EAAS,iBAAA,GAAoB,UAAA"}
@@ -1,4 +1,4 @@
1
- import { OpenAI as OpenAI$1 } from "openai";
1
+ import { OpenAI } from "openai";
2
2
  import { ServerTool } from "@langchain/core/tools";
3
3
 
4
4
  //#region src/tools/fileSearch.d.ts
@@ -108,7 +108,7 @@ interface FileSearchOptions {
108
108
  /**
109
109
  * OpenAI File Search tool type for the Responses API.
110
110
  */
111
- type FileSearchTool = OpenAI$1.Responses.FileSearchTool;
111
+ type FileSearchTool = OpenAI.Responses.FileSearchTool;
112
112
  /**
113
113
  * Creates a File Search tool that allows models to search your files
114
114
  * for relevant information using semantic and keyword search.
@@ -1 +1 @@
1
- {"version":3,"file":"fileSearch.d.ts","names":[],"sources":["../../src/tools/fileSearch.ts"],"mappings":";;;;;;AAMA;KAAY,wBAAA;;;;UAWK,0BAAA;EAA0B;;;;;;;;;EAUzC,IAAA,EAAM,wBAAA;EAeS;;;EAXf,GAAA;EAmB4C;;;;EAd5C,KAAA,8BAAmC,KAAA;AAAA;;;;UAMpB,wBAAA;EAQqD;AAMtE;;EAVE,IAAA;EAWE;;AAMJ;EAbE,OAAA,EAAS,KAAA,CAAM,0BAAA,GAA6B,wBAAA;AAAA;;;AA2B9C;KArBY,gBAAA,GACR,0BAAA,GACA,wBAAA;;;;UAKa,6BAAA;EA8Bf;;;EA1BA,eAAA;EAgCe;;;EA5Bf,UAAA;AAAA;;;;UAMe,wBAAA;EAyCE;;;AAMnB;;EAzCE,MAAA;EAyCgE;;;;EApChE,cAAA;EAoCgE;AAiIlE;;;EAhKE,YAAA,GAAe,6BAAA;AAAA;;;;UAMA,iBAAA;;;;;EAKf,cAAA;;;;;EAKA,aAAA;;;;;EAKA,OAAA,GAAU,gBAAA;;;;EAIV,cAAA,GAAiB,wBAAA;AAAA;;;;KAMP,cAAA,GAAiB,QAAA,CAAa,SAAA,CAAU,cAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiIpC,UAAA,CAAW,OAAA,EAAS,iBAAA,GAAoB,UAAA"}
1
+ {"version":3,"file":"fileSearch.d.ts","names":[],"sources":["../../src/tools/fileSearch.ts"],"mappings":";;;;;;AAMA;KAAY,wBAAA;;;;UAWK,0BAAA;EAA0B;;;;;;;;;EAUzC,IAAA,EAAM,wBAAA;EAeS;;;EAXf,GAAA;EAmB4C;;;;EAd5C,KAAA,8BAAmC,KAAA;AAAA;;;;UAMpB,wBAAA;EAQqD;AAMtE;;EAVE,IAAA;EAWE;;AAMJ;EAbE,OAAA,EAAS,KAAA,CAAM,0BAAA,GAA6B,wBAAA;AAAA;;;AA2B9C;KArBY,gBAAA,GACR,0BAAA,GACA,wBAAA;;;;UAKa,6BAAA;EA8Bf;;;EA1BA,eAAA;EAgCe;;;EA5Bf,UAAA;AAAA;;;;UAMe,wBAAA;EAyCE;;;AAMnB;;EAzCE,MAAA;EAyCgE;;;;EApChE,cAAA;EAoCgE;AAiIlE;;;EAhKE,YAAA,GAAe,6BAAA;AAAA;;;;UAMA,iBAAA;;;;;EAKf,cAAA;;;;;EAKA,aAAA;;;;;EAKA,OAAA,GAAU,gBAAA;;;;EAIV,cAAA,GAAiB,wBAAA;AAAA;;;;KAMP,cAAA,GAAiB,MAAA,CAAa,SAAA,CAAU,cAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiIpC,UAAA,CAAW,OAAA,EAAS,iBAAA,GAAoB,UAAA"}
@@ -130,7 +130,7 @@ function fileSearch(options) {
130
130
  ranking_options: convertRankingOptions(options.rankingOptions)
131
131
  };
132
132
  }
133
-
134
133
  //#endregion
135
134
  export { fileSearch };
135
+
136
136
  //# sourceMappingURL=fileSearch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fileSearch.js","names":[],"sources":["../../src/tools/fileSearch.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Comparison operators for file attribute filtering.\n */\nexport type FileSearchComparisonType =\n | \"eq\"\n | \"ne\"\n | \"gt\"\n | \"gte\"\n | \"lt\"\n | \"lte\";\n\n/**\n * A filter used to compare a specified attribute key to a given value.\n */\nexport interface FileSearchComparisonFilter {\n /**\n * The comparison operator to use.\n * - `eq`: equals\n * - `ne`: not equal\n * - `gt`: greater than\n * - `gte`: greater than or equal\n * - `lt`: less than\n * - `lte`: less than or equal\n */\n type: FileSearchComparisonType;\n /**\n * The attribute key to compare against.\n */\n key: string;\n /**\n * The value to compare against the attribute key.\n * Supports string, number, boolean, or array of strings/numbers.\n */\n value: string | number | boolean | Array<string | number>;\n}\n\n/**\n * Combine multiple filters using `and` or `or`.\n */\nexport interface FileSearchCompoundFilter {\n /**\n * Type of operation: `and` or `or`.\n */\n type: \"and\" | \"or\";\n /**\n * Array of filters to combine.\n */\n filters: Array<FileSearchComparisonFilter | FileSearchCompoundFilter>;\n}\n\n/**\n * Filter type for file search - can be a comparison or compound filter.\n */\nexport type FileSearchFilter =\n | FileSearchComparisonFilter\n | FileSearchCompoundFilter;\n\n/**\n * Weights for hybrid search balancing semantic and keyword matches.\n */\nexport interface FileSearchHybridSearchWeights {\n /**\n * The weight of semantic embedding matches (0-1).\n */\n embeddingWeight: number;\n /**\n * The weight of keyword/text matches (0-1).\n */\n textWeight: number;\n}\n\n/**\n * Ranking options for file search results.\n */\nexport interface FileSearchRankingOptions {\n /**\n * The ranker to use for the file search.\n * - `auto`: Automatically select the best ranker\n * - `default-2024-11-15`: Default ranker as of November 2024\n */\n ranker?: \"auto\" | \"default-2024-11-15\";\n /**\n * The score threshold for results (0-1).\n * Numbers closer to 1 return only the most relevant results but may return fewer.\n */\n scoreThreshold?: number;\n /**\n * Weights that control how reciprocal rank fusion balances semantic\n * embedding matches versus sparse keyword matches when hybrid search is enabled.\n */\n hybridSearch?: FileSearchHybridSearchWeights;\n}\n\n/**\n * Options for the File Search tool.\n */\nexport interface FileSearchOptions {\n /**\n * The IDs of the vector stores to search.\n * You must have previously created vector stores and uploaded files to them.\n */\n vectorStoreIds: string[];\n /**\n * The maximum number of results to return.\n * Must be between 1 and 50 inclusive.\n */\n maxNumResults?: number;\n /**\n * A filter to apply based on file attributes/metadata.\n * Use this to narrow down search results to specific categories or file types.\n */\n filters?: FileSearchFilter;\n /**\n * Ranking options to customize how results are scored and ordered.\n */\n rankingOptions?: FileSearchRankingOptions;\n}\n\n/**\n * OpenAI File Search tool type for the Responses API.\n */\nexport type FileSearchTool = OpenAIClient.Responses.FileSearchTool;\n\n/**\n * Converts ranking options to the API format.\n */\nfunction convertRankingOptions(\n options: FileSearchRankingOptions | undefined\n): OpenAIClient.Responses.FileSearchTool.RankingOptions | undefined {\n if (!options) return undefined;\n return {\n ranker: options.ranker,\n score_threshold: options.scoreThreshold,\n hybrid_search: options.hybridSearch\n ? {\n embedding_weight: options.hybridSearch.embeddingWeight,\n text_weight: options.hybridSearch.textWeight,\n }\n : undefined,\n };\n}\n\n/**\n * Creates a File Search tool that allows models to search your files\n * for relevant information using semantic and keyword search.\n *\n * File Search enables models to retrieve information from a knowledge base\n * of previously uploaded files stored in vector stores. This is a hosted tool\n * managed by OpenAI - you don't need to implement the search execution yourself.\n *\n * **Prerequisites**: Before using File Search, you must:\n * 1. Upload files to the File API with `purpose: \"assistants\"`\n * 2. Create a vector store\n * 3. Add files to the vector store\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-file-search | OpenAI File Search Documentation}\n *\n * @param options - Configuration options for the File Search tool\n * @returns A File Search tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-4.1\" });\n *\n * // Basic usage with a vector store\n * const response = await model.invoke(\n * \"What is deep research by OpenAI?\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"]\n * })]\n * }\n * );\n *\n * // Limit the number of results for lower latency\n * const response = await model.invoke(\n * \"Find information about pricing\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"],\n * maxNumResults: 5\n * })]\n * }\n * );\n *\n * // With metadata filtering\n * const response = await model.invoke(\n * \"Find recent blog posts about AI\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"],\n * filters: {\n * type: \"eq\",\n * key: \"category\",\n * value: \"blog\"\n * }\n * })]\n * }\n * );\n *\n * // With compound filters (AND/OR)\n * const response = await model.invoke(\n * \"Find technical docs from 2024\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"],\n * filters: {\n * type: \"and\",\n * filters: [\n * { type: \"eq\", key: \"category\", value: \"technical\" },\n * { type: \"gte\", key: \"year\", value: 2024 }\n * ]\n * }\n * })]\n * }\n * );\n *\n * // With ranking options for more relevant results\n * const response = await model.invoke(\n * \"Find the most relevant information\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"],\n * rankingOptions: {\n * scoreThreshold: 0.8,\n * ranker: \"auto\"\n * }\n * })]\n * }\n * );\n *\n * // Search multiple vector stores\n * const response = await model.invoke(\n * \"Search across all knowledge bases\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\", \"vs_def456\"]\n * })]\n * }\n * );\n * ```\n *\n * @remarks\n * - Vector stores must be created and populated before using this tool\n * - The tool returns file citations in the response annotations\n * - Use `include: [\"file_search_call.results\"]` in the API call to get search results\n * - Supported file types include PDF, DOCX, TXT, MD, and many code file formats\n */\nexport function fileSearch(options: FileSearchOptions): ServerTool {\n return {\n type: \"file_search\",\n vector_store_ids: options.vectorStoreIds,\n max_num_results: options.maxNumResults,\n filters: options.filters as FileSearchTool[\"filters\"],\n ranking_options: convertRankingOptions(options.rankingOptions),\n } satisfies FileSearchTool;\n}\n"],"mappings":";;;;AAiIA,SAAS,sBACP,SACkE;AAClE,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO;EACL,QAAQ,QAAQ;EAChB,iBAAiB,QAAQ;EACzB,eAAe,QAAQ,eACnB;GACE,kBAAkB,QAAQ,aAAa;GACvC,aAAa,QAAQ,aAAa;GACnC,GACD;EACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+GH,SAAgB,WAAW,SAAwC;AACjE,QAAO;EACL,MAAM;EACN,kBAAkB,QAAQ;EAC1B,iBAAiB,QAAQ;EACzB,SAAS,QAAQ;EACjB,iBAAiB,sBAAsB,QAAQ,eAAe;EAC/D"}
1
+ {"version":3,"file":"fileSearch.js","names":[],"sources":["../../src/tools/fileSearch.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Comparison operators for file attribute filtering.\n */\nexport type FileSearchComparisonType =\n | \"eq\"\n | \"ne\"\n | \"gt\"\n | \"gte\"\n | \"lt\"\n | \"lte\";\n\n/**\n * A filter used to compare a specified attribute key to a given value.\n */\nexport interface FileSearchComparisonFilter {\n /**\n * The comparison operator to use.\n * - `eq`: equals\n * - `ne`: not equal\n * - `gt`: greater than\n * - `gte`: greater than or equal\n * - `lt`: less than\n * - `lte`: less than or equal\n */\n type: FileSearchComparisonType;\n /**\n * The attribute key to compare against.\n */\n key: string;\n /**\n * The value to compare against the attribute key.\n * Supports string, number, boolean, or array of strings/numbers.\n */\n value: string | number | boolean | Array<string | number>;\n}\n\n/**\n * Combine multiple filters using `and` or `or`.\n */\nexport interface FileSearchCompoundFilter {\n /**\n * Type of operation: `and` or `or`.\n */\n type: \"and\" | \"or\";\n /**\n * Array of filters to combine.\n */\n filters: Array<FileSearchComparisonFilter | FileSearchCompoundFilter>;\n}\n\n/**\n * Filter type for file search - can be a comparison or compound filter.\n */\nexport type FileSearchFilter =\n | FileSearchComparisonFilter\n | FileSearchCompoundFilter;\n\n/**\n * Weights for hybrid search balancing semantic and keyword matches.\n */\nexport interface FileSearchHybridSearchWeights {\n /**\n * The weight of semantic embedding matches (0-1).\n */\n embeddingWeight: number;\n /**\n * The weight of keyword/text matches (0-1).\n */\n textWeight: number;\n}\n\n/**\n * Ranking options for file search results.\n */\nexport interface FileSearchRankingOptions {\n /**\n * The ranker to use for the file search.\n * - `auto`: Automatically select the best ranker\n * - `default-2024-11-15`: Default ranker as of November 2024\n */\n ranker?: \"auto\" | \"default-2024-11-15\";\n /**\n * The score threshold for results (0-1).\n * Numbers closer to 1 return only the most relevant results but may return fewer.\n */\n scoreThreshold?: number;\n /**\n * Weights that control how reciprocal rank fusion balances semantic\n * embedding matches versus sparse keyword matches when hybrid search is enabled.\n */\n hybridSearch?: FileSearchHybridSearchWeights;\n}\n\n/**\n * Options for the File Search tool.\n */\nexport interface FileSearchOptions {\n /**\n * The IDs of the vector stores to search.\n * You must have previously created vector stores and uploaded files to them.\n */\n vectorStoreIds: string[];\n /**\n * The maximum number of results to return.\n * Must be between 1 and 50 inclusive.\n */\n maxNumResults?: number;\n /**\n * A filter to apply based on file attributes/metadata.\n * Use this to narrow down search results to specific categories or file types.\n */\n filters?: FileSearchFilter;\n /**\n * Ranking options to customize how results are scored and ordered.\n */\n rankingOptions?: FileSearchRankingOptions;\n}\n\n/**\n * OpenAI File Search tool type for the Responses API.\n */\nexport type FileSearchTool = OpenAIClient.Responses.FileSearchTool;\n\n/**\n * Converts ranking options to the API format.\n */\nfunction convertRankingOptions(\n options: FileSearchRankingOptions | undefined\n): OpenAIClient.Responses.FileSearchTool.RankingOptions | undefined {\n if (!options) return undefined;\n return {\n ranker: options.ranker,\n score_threshold: options.scoreThreshold,\n hybrid_search: options.hybridSearch\n ? {\n embedding_weight: options.hybridSearch.embeddingWeight,\n text_weight: options.hybridSearch.textWeight,\n }\n : undefined,\n };\n}\n\n/**\n * Creates a File Search tool that allows models to search your files\n * for relevant information using semantic and keyword search.\n *\n * File Search enables models to retrieve information from a knowledge base\n * of previously uploaded files stored in vector stores. This is a hosted tool\n * managed by OpenAI - you don't need to implement the search execution yourself.\n *\n * **Prerequisites**: Before using File Search, you must:\n * 1. Upload files to the File API with `purpose: \"assistants\"`\n * 2. Create a vector store\n * 3. Add files to the vector store\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-file-search | OpenAI File Search Documentation}\n *\n * @param options - Configuration options for the File Search tool\n * @returns A File Search tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-4.1\" });\n *\n * // Basic usage with a vector store\n * const response = await model.invoke(\n * \"What is deep research by OpenAI?\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"]\n * })]\n * }\n * );\n *\n * // Limit the number of results for lower latency\n * const response = await model.invoke(\n * \"Find information about pricing\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"],\n * maxNumResults: 5\n * })]\n * }\n * );\n *\n * // With metadata filtering\n * const response = await model.invoke(\n * \"Find recent blog posts about AI\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"],\n * filters: {\n * type: \"eq\",\n * key: \"category\",\n * value: \"blog\"\n * }\n * })]\n * }\n * );\n *\n * // With compound filters (AND/OR)\n * const response = await model.invoke(\n * \"Find technical docs from 2024\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"],\n * filters: {\n * type: \"and\",\n * filters: [\n * { type: \"eq\", key: \"category\", value: \"technical\" },\n * { type: \"gte\", key: \"year\", value: 2024 }\n * ]\n * }\n * })]\n * }\n * );\n *\n * // With ranking options for more relevant results\n * const response = await model.invoke(\n * \"Find the most relevant information\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"],\n * rankingOptions: {\n * scoreThreshold: 0.8,\n * ranker: \"auto\"\n * }\n * })]\n * }\n * );\n *\n * // Search multiple vector stores\n * const response = await model.invoke(\n * \"Search across all knowledge bases\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\", \"vs_def456\"]\n * })]\n * }\n * );\n * ```\n *\n * @remarks\n * - Vector stores must be created and populated before using this tool\n * - The tool returns file citations in the response annotations\n * - Use `include: [\"file_search_call.results\"]` in the API call to get search results\n * - Supported file types include PDF, DOCX, TXT, MD, and many code file formats\n */\nexport function fileSearch(options: FileSearchOptions): ServerTool {\n return {\n type: \"file_search\",\n vector_store_ids: options.vectorStoreIds,\n max_num_results: options.maxNumResults,\n filters: options.filters as FileSearchTool[\"filters\"],\n ranking_options: convertRankingOptions(options.rankingOptions),\n } satisfies FileSearchTool;\n}\n"],"mappings":";;;;AAiIA,SAAS,sBACP,SACkE;AAClE,KAAI,CAAC,QAAS,QAAO,KAAA;AACrB,QAAO;EACL,QAAQ,QAAQ;EAChB,iBAAiB,QAAQ;EACzB,eAAe,QAAQ,eACnB;GACE,kBAAkB,QAAQ,aAAa;GACvC,aAAa,QAAQ,aAAa;GACnC,GACD,KAAA;EACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+GH,SAAgB,WAAW,SAAwC;AACjE,QAAO;EACL,MAAM;EACN,kBAAkB,QAAQ;EAC1B,iBAAiB,QAAQ;EACzB,SAAS,QAAQ;EACjB,iBAAiB,sBAAsB,QAAQ,eAAe;EAC/D"}
@@ -1,4 +1,3 @@
1
-
2
1
  //#region src/tools/imageGeneration.ts
3
2
  /**
4
3
  * Converts input mask options to the API format.
@@ -123,7 +122,7 @@ function imageGeneration(options) {
123
122
  size: options?.size
124
123
  };
125
124
  }
126
-
127
125
  //#endregion
128
126
  exports.imageGeneration = imageGeneration;
127
+
129
128
  //# sourceMappingURL=imageGeneration.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"imageGeneration.cjs","names":[],"sources":["../../src/tools/imageGeneration.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Optional mask for inpainting. Allows you to specify areas of the image\n * that should be regenerated.\n */\nexport interface ImageGenerationInputMask {\n /**\n * Base64-encoded mask image URL.\n */\n imageUrl?: string;\n /**\n * File ID for the mask image (uploaded via OpenAI File API).\n */\n fileId?: string;\n}\n\n/**\n * Options for the Image Generation tool.\n */\nexport interface ImageGenerationOptions {\n /**\n * Whether to generate a new image or edit an existing image.\n * - `generate`: Generate a new image from scratch\n * - `edit`: Edit an existing image\n * - `auto`: Let the model decide based on the input\n * @default \"auto\"\n */\n action?: \"generate\" | \"edit\" | \"auto\";\n\n /**\n * Background type for the generated image.\n * - `transparent`: Generate image with transparent background\n * - `opaque`: Generate image with opaque background\n * - `auto`: Let the model decide based on the prompt\n * @default \"auto\"\n */\n background?: \"transparent\" | \"opaque\" | \"auto\";\n\n /**\n * Control how much effort the model will exert to match the style and features,\n * especially facial features, of input images. This parameter is only supported\n * for `gpt-image-1`. Unsupported for `gpt-image-1-mini`.\n * - `high`: Higher fidelity to input images\n * - `low`: Lower fidelity to input images\n * @default \"low\"\n */\n inputFidelity?: \"high\" | \"low\";\n\n /**\n * Optional mask for inpainting. Use this to specify areas of an image\n * that should be regenerated.\n */\n inputImageMask?: ImageGenerationInputMask;\n\n /**\n * The image generation model to use.\n * @default \"gpt-image-1\"\n */\n model?: \"gpt-image-1\" | \"gpt-image-1-mini\" | \"gpt-image-1.5\";\n\n /**\n * Moderation level for the generated image.\n * - `auto`: Standard moderation\n * - `low`: Less restrictive moderation\n * @default \"auto\"\n */\n moderation?: \"auto\" | \"low\";\n\n /**\n * Compression level for the output image (0-100).\n * Only applies to JPEG and WebP formats.\n * @default 100\n */\n outputCompression?: number;\n\n /**\n * The output format of the generated image.\n * @default \"png\"\n */\n outputFormat?: \"png\" | \"webp\" | \"jpeg\";\n\n /**\n * Number of partial images to generate in streaming mode (0-3).\n * When set, the model will return partial images as they are generated,\n * providing faster visual feedback.\n * @default 0\n */\n partialImages?: number;\n\n /**\n * The quality of the generated image.\n * - `low`: Faster generation, lower quality\n * - `medium`: Balanced generation time and quality\n * - `high`: Slower generation, higher quality\n * - `auto`: Let the model decide based on the prompt\n * @default \"auto\"\n */\n quality?: \"low\" | \"medium\" | \"high\" | \"auto\";\n\n /**\n * The size of the generated image.\n * - `1024x1024`: Square format\n * - `1024x1536`: Portrait format\n * - `1536x1024`: Landscape format\n * - `auto`: Let the model decide based on the prompt\n * @default \"auto\"\n */\n size?: \"1024x1024\" | \"1024x1536\" | \"1536x1024\" | \"auto\";\n}\n\n/**\n * OpenAI Image Generation tool type for the Responses API.\n */\nexport type ImageGenerationTool = OpenAIClient.Responses.Tool.ImageGeneration;\n\n/**\n * Converts input mask options to the API format.\n */\nfunction convertInputImageMask(\n mask: ImageGenerationInputMask | undefined\n): ImageGenerationTool[\"input_image_mask\"] {\n if (!mask) return undefined;\n return {\n image_url: mask.imageUrl,\n file_id: mask.fileId,\n };\n}\n\n/**\n * Creates an Image Generation tool that allows models to generate or edit images\n * using text prompts and optional image inputs.\n *\n * The image generation tool leverages the GPT Image model and automatically\n * optimizes text inputs for improved performance. When included in a request,\n * the model can decide when and how to generate images as part of the conversation.\n *\n * **Key Features**:\n * - Generate images from text descriptions\n * - Edit existing images with text instructions\n * - Multi-turn image editing by referencing previous responses\n * - Configurable output options (size, quality, format)\n * - Streaming support for partial image generation\n *\n * **Prompting Tips**:\n * - Use terms like \"draw\" or \"edit\" in your prompt for best results\n * - For combining images, say \"edit the first image by adding this element\" instead of \"combine\"\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-image-generation | OpenAI Image Generation Documentation}\n *\n * @param options - Configuration options for the Image Generation tool\n * @returns An Image Generation tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-4o\" });\n *\n * // Basic usage - generate an image\n * const response = await model.invoke(\n * \"Generate an image of a gray tabby cat hugging an otter with an orange scarf\",\n * { tools: [tools.imageGeneration()] }\n * );\n *\n * // Access the generated image\n * const imageData = response.additional_kwargs.tool_outputs?.find(\n * (output) => output.type === \"image_generation_call\"\n * );\n * if (imageData?.result) {\n * // imageData.result contains the base64-encoded image\n * const fs = await import(\"fs\");\n * fs.writeFileSync(\"output.png\", Buffer.from(imageData.result, \"base64\"));\n * }\n *\n * // With custom options\n * const response = await model.invoke(\n * \"Draw a beautiful sunset over mountains\",\n * {\n * tools: [tools.imageGeneration({\n * size: \"1536x1024\", // Landscape format\n * quality: \"high\", // Higher quality output\n * outputFormat: \"jpeg\", // JPEG format\n * outputCompression: 90, // 90% compression\n * })]\n * }\n * );\n *\n * // With transparent background\n * const response = await model.invoke(\n * \"Create a logo with a transparent background\",\n * {\n * tools: [tools.imageGeneration({\n * background: \"transparent\",\n * outputFormat: \"png\",\n * })]\n * }\n * );\n *\n * // Force the model to use image generation\n * const response = await model.invoke(\n * \"A serene lake at dawn\",\n * {\n * tools: [tools.imageGeneration()],\n * tool_choice: { type: \"image_generation\" },\n * }\n * );\n *\n * // Enable streaming with partial images\n * const response = await model.invoke(\n * \"Draw a detailed fantasy castle\",\n * {\n * tools: [tools.imageGeneration({\n * partialImages: 2, // Get 2 partial images during generation\n * })]\n * }\n * );\n * ```\n *\n * @remarks\n * - Supported models: gpt-4o, gpt-4o-mini, gpt-4.1, gpt-4.1-mini, gpt-4.1-nano, o3\n * - The image generation process always uses `gpt-image-1` model internally\n * - The model will automatically revise prompts for improved performance\n * - Access the revised prompt via `revised_prompt` field in the output\n * - Multi-turn editing is supported by passing previous response messages\n */\nexport function imageGeneration(options?: ImageGenerationOptions): ServerTool {\n return {\n type: \"image_generation\",\n action: options?.action,\n background: options?.background,\n input_fidelity: options?.inputFidelity,\n input_image_mask: convertInputImageMask(options?.inputImageMask),\n model: options?.model,\n moderation: options?.moderation,\n output_compression: options?.outputCompression,\n output_format: options?.outputFormat,\n partial_images: options?.partialImages,\n quality: options?.quality,\n size: options?.size,\n } satisfies ImageGenerationTool;\n}\n"],"mappings":";;;;;AAwHA,SAAS,sBACP,MACyC;AACzC,KAAI,CAAC,KAAM,QAAO;AAClB,QAAO;EACL,WAAW,KAAK;EAChB,SAAS,KAAK;EACf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoGH,SAAgB,gBAAgB,SAA8C;AAC5E,QAAO;EACL,MAAM;EACN,QAAQ,SAAS;EACjB,YAAY,SAAS;EACrB,gBAAgB,SAAS;EACzB,kBAAkB,sBAAsB,SAAS,eAAe;EAChE,OAAO,SAAS;EAChB,YAAY,SAAS;EACrB,oBAAoB,SAAS;EAC7B,eAAe,SAAS;EACxB,gBAAgB,SAAS;EACzB,SAAS,SAAS;EAClB,MAAM,SAAS;EAChB"}
1
+ {"version":3,"file":"imageGeneration.cjs","names":[],"sources":["../../src/tools/imageGeneration.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Optional mask for inpainting. Allows you to specify areas of the image\n * that should be regenerated.\n */\nexport interface ImageGenerationInputMask {\n /**\n * Base64-encoded mask image URL.\n */\n imageUrl?: string;\n /**\n * File ID for the mask image (uploaded via OpenAI File API).\n */\n fileId?: string;\n}\n\n/**\n * Options for the Image Generation tool.\n */\nexport interface ImageGenerationOptions {\n /**\n * Whether to generate a new image or edit an existing image.\n * - `generate`: Generate a new image from scratch\n * - `edit`: Edit an existing image\n * - `auto`: Let the model decide based on the input\n * @default \"auto\"\n */\n action?: \"generate\" | \"edit\" | \"auto\";\n\n /**\n * Background type for the generated image.\n * - `transparent`: Generate image with transparent background\n * - `opaque`: Generate image with opaque background\n * - `auto`: Let the model decide based on the prompt\n * @default \"auto\"\n */\n background?: \"transparent\" | \"opaque\" | \"auto\";\n\n /**\n * Control how much effort the model will exert to match the style and features,\n * especially facial features, of input images. This parameter is only supported\n * for `gpt-image-1`. Unsupported for `gpt-image-1-mini`.\n * - `high`: Higher fidelity to input images\n * - `low`: Lower fidelity to input images\n * @default \"low\"\n */\n inputFidelity?: \"high\" | \"low\";\n\n /**\n * Optional mask for inpainting. Use this to specify areas of an image\n * that should be regenerated.\n */\n inputImageMask?: ImageGenerationInputMask;\n\n /**\n * The image generation model to use.\n * @default \"gpt-image-1\"\n */\n model?: \"gpt-image-1\" | \"gpt-image-1-mini\" | \"gpt-image-1.5\";\n\n /**\n * Moderation level for the generated image.\n * - `auto`: Standard moderation\n * - `low`: Less restrictive moderation\n * @default \"auto\"\n */\n moderation?: \"auto\" | \"low\";\n\n /**\n * Compression level for the output image (0-100).\n * Only applies to JPEG and WebP formats.\n * @default 100\n */\n outputCompression?: number;\n\n /**\n * The output format of the generated image.\n * @default \"png\"\n */\n outputFormat?: \"png\" | \"webp\" | \"jpeg\";\n\n /**\n * Number of partial images to generate in streaming mode (0-3).\n * When set, the model will return partial images as they are generated,\n * providing faster visual feedback.\n * @default 0\n */\n partialImages?: number;\n\n /**\n * The quality of the generated image.\n * - `low`: Faster generation, lower quality\n * - `medium`: Balanced generation time and quality\n * - `high`: Slower generation, higher quality\n * - `auto`: Let the model decide based on the prompt\n * @default \"auto\"\n */\n quality?: \"low\" | \"medium\" | \"high\" | \"auto\";\n\n /**\n * The size of the generated image.\n * - `1024x1024`: Square format\n * - `1024x1536`: Portrait format\n * - `1536x1024`: Landscape format\n * - `auto`: Let the model decide based on the prompt\n * @default \"auto\"\n */\n size?: \"1024x1024\" | \"1024x1536\" | \"1536x1024\" | \"auto\";\n}\n\n/**\n * OpenAI Image Generation tool type for the Responses API.\n */\nexport type ImageGenerationTool = OpenAIClient.Responses.Tool.ImageGeneration;\n\n/**\n * Converts input mask options to the API format.\n */\nfunction convertInputImageMask(\n mask: ImageGenerationInputMask | undefined\n): ImageGenerationTool[\"input_image_mask\"] {\n if (!mask) return undefined;\n return {\n image_url: mask.imageUrl,\n file_id: mask.fileId,\n };\n}\n\n/**\n * Creates an Image Generation tool that allows models to generate or edit images\n * using text prompts and optional image inputs.\n *\n * The image generation tool leverages the GPT Image model and automatically\n * optimizes text inputs for improved performance. When included in a request,\n * the model can decide when and how to generate images as part of the conversation.\n *\n * **Key Features**:\n * - Generate images from text descriptions\n * - Edit existing images with text instructions\n * - Multi-turn image editing by referencing previous responses\n * - Configurable output options (size, quality, format)\n * - Streaming support for partial image generation\n *\n * **Prompting Tips**:\n * - Use terms like \"draw\" or \"edit\" in your prompt for best results\n * - For combining images, say \"edit the first image by adding this element\" instead of \"combine\"\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-image-generation | OpenAI Image Generation Documentation}\n *\n * @param options - Configuration options for the Image Generation tool\n * @returns An Image Generation tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-4o\" });\n *\n * // Basic usage - generate an image\n * const response = await model.invoke(\n * \"Generate an image of a gray tabby cat hugging an otter with an orange scarf\",\n * { tools: [tools.imageGeneration()] }\n * );\n *\n * // Access the generated image\n * const imageData = response.additional_kwargs.tool_outputs?.find(\n * (output) => output.type === \"image_generation_call\"\n * );\n * if (imageData?.result) {\n * // imageData.result contains the base64-encoded image\n * const fs = await import(\"fs\");\n * fs.writeFileSync(\"output.png\", Buffer.from(imageData.result, \"base64\"));\n * }\n *\n * // With custom options\n * const response = await model.invoke(\n * \"Draw a beautiful sunset over mountains\",\n * {\n * tools: [tools.imageGeneration({\n * size: \"1536x1024\", // Landscape format\n * quality: \"high\", // Higher quality output\n * outputFormat: \"jpeg\", // JPEG format\n * outputCompression: 90, // 90% compression\n * })]\n * }\n * );\n *\n * // With transparent background\n * const response = await model.invoke(\n * \"Create a logo with a transparent background\",\n * {\n * tools: [tools.imageGeneration({\n * background: \"transparent\",\n * outputFormat: \"png\",\n * })]\n * }\n * );\n *\n * // Force the model to use image generation\n * const response = await model.invoke(\n * \"A serene lake at dawn\",\n * {\n * tools: [tools.imageGeneration()],\n * tool_choice: { type: \"image_generation\" },\n * }\n * );\n *\n * // Enable streaming with partial images\n * const response = await model.invoke(\n * \"Draw a detailed fantasy castle\",\n * {\n * tools: [tools.imageGeneration({\n * partialImages: 2, // Get 2 partial images during generation\n * })]\n * }\n * );\n * ```\n *\n * @remarks\n * - Supported models: gpt-4o, gpt-4o-mini, gpt-4.1, gpt-4.1-mini, gpt-4.1-nano, o3\n * - The image generation process always uses `gpt-image-1` model internally\n * - The model will automatically revise prompts for improved performance\n * - Access the revised prompt via `revised_prompt` field in the output\n * - Multi-turn editing is supported by passing previous response messages\n */\nexport function imageGeneration(options?: ImageGenerationOptions): ServerTool {\n return {\n type: \"image_generation\",\n action: options?.action,\n background: options?.background,\n input_fidelity: options?.inputFidelity,\n input_image_mask: convertInputImageMask(options?.inputImageMask),\n model: options?.model,\n moderation: options?.moderation,\n output_compression: options?.outputCompression,\n output_format: options?.outputFormat,\n partial_images: options?.partialImages,\n quality: options?.quality,\n size: options?.size,\n } satisfies ImageGenerationTool;\n}\n"],"mappings":";;;;AAwHA,SAAS,sBACP,MACyC;AACzC,KAAI,CAAC,KAAM,QAAO,KAAA;AAClB,QAAO;EACL,WAAW,KAAK;EAChB,SAAS,KAAK;EACf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoGH,SAAgB,gBAAgB,SAA8C;AAC5E,QAAO;EACL,MAAM;EACN,QAAQ,SAAS;EACjB,YAAY,SAAS;EACrB,gBAAgB,SAAS;EACzB,kBAAkB,sBAAsB,SAAS,eAAe;EAChE,OAAO,SAAS;EAChB,YAAY,SAAS;EACrB,oBAAoB,SAAS;EAC7B,eAAe,SAAS;EACxB,gBAAgB,SAAS;EACzB,SAAS,SAAS;EAClB,MAAM,SAAS;EAChB"}
@@ -1,4 +1,4 @@
1
- import { OpenAI as OpenAI$1 } from "openai";
1
+ import { OpenAI } from "openai";
2
2
  import { ServerTool } from "@langchain/core/tools";
3
3
 
4
4
  //#region src/tools/imageGeneration.d.ts
@@ -102,7 +102,7 @@ interface ImageGenerationOptions {
102
102
  /**
103
103
  * OpenAI Image Generation tool type for the Responses API.
104
104
  */
105
- type ImageGenerationTool = OpenAI$1.Responses.Tool.ImageGeneration;
105
+ type ImageGenerationTool = OpenAI.Responses.Tool.ImageGeneration;
106
106
  /**
107
107
  * Creates an Image Generation tool that allows models to generate or edit images
108
108
  * using text prompts and optional image inputs.
@@ -1 +1 @@
1
- {"version":3,"file":"imageGeneration.d.cts","names":[],"sources":["../../src/tools/imageGeneration.ts"],"mappings":";;;;;;AAOA;;UAAiB,wBAAA;EAIf;;AAUF;EAVE,QAAA;;;;EAIA,MAAA;AAAA;;;;UAMe,sBAAA;EAsDf;;;;;;;EA9CA,MAAA;EAsF6B;;;;;;;EA7E7B,UAAA;EA6E2E;AAgH7E;;;;;;;EAnLE,aAAA;EAmL2E;;;;EA7K3E,cAAA,GAAiB,wBAAA;;;;;EAMjB,KAAA;;;;;;;EAQA,UAAA;;;;;;EAOA,iBAAA;;;;;EAMA,YAAA;;;;;;;EAQA,aAAA;;;;;;;;;EAUA,OAAA;;;;;;;;;EAUA,IAAA;AAAA;;;;KAMU,mBAAA,GAAsB,QAAA,CAAa,SAAA,CAAU,IAAA,CAAK,eAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgH9C,eAAA,CAAgB,OAAA,GAAU,sBAAA,GAAyB,UAAA"}
1
+ {"version":3,"file":"imageGeneration.d.cts","names":[],"sources":["../../src/tools/imageGeneration.ts"],"mappings":";;;;;;AAOA;;UAAiB,wBAAA;EAIf;;AAUF;EAVE,QAAA;;;;EAIA,MAAA;AAAA;;;;UAMe,sBAAA;EAsDf;;;;;;;EA9CA,MAAA;EAsF6B;;;;;;;EA7E7B,UAAA;EA6E2E;AAgH7E;;;;;;;EAnLE,aAAA;EAmL2E;;;;EA7K3E,cAAA,GAAiB,wBAAA;;;;;EAMjB,KAAA;;;;;;;EAQA,UAAA;;;;;;EAOA,iBAAA;;;;;EAMA,YAAA;;;;;;;EAQA,aAAA;;;;;;;;;EAUA,OAAA;;;;;;;;;EAUA,IAAA;AAAA;;;;KAMU,mBAAA,GAAsB,MAAA,CAAa,SAAA,CAAU,IAAA,CAAK,eAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgH9C,eAAA,CAAgB,OAAA,GAAU,sBAAA,GAAyB,UAAA"}
@@ -1,4 +1,4 @@
1
- import { OpenAI as OpenAI$1 } from "openai";
1
+ import { OpenAI } from "openai";
2
2
  import { ServerTool } from "@langchain/core/tools";
3
3
 
4
4
  //#region src/tools/imageGeneration.d.ts
@@ -102,7 +102,7 @@ interface ImageGenerationOptions {
102
102
  /**
103
103
  * OpenAI Image Generation tool type for the Responses API.
104
104
  */
105
- type ImageGenerationTool = OpenAI$1.Responses.Tool.ImageGeneration;
105
+ type ImageGenerationTool = OpenAI.Responses.Tool.ImageGeneration;
106
106
  /**
107
107
  * Creates an Image Generation tool that allows models to generate or edit images
108
108
  * using text prompts and optional image inputs.
@@ -1 +1 @@
1
- {"version":3,"file":"imageGeneration.d.ts","names":[],"sources":["../../src/tools/imageGeneration.ts"],"mappings":";;;;;;AAOA;;UAAiB,wBAAA;EAIf;;AAUF;EAVE,QAAA;;;;EAIA,MAAA;AAAA;;;;UAMe,sBAAA;EAsDf;;;;;;;EA9CA,MAAA;EAsF6B;;;;;;;EA7E7B,UAAA;EA6E2E;AAgH7E;;;;;;;EAnLE,aAAA;EAmL2E;;;;EA7K3E,cAAA,GAAiB,wBAAA;;;;;EAMjB,KAAA;;;;;;;EAQA,UAAA;;;;;;EAOA,iBAAA;;;;;EAMA,YAAA;;;;;;;EAQA,aAAA;;;;;;;;;EAUA,OAAA;;;;;;;;;EAUA,IAAA;AAAA;;;;KAMU,mBAAA,GAAsB,QAAA,CAAa,SAAA,CAAU,IAAA,CAAK,eAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgH9C,eAAA,CAAgB,OAAA,GAAU,sBAAA,GAAyB,UAAA"}
1
+ {"version":3,"file":"imageGeneration.d.ts","names":[],"sources":["../../src/tools/imageGeneration.ts"],"mappings":";;;;;;AAOA;;UAAiB,wBAAA;EAIf;;AAUF;EAVE,QAAA;;;;EAIA,MAAA;AAAA;;;;UAMe,sBAAA;EAsDf;;;;;;;EA9CA,MAAA;EAsF6B;;;;;;;EA7E7B,UAAA;EA6E2E;AAgH7E;;;;;;;EAnLE,aAAA;EAmL2E;;;;EA7K3E,cAAA,GAAiB,wBAAA;;;;;EAMjB,KAAA;;;;;;;EAQA,UAAA;;;;;;EAOA,iBAAA;;;;;EAMA,YAAA;;;;;;;EAQA,aAAA;;;;;;;;;EAUA,OAAA;;;;;;;;;EAUA,IAAA;AAAA;;;;KAMU,mBAAA,GAAsB,MAAA,CAAa,SAAA,CAAU,IAAA,CAAK,eAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgH9C,eAAA,CAAgB,OAAA,GAAU,sBAAA,GAAyB,UAAA"}
@@ -122,7 +122,7 @@ function imageGeneration(options) {
122
122
  size: options?.size
123
123
  };
124
124
  }
125
-
126
125
  //#endregion
127
126
  export { imageGeneration };
127
+
128
128
  //# sourceMappingURL=imageGeneration.js.map