@langchain/openai 1.1.2 → 1.2.0-dev-1765431816670

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 (207) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +583 -2
  3. package/dist/azure/chat_models/common.d.cts.map +1 -1
  4. package/dist/azure/chat_models/common.d.ts +1 -0
  5. package/dist/azure/chat_models/common.d.ts.map +1 -1
  6. package/dist/azure/chat_models/completions.d.cts.map +1 -1
  7. package/dist/azure/chat_models/completions.d.ts.map +1 -1
  8. package/dist/azure/chat_models/index.d.cts +1 -1
  9. package/dist/azure/chat_models/index.d.cts.map +1 -1
  10. package/dist/azure/chat_models/index.d.ts.map +1 -1
  11. package/dist/azure/chat_models/responses.d.cts.map +1 -1
  12. package/dist/azure/chat_models/responses.d.ts.map +1 -1
  13. package/dist/azure/embeddings.d.cts.map +1 -1
  14. package/dist/azure/embeddings.d.ts.map +1 -1
  15. package/dist/azure/llms.d.cts +0 -1
  16. package/dist/azure/llms.d.cts.map +1 -1
  17. package/dist/azure/llms.d.ts +0 -1
  18. package/dist/azure/llms.d.ts.map +1 -1
  19. package/dist/chat_models/base.cjs +5 -1
  20. package/dist/chat_models/base.cjs.map +1 -1
  21. package/dist/chat_models/base.d.cts +8 -22
  22. package/dist/chat_models/base.d.cts.map +1 -1
  23. package/dist/chat_models/base.d.ts +6 -20
  24. package/dist/chat_models/base.d.ts.map +1 -1
  25. package/dist/chat_models/base.js +6 -2
  26. package/dist/chat_models/base.js.map +1 -1
  27. package/dist/chat_models/completions.cjs.map +1 -1
  28. package/dist/chat_models/completions.d.cts +1 -3
  29. package/dist/chat_models/completions.d.cts.map +1 -1
  30. package/dist/chat_models/completions.d.ts +1 -3
  31. package/dist/chat_models/completions.d.ts.map +1 -1
  32. package/dist/chat_models/completions.js.map +1 -1
  33. package/dist/chat_models/index.d.cts +42 -4
  34. package/dist/chat_models/index.d.cts.map +1 -1
  35. package/dist/chat_models/index.d.ts +42 -4
  36. package/dist/chat_models/index.d.ts.map +1 -1
  37. package/dist/chat_models/responses.d.cts +2 -2
  38. package/dist/chat_models/responses.d.cts.map +1 -1
  39. package/dist/chat_models/responses.d.ts +2 -2
  40. package/dist/chat_models/responses.d.ts.map +1 -1
  41. package/dist/converters/completions.cjs +22 -12
  42. package/dist/converters/completions.cjs.map +1 -1
  43. package/dist/converters/completions.d.cts +0 -1
  44. package/dist/converters/completions.d.cts.map +1 -1
  45. package/dist/converters/completions.d.ts +0 -1
  46. package/dist/converters/completions.d.ts.map +1 -1
  47. package/dist/converters/completions.js +23 -13
  48. package/dist/converters/completions.js.map +1 -1
  49. package/dist/converters/index.d.ts +2 -0
  50. package/dist/converters/responses.cjs +37 -4
  51. package/dist/converters/responses.cjs.map +1 -1
  52. package/dist/converters/responses.d.cts.map +1 -1
  53. package/dist/converters/responses.d.ts.map +1 -1
  54. package/dist/converters/responses.js +39 -6
  55. package/dist/converters/responses.js.map +1 -1
  56. package/dist/embeddings.d.cts +0 -1
  57. package/dist/embeddings.d.cts.map +1 -1
  58. package/dist/embeddings.d.ts +0 -1
  59. package/dist/embeddings.d.ts.map +1 -1
  60. package/dist/index.cjs +2 -1
  61. package/dist/index.d.cts +12 -2
  62. package/dist/index.d.ts +13 -2
  63. package/dist/index.js +2 -2
  64. package/dist/llms.d.cts +0 -1
  65. package/dist/llms.d.cts.map +1 -1
  66. package/dist/llms.d.ts +0 -1
  67. package/dist/llms.d.ts.map +1 -1
  68. package/dist/tools/applyPatch.cjs +116 -0
  69. package/dist/tools/applyPatch.cjs.map +1 -0
  70. package/dist/tools/applyPatch.d.cts +148 -0
  71. package/dist/tools/applyPatch.d.cts.map +1 -0
  72. package/dist/tools/applyPatch.d.ts +148 -0
  73. package/dist/tools/applyPatch.d.ts.map +1 -0
  74. package/dist/tools/applyPatch.js +115 -0
  75. package/dist/tools/applyPatch.js.map +1 -0
  76. package/dist/tools/codeInterpreter.cjs +95 -0
  77. package/dist/tools/codeInterpreter.cjs.map +1 -0
  78. package/dist/tools/codeInterpreter.d.cts +125 -0
  79. package/dist/tools/codeInterpreter.d.cts.map +1 -0
  80. package/dist/tools/codeInterpreter.d.ts +125 -0
  81. package/dist/tools/codeInterpreter.d.ts.map +1 -0
  82. package/dist/tools/codeInterpreter.js +94 -0
  83. package/dist/tools/codeInterpreter.js.map +1 -0
  84. package/dist/tools/computerUse.cjs +240 -0
  85. package/dist/tools/computerUse.cjs.map +1 -0
  86. package/dist/tools/computerUse.d.cts +234 -0
  87. package/dist/tools/computerUse.d.cts.map +1 -0
  88. package/dist/tools/computerUse.d.ts +234 -0
  89. package/dist/tools/computerUse.d.ts.map +1 -0
  90. package/dist/tools/computerUse.js +239 -0
  91. package/dist/tools/computerUse.js.map +1 -0
  92. package/dist/tools/custom.d.cts +1 -1
  93. package/dist/tools/custom.d.cts.map +1 -1
  94. package/dist/tools/custom.d.ts.map +1 -1
  95. package/dist/tools/dalle.d.cts +1 -2
  96. package/dist/tools/dalle.d.cts.map +1 -1
  97. package/dist/tools/dalle.d.ts +1 -2
  98. package/dist/tools/dalle.d.ts.map +1 -1
  99. package/dist/tools/fileSearch.cjs +137 -0
  100. package/dist/tools/fileSearch.cjs.map +1 -0
  101. package/dist/tools/fileSearch.d.cts +224 -0
  102. package/dist/tools/fileSearch.d.cts.map +1 -0
  103. package/dist/tools/fileSearch.d.ts +224 -0
  104. package/dist/tools/fileSearch.d.ts.map +1 -0
  105. package/dist/tools/fileSearch.js +136 -0
  106. package/dist/tools/fileSearch.js.map +1 -0
  107. package/dist/tools/imageGeneration.cjs +128 -0
  108. package/dist/tools/imageGeneration.cjs.map +1 -0
  109. package/dist/tools/imageGeneration.d.cts +199 -0
  110. package/dist/tools/imageGeneration.d.cts.map +1 -0
  111. package/dist/tools/imageGeneration.d.ts +199 -0
  112. package/dist/tools/imageGeneration.d.ts.map +1 -0
  113. package/dist/tools/imageGeneration.js +127 -0
  114. package/dist/tools/imageGeneration.js.map +1 -0
  115. package/dist/tools/index.cjs +26 -0
  116. package/dist/tools/index.cjs.map +1 -0
  117. package/dist/tools/index.d.cts +27 -0
  118. package/dist/tools/index.d.cts.map +1 -0
  119. package/dist/tools/index.d.ts +27 -0
  120. package/dist/tools/index.d.ts.map +1 -0
  121. package/dist/tools/index.js +26 -0
  122. package/dist/tools/index.js.map +1 -0
  123. package/dist/tools/localShell.cjs +145 -0
  124. package/dist/tools/localShell.cjs.map +1 -0
  125. package/dist/tools/localShell.d.cts +167 -0
  126. package/dist/tools/localShell.d.cts.map +1 -0
  127. package/dist/tools/localShell.d.ts +167 -0
  128. package/dist/tools/localShell.d.ts.map +1 -0
  129. package/dist/tools/localShell.js +144 -0
  130. package/dist/tools/localShell.js.map +1 -0
  131. package/dist/tools/mcp.cjs +53 -0
  132. package/dist/tools/mcp.cjs.map +1 -0
  133. package/dist/tools/mcp.d.cts +177 -0
  134. package/dist/tools/mcp.d.cts.map +1 -0
  135. package/dist/tools/mcp.d.ts +177 -0
  136. package/dist/tools/mcp.d.ts.map +1 -0
  137. package/dist/tools/mcp.js +52 -0
  138. package/dist/tools/mcp.js.map +1 -0
  139. package/dist/tools/shell.cjs +163 -0
  140. package/dist/tools/shell.cjs.map +1 -0
  141. package/dist/tools/shell.d.cts +221 -0
  142. package/dist/tools/shell.d.cts.map +1 -0
  143. package/dist/tools/shell.d.ts +221 -0
  144. package/dist/tools/shell.d.ts.map +1 -0
  145. package/dist/tools/shell.js +162 -0
  146. package/dist/tools/shell.js.map +1 -0
  147. package/dist/tools/webSearch.cjs +73 -0
  148. package/dist/tools/webSearch.cjs.map +1 -0
  149. package/dist/tools/webSearch.d.cts +130 -0
  150. package/dist/tools/webSearch.d.cts.map +1 -0
  151. package/dist/tools/webSearch.d.ts +130 -0
  152. package/dist/tools/webSearch.d.ts.map +1 -0
  153. package/dist/tools/webSearch.js +72 -0
  154. package/dist/tools/webSearch.js.map +1 -0
  155. package/dist/types.d.cts +2 -4
  156. package/dist/types.d.cts.map +1 -1
  157. package/dist/types.d.ts +1 -3
  158. package/dist/types.d.ts.map +1 -1
  159. package/dist/utils/azure.d.cts +1 -5
  160. package/dist/utils/azure.d.cts.map +1 -1
  161. package/dist/utils/azure.d.ts +1 -5
  162. package/dist/utils/azure.d.ts.map +1 -1
  163. package/dist/utils/client.d.cts.map +1 -1
  164. package/dist/utils/client.d.ts.map +1 -1
  165. package/dist/utils/misc.cjs +6 -0
  166. package/dist/utils/misc.cjs.map +1 -1
  167. package/dist/utils/misc.d.cts +1 -1
  168. package/dist/utils/misc.d.cts.map +1 -1
  169. package/dist/utils/misc.d.ts +1 -1
  170. package/dist/utils/misc.d.ts.map +1 -1
  171. package/dist/utils/misc.js +6 -1
  172. package/dist/utils/misc.js.map +1 -1
  173. package/dist/utils/prompts.d.cts +0 -1
  174. package/dist/utils/prompts.d.cts.map +1 -1
  175. package/dist/utils/prompts.d.ts +0 -1
  176. package/dist/utils/prompts.d.ts.map +1 -1
  177. package/dist/utils/tools.cjs +39 -1
  178. package/dist/utils/tools.cjs.map +1 -1
  179. package/dist/utils/tools.d.cts.map +1 -1
  180. package/dist/utils/tools.d.ts.map +1 -1
  181. package/dist/utils/tools.js +37 -2
  182. package/dist/utils/tools.js.map +1 -1
  183. package/package.json +18 -15
  184. package/dist/langchain-core/dist/callbacks/base.d.ts +0 -1
  185. package/dist/langchain-core/dist/callbacks/manager.d.ts +0 -2
  186. package/dist/langchain-core/dist/language_models/base.d.ts +0 -5
  187. package/dist/langchain-core/dist/language_models/chat_models.d.cts +0 -13
  188. package/dist/langchain-core/dist/language_models/chat_models.d.cts.map +0 -1
  189. package/dist/langchain-core/dist/language_models/chat_models.d.ts +0 -20
  190. package/dist/langchain-core/dist/language_models/chat_models.d.ts.map +0 -1
  191. package/dist/langchain-core/dist/runnables/base.d.ts +0 -7
  192. package/dist/langchain-core/dist/runnables/graph.d.ts +0 -1
  193. package/dist/langchain-core/dist/runnables/types.d.ts +0 -2
  194. package/dist/langchain-core/dist/tools/types.d.ts +0 -5
  195. package/dist/langchain-core/dist/tracers/base.d.ts +0 -2
  196. package/dist/langchain-core/dist/tracers/event_stream.d.ts +0 -1
  197. package/dist/langchain-core/dist/tracers/log_stream.d.ts +0 -3
  198. package/dist/langchain-core/dist/types/_internal.d.cts +0 -11
  199. package/dist/langchain-core/dist/types/_internal.d.cts.map +0 -1
  200. package/dist/langchain-core/dist/types/_internal.d.ts +0 -11
  201. package/dist/langchain-core/dist/types/_internal.d.ts.map +0 -1
  202. package/dist/langchain-core/dist/utils/stream.d.cts +0 -26
  203. package/dist/langchain-core/dist/utils/stream.d.cts.map +0 -1
  204. package/dist/langchain-core/dist/utils/stream.d.ts +0 -26
  205. package/dist/langchain-core/dist/utils/stream.d.ts.map +0 -1
  206. package/dist/langchain-core/dist/utils/types/index.d.ts +0 -1
  207. package/dist/langchain-core/dist/utils/types/zod.d.ts +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"dalle.d.ts","names":["OpenAI","OpenAIClient","Tool","ToolParams","MessageContentComplex","OpenAIImageModelId","ImageModel","NonNullable","DallEAPIWrapperParams","DallEAPIWrapper","Promise"],"sources":["../../src/tools/dalle.d.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport { Tool, ToolParams } from \"@langchain/core/tools\";\nimport { MessageContentComplex } from \"@langchain/core/messages\";\n/**\n * @see https://platform.openai.com/docs/api-reference/images/create\n */\nexport type OpenAIImageModelId = OpenAIClient.ImageModel | (string & NonNullable<unknown>);\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 * A tool for generating images with Open AIs Dall-E 2 or 3 API.\n */\nexport declare class DallEAPIWrapper extends Tool {\n static lc_name(): string;\n name: string;\n description: string;\n protected client: OpenAIClient;\n static readonly toolName: string;\n private model;\n private style;\n private quality;\n private n;\n private size;\n private dallEResponseFormat;\n private user?;\n constructor(fields?: DallEAPIWrapperParams);\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 /** @ignore */\n _call(input: string): Promise<string | MessageContentComplex[]>;\n}\n"],"mappings":";;;;;;;;AAMA;AAA8B,KAAlBK,kBAAAA,GAAqBJ,QAAAA,CAAaK,UAAhB,GAAA,CAAA,MAAA,GAAuCC,WAAvC,CAAA,OAAA,CAAA,CAAA;;;AAAkD;AAI/DC,UAAAA,qBAAAA,SAA8BL,UAAT,CAAA;EAAA;;;;EAAmB,YAAA,CAAA,EAAA,MAAA;EA+EpCM;;;EAIa,MASTD,CAAAA,EAAAA,MAAAA;EAAqB;;;AAbG;;;;cA9DjCH;;;;;;UAMJA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAwDSI,eAAAA,SAAwBP,IAAAA;;;;oBAIvBD;;;;;;;;;uBASGO;;;;;;;;;;;;;wBAaCE,iBAAiBN"}
1
+ {"version":3,"file":"dalle.d.ts","names":["OpenAI","OpenAIClient","Tool","ToolParams","MessageContentComplex","OpenAIImageModelId","ImageModel","NonNullable","DallEAPIWrapperParams","DallEAPIWrapper","Promise"],"sources":["../../src/tools/dalle.d.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport { Tool, ToolParams } from \"@langchain/core/tools\";\nimport { MessageContentComplex } from \"@langchain/core/messages\";\n/**\n * @see https://platform.openai.com/docs/api-reference/images/create\n */\nexport type OpenAIImageModelId = OpenAIClient.ImageModel | (string & NonNullable<unknown>);\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 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 * A tool for generating images with Open AIs Dall-E 2 or 3 API.\n */\nexport declare class DallEAPIWrapper extends Tool {\n static lc_name(): string;\n name: string;\n description: string;\n protected client: OpenAIClient;\n static readonly toolName = \"dalle_api_wrapper\";\n private model;\n private style;\n private quality;\n private n;\n private size;\n private dallEResponseFormat;\n private user?;\n constructor(fields?: DallEAPIWrapperParams);\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 /** @ignore */\n _call(input: string): Promise<string | MessageContentComplex[]>;\n}\n//# sourceMappingURL=dalle.d.ts.map"],"mappings":";;;;;;;;AAMA;AAIiBQ,KAJLH,kBAAAA,GAAqBJ,QAAAA,CAAaK,UAIR,GAAA,CAAA,MAAA,GAJ+BC,WAI/B,CAAA,OAAA,CAAA,CAAA;;;;AAAmB,UAAxCC,qBAAAA,SAA8BL,UAAU,CAAA;EA8EpCM;;;;EA0BKC,YAAAA,CAAAA,EAAAA,MAAAA;EA1BmBR;AAAI;;;;;;;;;;cA7DjCG;;;;;;UAMJA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAuDSI,eAAAA,SAAwBP,IAAAA;;;;oBAIvBD;;;;;;;;;uBASGO;;;;;;;;;;;;;wBAaCE,iBAAiBN"}
@@ -0,0 +1,137 @@
1
+
2
+ //#region src/tools/fileSearch.ts
3
+ /**
4
+ * Converts ranking options to the API format.
5
+ */
6
+ function convertRankingOptions(options) {
7
+ if (!options) return void 0;
8
+ return {
9
+ ranker: options.ranker,
10
+ score_threshold: options.scoreThreshold,
11
+ hybrid_search: options.hybridSearch ? {
12
+ embedding_weight: options.hybridSearch.embeddingWeight,
13
+ text_weight: options.hybridSearch.textWeight
14
+ } : void 0
15
+ };
16
+ }
17
+ /**
18
+ * Creates a File Search tool that allows models to search your files
19
+ * for relevant information using semantic and keyword search.
20
+ *
21
+ * File Search enables models to retrieve information from a knowledge base
22
+ * of previously uploaded files stored in vector stores. This is a hosted tool
23
+ * managed by OpenAI - you don't need to implement the search execution yourself.
24
+ *
25
+ * **Prerequisites**: Before using File Search, you must:
26
+ * 1. Upload files to the File API with `purpose: "assistants"`
27
+ * 2. Create a vector store
28
+ * 3. Add files to the vector store
29
+ *
30
+ * @see {@link https://platform.openai.com/docs/guides/tools-file-search | OpenAI File Search Documentation}
31
+ *
32
+ * @param options - Configuration options for the File Search tool
33
+ * @returns A File Search tool definition to be passed to the OpenAI Responses API
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * import { ChatOpenAI, tools } from "@langchain/openai";
38
+ *
39
+ * const model = new ChatOpenAI({ model: "gpt-4.1" });
40
+ *
41
+ * // Basic usage with a vector store
42
+ * const response = await model.invoke(
43
+ * "What is deep research by OpenAI?",
44
+ * {
45
+ * tools: [tools.fileSearch({
46
+ * vectorStoreIds: ["vs_abc123"]
47
+ * })]
48
+ * }
49
+ * );
50
+ *
51
+ * // Limit the number of results for lower latency
52
+ * const response = await model.invoke(
53
+ * "Find information about pricing",
54
+ * {
55
+ * tools: [tools.fileSearch({
56
+ * vectorStoreIds: ["vs_abc123"],
57
+ * maxNumResults: 5
58
+ * })]
59
+ * }
60
+ * );
61
+ *
62
+ * // With metadata filtering
63
+ * const response = await model.invoke(
64
+ * "Find recent blog posts about AI",
65
+ * {
66
+ * tools: [tools.fileSearch({
67
+ * vectorStoreIds: ["vs_abc123"],
68
+ * filters: {
69
+ * type: "eq",
70
+ * key: "category",
71
+ * value: "blog"
72
+ * }
73
+ * })]
74
+ * }
75
+ * );
76
+ *
77
+ * // With compound filters (AND/OR)
78
+ * const response = await model.invoke(
79
+ * "Find technical docs from 2024",
80
+ * {
81
+ * tools: [tools.fileSearch({
82
+ * vectorStoreIds: ["vs_abc123"],
83
+ * filters: {
84
+ * type: "and",
85
+ * filters: [
86
+ * { type: "eq", key: "category", value: "technical" },
87
+ * { type: "gte", key: "year", value: 2024 }
88
+ * ]
89
+ * }
90
+ * })]
91
+ * }
92
+ * );
93
+ *
94
+ * // With ranking options for more relevant results
95
+ * const response = await model.invoke(
96
+ * "Find the most relevant information",
97
+ * {
98
+ * tools: [tools.fileSearch({
99
+ * vectorStoreIds: ["vs_abc123"],
100
+ * rankingOptions: {
101
+ * scoreThreshold: 0.8,
102
+ * ranker: "auto"
103
+ * }
104
+ * })]
105
+ * }
106
+ * );
107
+ *
108
+ * // Search multiple vector stores
109
+ * const response = await model.invoke(
110
+ * "Search across all knowledge bases",
111
+ * {
112
+ * tools: [tools.fileSearch({
113
+ * vectorStoreIds: ["vs_abc123", "vs_def456"]
114
+ * })]
115
+ * }
116
+ * );
117
+ * ```
118
+ *
119
+ * @remarks
120
+ * - Vector stores must be created and populated before using this tool
121
+ * - The tool returns file citations in the response annotations
122
+ * - Use `include: ["file_search_call.results"]` in the API call to get search results
123
+ * - Supported file types include PDF, DOCX, TXT, MD, and many code file formats
124
+ */
125
+ function fileSearch(options) {
126
+ return {
127
+ type: "file_search",
128
+ vector_store_ids: options.vectorStoreIds,
129
+ max_num_results: options.maxNumResults,
130
+ filters: options.filters,
131
+ ranking_options: convertRankingOptions(options.rankingOptions)
132
+ };
133
+ }
134
+
135
+ //#endregion
136
+ exports.fileSearch = fileSearch;
137
+ //# sourceMappingURL=fileSearch.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileSearch.cjs","names":["options: FileSearchRankingOptions | undefined","options: FileSearchOptions"],"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,sBACPA,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;EACnC,IACD;CACL;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8GD,SAAgB,WAAWC,SAAwC;AACjE,QAAO;EACL,MAAM;EACN,kBAAkB,QAAQ;EAC1B,iBAAiB,QAAQ;EACzB,SAAS,QAAQ;EACjB,iBAAiB,sBAAsB,QAAQ,eAAe;CAC/D;AACF"}
@@ -0,0 +1,224 @@
1
+ import { OpenAI as OpenAI$1 } from "openai";
2
+ import { ServerTool } from "@langchain/core/tools";
3
+
4
+ //#region src/tools/fileSearch.d.ts
5
+
6
+ /**
7
+ * Comparison operators for file attribute filtering.
8
+ */
9
+ type FileSearchComparisonType = "eq" | "ne" | "gt" | "gte" | "lt" | "lte";
10
+ /**
11
+ * A filter used to compare a specified attribute key to a given value.
12
+ */
13
+ interface FileSearchComparisonFilter {
14
+ /**
15
+ * The comparison operator to use.
16
+ * - `eq`: equals
17
+ * - `ne`: not equal
18
+ * - `gt`: greater than
19
+ * - `gte`: greater than or equal
20
+ * - `lt`: less than
21
+ * - `lte`: less than or equal
22
+ */
23
+ type: FileSearchComparisonType;
24
+ /**
25
+ * The attribute key to compare against.
26
+ */
27
+ key: string;
28
+ /**
29
+ * The value to compare against the attribute key.
30
+ * Supports string, number, boolean, or array of strings/numbers.
31
+ */
32
+ value: string | number | boolean | Array<string | number>;
33
+ }
34
+ /**
35
+ * Combine multiple filters using `and` or `or`.
36
+ */
37
+ interface FileSearchCompoundFilter {
38
+ /**
39
+ * Type of operation: `and` or `or`.
40
+ */
41
+ type: "and" | "or";
42
+ /**
43
+ * Array of filters to combine.
44
+ */
45
+ filters: Array<FileSearchComparisonFilter | FileSearchCompoundFilter>;
46
+ }
47
+ /**
48
+ * Filter type for file search - can be a comparison or compound filter.
49
+ */
50
+ type FileSearchFilter = FileSearchComparisonFilter | FileSearchCompoundFilter;
51
+ /**
52
+ * Weights for hybrid search balancing semantic and keyword matches.
53
+ */
54
+ interface FileSearchHybridSearchWeights {
55
+ /**
56
+ * The weight of semantic embedding matches (0-1).
57
+ */
58
+ embeddingWeight: number;
59
+ /**
60
+ * The weight of keyword/text matches (0-1).
61
+ */
62
+ textWeight: number;
63
+ }
64
+ /**
65
+ * Ranking options for file search results.
66
+ */
67
+ interface FileSearchRankingOptions {
68
+ /**
69
+ * The ranker to use for the file search.
70
+ * - `auto`: Automatically select the best ranker
71
+ * - `default-2024-11-15`: Default ranker as of November 2024
72
+ */
73
+ ranker?: "auto" | "default-2024-11-15";
74
+ /**
75
+ * The score threshold for results (0-1).
76
+ * Numbers closer to 1 return only the most relevant results but may return fewer.
77
+ */
78
+ scoreThreshold?: number;
79
+ /**
80
+ * Weights that control how reciprocal rank fusion balances semantic
81
+ * embedding matches versus sparse keyword matches when hybrid search is enabled.
82
+ */
83
+ hybridSearch?: FileSearchHybridSearchWeights;
84
+ }
85
+ /**
86
+ * Options for the File Search tool.
87
+ */
88
+ interface FileSearchOptions {
89
+ /**
90
+ * The IDs of the vector stores to search.
91
+ * You must have previously created vector stores and uploaded files to them.
92
+ */
93
+ vectorStoreIds: string[];
94
+ /**
95
+ * The maximum number of results to return.
96
+ * Must be between 1 and 50 inclusive.
97
+ */
98
+ maxNumResults?: number;
99
+ /**
100
+ * A filter to apply based on file attributes/metadata.
101
+ * Use this to narrow down search results to specific categories or file types.
102
+ */
103
+ filters?: FileSearchFilter;
104
+ /**
105
+ * Ranking options to customize how results are scored and ordered.
106
+ */
107
+ rankingOptions?: FileSearchRankingOptions;
108
+ }
109
+ /**
110
+ * OpenAI File Search tool type for the Responses API.
111
+ */
112
+ type FileSearchTool = OpenAI$1.Responses.FileSearchTool;
113
+ /**
114
+ * Creates a File Search tool that allows models to search your files
115
+ * for relevant information using semantic and keyword search.
116
+ *
117
+ * File Search enables models to retrieve information from a knowledge base
118
+ * of previously uploaded files stored in vector stores. This is a hosted tool
119
+ * managed by OpenAI - you don't need to implement the search execution yourself.
120
+ *
121
+ * **Prerequisites**: Before using File Search, you must:
122
+ * 1. Upload files to the File API with `purpose: "assistants"`
123
+ * 2. Create a vector store
124
+ * 3. Add files to the vector store
125
+ *
126
+ * @see {@link https://platform.openai.com/docs/guides/tools-file-search | OpenAI File Search Documentation}
127
+ *
128
+ * @param options - Configuration options for the File Search tool
129
+ * @returns A File Search tool definition to be passed to the OpenAI Responses API
130
+ *
131
+ * @example
132
+ * ```typescript
133
+ * import { ChatOpenAI, tools } from "@langchain/openai";
134
+ *
135
+ * const model = new ChatOpenAI({ model: "gpt-4.1" });
136
+ *
137
+ * // Basic usage with a vector store
138
+ * const response = await model.invoke(
139
+ * "What is deep research by OpenAI?",
140
+ * {
141
+ * tools: [tools.fileSearch({
142
+ * vectorStoreIds: ["vs_abc123"]
143
+ * })]
144
+ * }
145
+ * );
146
+ *
147
+ * // Limit the number of results for lower latency
148
+ * const response = await model.invoke(
149
+ * "Find information about pricing",
150
+ * {
151
+ * tools: [tools.fileSearch({
152
+ * vectorStoreIds: ["vs_abc123"],
153
+ * maxNumResults: 5
154
+ * })]
155
+ * }
156
+ * );
157
+ *
158
+ * // With metadata filtering
159
+ * const response = await model.invoke(
160
+ * "Find recent blog posts about AI",
161
+ * {
162
+ * tools: [tools.fileSearch({
163
+ * vectorStoreIds: ["vs_abc123"],
164
+ * filters: {
165
+ * type: "eq",
166
+ * key: "category",
167
+ * value: "blog"
168
+ * }
169
+ * })]
170
+ * }
171
+ * );
172
+ *
173
+ * // With compound filters (AND/OR)
174
+ * const response = await model.invoke(
175
+ * "Find technical docs from 2024",
176
+ * {
177
+ * tools: [tools.fileSearch({
178
+ * vectorStoreIds: ["vs_abc123"],
179
+ * filters: {
180
+ * type: "and",
181
+ * filters: [
182
+ * { type: "eq", key: "category", value: "technical" },
183
+ * { type: "gte", key: "year", value: 2024 }
184
+ * ]
185
+ * }
186
+ * })]
187
+ * }
188
+ * );
189
+ *
190
+ * // With ranking options for more relevant results
191
+ * const response = await model.invoke(
192
+ * "Find the most relevant information",
193
+ * {
194
+ * tools: [tools.fileSearch({
195
+ * vectorStoreIds: ["vs_abc123"],
196
+ * rankingOptions: {
197
+ * scoreThreshold: 0.8,
198
+ * ranker: "auto"
199
+ * }
200
+ * })]
201
+ * }
202
+ * );
203
+ *
204
+ * // Search multiple vector stores
205
+ * const response = await model.invoke(
206
+ * "Search across all knowledge bases",
207
+ * {
208
+ * tools: [tools.fileSearch({
209
+ * vectorStoreIds: ["vs_abc123", "vs_def456"]
210
+ * })]
211
+ * }
212
+ * );
213
+ * ```
214
+ *
215
+ * @remarks
216
+ * - Vector stores must be created and populated before using this tool
217
+ * - The tool returns file citations in the response annotations
218
+ * - Use `include: ["file_search_call.results"]` in the API call to get search results
219
+ * - Supported file types include PDF, DOCX, TXT, MD, and many code file formats
220
+ */
221
+ declare function fileSearch(options: FileSearchOptions): ServerTool;
222
+ //#endregion
223
+ export { FileSearchComparisonFilter, FileSearchComparisonType, FileSearchCompoundFilter, FileSearchFilter, FileSearchHybridSearchWeights, FileSearchOptions, FileSearchRankingOptions, FileSearchTool, fileSearch };
224
+ //# sourceMappingURL=fileSearch.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileSearch.d.cts","names":["OpenAI","OpenAIClient","ServerTool","FileSearchComparisonType","FileSearchComparisonFilter","Array","FileSearchCompoundFilter","FileSearchFilter","FileSearchHybridSearchWeights","FileSearchRankingOptions","FileSearchOptions","FileSearchTool","Responses","fileSearch"],"sources":["../../src/tools/fileSearch.d.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n/**\n * Comparison operators for file attribute filtering.\n */\nexport type FileSearchComparisonType = \"eq\" | \"ne\" | \"gt\" | \"gte\" | \"lt\" | \"lte\";\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 * 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 * Filter type for file search - can be a comparison or compound filter.\n */\nexport type FileSearchFilter = FileSearchComparisonFilter | FileSearchCompoundFilter;\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 * 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 * 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 * OpenAI File Search tool type for the Responses API.\n */\nexport type FileSearchTool = OpenAIClient.Responses.FileSearchTool;\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 declare function fileSearch(options: FileSearchOptions): ServerTool;\n//# sourceMappingURL=fileSearch.d.ts.map"],"mappings":";;;;;;;AAKA;AAIiBI,KAJLD,wBAAAA,GAI+B,IAAA,GAUjCA,IAAAA,GAAAA,IAAAA,GAAAA,KAAAA,GAAAA,IAS6BE,GAAAA,KAAK;AAK5C;;;AAQaA,UAhCID,0BAAAA,CAgCJC;EAAK;AAKlB;AAIA;AAaA;AAqBA;AAwBA;AA6GA;;;QAtMUF;;;;;;;;;qCAS6BE;;;;;UAKtBC,wBAAAA;;;;;;;;WAQJD,MAAMD,6BAA6BE;;;;;KAKpCC,gBAAAA,GAAmBH,6BAA6BE;;;;UAI3CE,6BAAAA;;;;;;;;;;;;;UAaAC,wBAAAA;;;;;;;;;;;;;;;;iBAgBED;;;;;UAKFE,iBAAAA;;;;;;;;;;;;;;;YAeHH;;;;mBAIOE;;;;;KAKTE,cAAAA,GAAiBV,QAAAA,CAAaW,SAAAA,CAAUD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6G5BE,UAAAA,UAAoBH,oBAAoBR"}
@@ -0,0 +1,224 @@
1
+ import { OpenAI as OpenAI$1 } from "openai";
2
+ import { ServerTool } from "@langchain/core/tools";
3
+
4
+ //#region src/tools/fileSearch.d.ts
5
+
6
+ /**
7
+ * Comparison operators for file attribute filtering.
8
+ */
9
+ type FileSearchComparisonType = "eq" | "ne" | "gt" | "gte" | "lt" | "lte";
10
+ /**
11
+ * A filter used to compare a specified attribute key to a given value.
12
+ */
13
+ interface FileSearchComparisonFilter {
14
+ /**
15
+ * The comparison operator to use.
16
+ * - `eq`: equals
17
+ * - `ne`: not equal
18
+ * - `gt`: greater than
19
+ * - `gte`: greater than or equal
20
+ * - `lt`: less than
21
+ * - `lte`: less than or equal
22
+ */
23
+ type: FileSearchComparisonType;
24
+ /**
25
+ * The attribute key to compare against.
26
+ */
27
+ key: string;
28
+ /**
29
+ * The value to compare against the attribute key.
30
+ * Supports string, number, boolean, or array of strings/numbers.
31
+ */
32
+ value: string | number | boolean | Array<string | number>;
33
+ }
34
+ /**
35
+ * Combine multiple filters using `and` or `or`.
36
+ */
37
+ interface FileSearchCompoundFilter {
38
+ /**
39
+ * Type of operation: `and` or `or`.
40
+ */
41
+ type: "and" | "or";
42
+ /**
43
+ * Array of filters to combine.
44
+ */
45
+ filters: Array<FileSearchComparisonFilter | FileSearchCompoundFilter>;
46
+ }
47
+ /**
48
+ * Filter type for file search - can be a comparison or compound filter.
49
+ */
50
+ type FileSearchFilter = FileSearchComparisonFilter | FileSearchCompoundFilter;
51
+ /**
52
+ * Weights for hybrid search balancing semantic and keyword matches.
53
+ */
54
+ interface FileSearchHybridSearchWeights {
55
+ /**
56
+ * The weight of semantic embedding matches (0-1).
57
+ */
58
+ embeddingWeight: number;
59
+ /**
60
+ * The weight of keyword/text matches (0-1).
61
+ */
62
+ textWeight: number;
63
+ }
64
+ /**
65
+ * Ranking options for file search results.
66
+ */
67
+ interface FileSearchRankingOptions {
68
+ /**
69
+ * The ranker to use for the file search.
70
+ * - `auto`: Automatically select the best ranker
71
+ * - `default-2024-11-15`: Default ranker as of November 2024
72
+ */
73
+ ranker?: "auto" | "default-2024-11-15";
74
+ /**
75
+ * The score threshold for results (0-1).
76
+ * Numbers closer to 1 return only the most relevant results but may return fewer.
77
+ */
78
+ scoreThreshold?: number;
79
+ /**
80
+ * Weights that control how reciprocal rank fusion balances semantic
81
+ * embedding matches versus sparse keyword matches when hybrid search is enabled.
82
+ */
83
+ hybridSearch?: FileSearchHybridSearchWeights;
84
+ }
85
+ /**
86
+ * Options for the File Search tool.
87
+ */
88
+ interface FileSearchOptions {
89
+ /**
90
+ * The IDs of the vector stores to search.
91
+ * You must have previously created vector stores and uploaded files to them.
92
+ */
93
+ vectorStoreIds: string[];
94
+ /**
95
+ * The maximum number of results to return.
96
+ * Must be between 1 and 50 inclusive.
97
+ */
98
+ maxNumResults?: number;
99
+ /**
100
+ * A filter to apply based on file attributes/metadata.
101
+ * Use this to narrow down search results to specific categories or file types.
102
+ */
103
+ filters?: FileSearchFilter;
104
+ /**
105
+ * Ranking options to customize how results are scored and ordered.
106
+ */
107
+ rankingOptions?: FileSearchRankingOptions;
108
+ }
109
+ /**
110
+ * OpenAI File Search tool type for the Responses API.
111
+ */
112
+ type FileSearchTool = OpenAI$1.Responses.FileSearchTool;
113
+ /**
114
+ * Creates a File Search tool that allows models to search your files
115
+ * for relevant information using semantic and keyword search.
116
+ *
117
+ * File Search enables models to retrieve information from a knowledge base
118
+ * of previously uploaded files stored in vector stores. This is a hosted tool
119
+ * managed by OpenAI - you don't need to implement the search execution yourself.
120
+ *
121
+ * **Prerequisites**: Before using File Search, you must:
122
+ * 1. Upload files to the File API with `purpose: "assistants"`
123
+ * 2. Create a vector store
124
+ * 3. Add files to the vector store
125
+ *
126
+ * @see {@link https://platform.openai.com/docs/guides/tools-file-search | OpenAI File Search Documentation}
127
+ *
128
+ * @param options - Configuration options for the File Search tool
129
+ * @returns A File Search tool definition to be passed to the OpenAI Responses API
130
+ *
131
+ * @example
132
+ * ```typescript
133
+ * import { ChatOpenAI, tools } from "@langchain/openai";
134
+ *
135
+ * const model = new ChatOpenAI({ model: "gpt-4.1" });
136
+ *
137
+ * // Basic usage with a vector store
138
+ * const response = await model.invoke(
139
+ * "What is deep research by OpenAI?",
140
+ * {
141
+ * tools: [tools.fileSearch({
142
+ * vectorStoreIds: ["vs_abc123"]
143
+ * })]
144
+ * }
145
+ * );
146
+ *
147
+ * // Limit the number of results for lower latency
148
+ * const response = await model.invoke(
149
+ * "Find information about pricing",
150
+ * {
151
+ * tools: [tools.fileSearch({
152
+ * vectorStoreIds: ["vs_abc123"],
153
+ * maxNumResults: 5
154
+ * })]
155
+ * }
156
+ * );
157
+ *
158
+ * // With metadata filtering
159
+ * const response = await model.invoke(
160
+ * "Find recent blog posts about AI",
161
+ * {
162
+ * tools: [tools.fileSearch({
163
+ * vectorStoreIds: ["vs_abc123"],
164
+ * filters: {
165
+ * type: "eq",
166
+ * key: "category",
167
+ * value: "blog"
168
+ * }
169
+ * })]
170
+ * }
171
+ * );
172
+ *
173
+ * // With compound filters (AND/OR)
174
+ * const response = await model.invoke(
175
+ * "Find technical docs from 2024",
176
+ * {
177
+ * tools: [tools.fileSearch({
178
+ * vectorStoreIds: ["vs_abc123"],
179
+ * filters: {
180
+ * type: "and",
181
+ * filters: [
182
+ * { type: "eq", key: "category", value: "technical" },
183
+ * { type: "gte", key: "year", value: 2024 }
184
+ * ]
185
+ * }
186
+ * })]
187
+ * }
188
+ * );
189
+ *
190
+ * // With ranking options for more relevant results
191
+ * const response = await model.invoke(
192
+ * "Find the most relevant information",
193
+ * {
194
+ * tools: [tools.fileSearch({
195
+ * vectorStoreIds: ["vs_abc123"],
196
+ * rankingOptions: {
197
+ * scoreThreshold: 0.8,
198
+ * ranker: "auto"
199
+ * }
200
+ * })]
201
+ * }
202
+ * );
203
+ *
204
+ * // Search multiple vector stores
205
+ * const response = await model.invoke(
206
+ * "Search across all knowledge bases",
207
+ * {
208
+ * tools: [tools.fileSearch({
209
+ * vectorStoreIds: ["vs_abc123", "vs_def456"]
210
+ * })]
211
+ * }
212
+ * );
213
+ * ```
214
+ *
215
+ * @remarks
216
+ * - Vector stores must be created and populated before using this tool
217
+ * - The tool returns file citations in the response annotations
218
+ * - Use `include: ["file_search_call.results"]` in the API call to get search results
219
+ * - Supported file types include PDF, DOCX, TXT, MD, and many code file formats
220
+ */
221
+ declare function fileSearch(options: FileSearchOptions): ServerTool;
222
+ //#endregion
223
+ export { FileSearchComparisonFilter, FileSearchComparisonType, FileSearchCompoundFilter, FileSearchFilter, FileSearchHybridSearchWeights, FileSearchOptions, FileSearchRankingOptions, FileSearchTool, fileSearch };
224
+ //# sourceMappingURL=fileSearch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileSearch.d.ts","names":["OpenAI","OpenAIClient","ServerTool","FileSearchComparisonType","FileSearchComparisonFilter","Array","FileSearchCompoundFilter","FileSearchFilter","FileSearchHybridSearchWeights","FileSearchRankingOptions","FileSearchOptions","FileSearchTool","Responses","fileSearch"],"sources":["../../src/tools/fileSearch.d.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n/**\n * Comparison operators for file attribute filtering.\n */\nexport type FileSearchComparisonType = \"eq\" | \"ne\" | \"gt\" | \"gte\" | \"lt\" | \"lte\";\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 * 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 * Filter type for file search - can be a comparison or compound filter.\n */\nexport type FileSearchFilter = FileSearchComparisonFilter | FileSearchCompoundFilter;\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 * 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 * 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 * OpenAI File Search tool type for the Responses API.\n */\nexport type FileSearchTool = OpenAIClient.Responses.FileSearchTool;\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 declare function fileSearch(options: FileSearchOptions): ServerTool;\n//# sourceMappingURL=fileSearch.d.ts.map"],"mappings":";;;;;;;AAKA;AAIiBI,KAJLD,wBAAAA,GAI+B,IAAA,GAUjCA,IAAAA,GAAAA,IAAAA,GAAAA,KAAAA,GAAAA,IAS6BE,GAAAA,KAAK;AAK5C;;;AAQaA,UAhCID,0BAAAA,CAgCJC;EAAK;AAKlB;AAIA;AAaA;AAqBA;AAwBA;AA6GA;;;QAtMUF;;;;;;;;;qCAS6BE;;;;;UAKtBC,wBAAAA;;;;;;;;WAQJD,MAAMD,6BAA6BE;;;;;KAKpCC,gBAAAA,GAAmBH,6BAA6BE;;;;UAI3CE,6BAAAA;;;;;;;;;;;;;UAaAC,wBAAAA;;;;;;;;;;;;;;;;iBAgBED;;;;;UAKFE,iBAAAA;;;;;;;;;;;;;;;YAeHH;;;;mBAIOE;;;;;KAKTE,cAAAA,GAAiBV,QAAAA,CAAaW,SAAAA,CAAUD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6G5BE,UAAAA,UAAoBH,oBAAoBR"}