@langchain/xai 1.2.2 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/chat_models/completions.cjs +1 -1
  3. package/dist/chat_models/completions.cjs.map +1 -1
  4. package/dist/chat_models/completions.d.cts +5 -0
  5. package/dist/chat_models/completions.d.cts.map +1 -1
  6. package/dist/chat_models/completions.d.ts +5 -0
  7. package/dist/chat_models/completions.d.ts.map +1 -1
  8. package/dist/chat_models/completions.js +1 -1
  9. package/dist/chat_models/completions.js.map +1 -1
  10. package/dist/chat_models/responses-types.d.cts +37 -7
  11. package/dist/chat_models/responses-types.d.cts.map +1 -1
  12. package/dist/chat_models/responses-types.d.ts +37 -7
  13. package/dist/chat_models/responses-types.d.ts.map +1 -1
  14. package/dist/chat_models/responses.cjs +5 -0
  15. package/dist/chat_models/responses.cjs.map +1 -1
  16. package/dist/chat_models/responses.d.cts +2 -1
  17. package/dist/chat_models/responses.d.cts.map +1 -1
  18. package/dist/chat_models/responses.d.ts +2 -1
  19. package/dist/chat_models/responses.d.ts.map +1 -1
  20. package/dist/chat_models/responses.js +5 -0
  21. package/dist/chat_models/responses.js.map +1 -1
  22. package/dist/tools/code_execution.cjs +52 -0
  23. package/dist/tools/code_execution.cjs.map +1 -0
  24. package/dist/tools/code_execution.d.cts +64 -0
  25. package/dist/tools/code_execution.d.cts.map +1 -0
  26. package/dist/tools/code_execution.d.ts +64 -0
  27. package/dist/tools/code_execution.d.ts.map +1 -0
  28. package/dist/tools/code_execution.js +50 -0
  29. package/dist/tools/code_execution.js.map +1 -0
  30. package/dist/tools/collections_search.cjs +60 -0
  31. package/dist/tools/collections_search.cjs.map +1 -0
  32. package/dist/tools/collections_search.d.cts +90 -0
  33. package/dist/tools/collections_search.d.cts.map +1 -0
  34. package/dist/tools/collections_search.d.ts +90 -0
  35. package/dist/tools/collections_search.d.ts.map +1 -0
  36. package/dist/tools/collections_search.js +58 -0
  37. package/dist/tools/collections_search.js.map +1 -0
  38. package/dist/tools/index.cjs +11 -1
  39. package/dist/tools/index.cjs.map +1 -1
  40. package/dist/tools/index.d.cts +10 -1
  41. package/dist/tools/index.d.cts.map +1 -1
  42. package/dist/tools/index.d.ts +10 -1
  43. package/dist/tools/index.d.ts.map +1 -1
  44. package/dist/tools/index.js +12 -2
  45. package/dist/tools/index.js.map +1 -1
  46. package/dist/tools/live_search.cjs +14 -0
  47. package/dist/tools/live_search.cjs.map +1 -1
  48. package/dist/tools/live_search.d.cts +14 -1
  49. package/dist/tools/live_search.d.cts.map +1 -1
  50. package/dist/tools/live_search.d.ts +14 -1
  51. package/dist/tools/live_search.d.ts.map +1 -1
  52. package/dist/tools/live_search.js +14 -1
  53. package/dist/tools/live_search.js.map +1 -1
  54. package/dist/tools/web_search.cjs +57 -0
  55. package/dist/tools/web_search.cjs.map +1 -0
  56. package/dist/tools/web_search.d.cts +104 -0
  57. package/dist/tools/web_search.d.cts.map +1 -0
  58. package/dist/tools/web_search.d.ts +104 -0
  59. package/dist/tools/web_search.d.ts.map +1 -0
  60. package/dist/tools/web_search.js +55 -0
  61. package/dist/tools/web_search.js.map +1 -0
  62. package/dist/tools/x_search.cjs +63 -0
  63. package/dist/tools/x_search.cjs.map +1 -0
  64. package/dist/tools/x_search.d.cts +145 -0
  65. package/dist/tools/x_search.d.cts.map +1 -0
  66. package/dist/tools/x_search.d.ts +145 -0
  67. package/dist/tools/x_search.d.ts.map +1 -0
  68. package/dist/tools/x_search.js +61 -0
  69. package/dist/tools/x_search.js.map +1 -0
  70. package/package.json +5 -5
@@ -0,0 +1,52 @@
1
+
2
+ //#region src/tools/code_execution.ts
3
+ /**
4
+ * xAI Code Execution tool type constant.
5
+ * Note: The Responses API uses "code_interpreter" as the type name.
6
+ */
7
+ const XAI_CODE_EXECUTION_TOOL_TYPE = "code_interpreter";
8
+ /**
9
+ * Creates an xAI code execution tool.
10
+ * Enables the model to write and execute Python code in real-time for
11
+ * calculations, data analysis, and complex computations.
12
+ *
13
+ * This tool is executed server-side by the xAI API in a secure, sandboxed
14
+ * Python environment with common libraries pre-installed (NumPy, Pandas,
15
+ * Matplotlib, SciPy).
16
+ *
17
+ * @returns An XAICodeExecutionTool object to pass to the model
18
+ *
19
+ * @example Basic usage
20
+ * ```typescript
21
+ * import { ChatXAIResponses, tools } from "@langchain/xai";
22
+ *
23
+ * const llm = new ChatXAIResponses({
24
+ * model: "grok-4-1-fast",
25
+ * });
26
+ *
27
+ * const codeExecution = tools.xaiCodeExecution();
28
+ * const result = await llm.invoke(
29
+ * "Calculate the compound interest for $10,000 at 5% annually for 10 years",
30
+ * { tools: [codeExecution] }
31
+ * );
32
+ * ```
33
+ *
34
+ * @example Combining with search tools
35
+ * ```typescript
36
+ * const webSearch = tools.xaiWebSearch();
37
+ * const codeExecution = tools.xaiCodeExecution();
38
+ *
39
+ * const result = await llm.invoke(
40
+ * "Find the current stock price of AAPL and calculate what it would be worth with 10% annual growth over 5 years",
41
+ * { tools: [webSearch, codeExecution] }
42
+ * );
43
+ * ```
44
+ */
45
+ function xaiCodeExecution() {
46
+ return { type: XAI_CODE_EXECUTION_TOOL_TYPE };
47
+ }
48
+
49
+ //#endregion
50
+ exports.XAI_CODE_EXECUTION_TOOL_TYPE = XAI_CODE_EXECUTION_TOOL_TYPE;
51
+ exports.xaiCodeExecution = xaiCodeExecution;
52
+ //# sourceMappingURL=code_execution.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code_execution.cjs","names":[],"sources":["../../src/tools/code_execution.ts"],"sourcesContent":["/**\n * xAI Code Execution tool type constant.\n * Note: The Responses API uses \"code_interpreter\" as the type name.\n */\nexport const XAI_CODE_EXECUTION_TOOL_TYPE = \"code_interpreter\";\n\n/**\n * xAI's built-in code execution tool interface.\n * Enables the model to write and execute Python code in real-time.\n *\n * This tool is part of xAI's agentic tool calling API and allows for:\n * - Mathematical computations\n * - Data analysis\n * - Financial modeling\n * - Scientific computing\n * - Code generation and testing\n */\nexport interface XAICodeExecutionTool {\n /**\n * The type of the tool. Must be \"code_interpreter\".\n */\n type: typeof XAI_CODE_EXECUTION_TOOL_TYPE;\n}\n\n/**\n * Creates an xAI code execution tool.\n * Enables the model to write and execute Python code in real-time for\n * calculations, data analysis, and complex computations.\n *\n * This tool is executed server-side by the xAI API in a secure, sandboxed\n * Python environment with common libraries pre-installed (NumPy, Pandas,\n * Matplotlib, SciPy).\n *\n * @returns An XAICodeExecutionTool object to pass to the model\n *\n * @example Basic usage\n * ```typescript\n * import { ChatXAIResponses, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAIResponses({\n * model: \"grok-4-1-fast\",\n * });\n *\n * const codeExecution = tools.xaiCodeExecution();\n * const result = await llm.invoke(\n * \"Calculate the compound interest for $10,000 at 5% annually for 10 years\",\n * { tools: [codeExecution] }\n * );\n * ```\n *\n * @example Combining with search tools\n * ```typescript\n * const webSearch = tools.xaiWebSearch();\n * const codeExecution = tools.xaiCodeExecution();\n *\n * const result = await llm.invoke(\n * \"Find the current stock price of AAPL and calculate what it would be worth with 10% annual growth over 5 years\",\n * { tools: [webSearch, codeExecution] }\n * );\n * ```\n */\nexport function xaiCodeExecution(): XAICodeExecutionTool {\n return {\n type: XAI_CODE_EXECUTION_TOOL_TYPE,\n };\n}\n"],"mappings":";;;;;;AAIA,MAAa,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyD5C,SAAgB,mBAAyC;AACvD,QAAO,EACL,MAAM,6BACP;AACF"}
@@ -0,0 +1,64 @@
1
+ //#region src/tools/code_execution.d.ts
2
+ /**
3
+ * xAI Code Execution tool type constant.
4
+ * Note: The Responses API uses "code_interpreter" as the type name.
5
+ */
6
+ declare const XAI_CODE_EXECUTION_TOOL_TYPE = "code_interpreter";
7
+ /**
8
+ * xAI's built-in code execution tool interface.
9
+ * Enables the model to write and execute Python code in real-time.
10
+ *
11
+ * This tool is part of xAI's agentic tool calling API and allows for:
12
+ * - Mathematical computations
13
+ * - Data analysis
14
+ * - Financial modeling
15
+ * - Scientific computing
16
+ * - Code generation and testing
17
+ */
18
+ interface XAICodeExecutionTool {
19
+ /**
20
+ * The type of the tool. Must be "code_interpreter".
21
+ */
22
+ type: typeof XAI_CODE_EXECUTION_TOOL_TYPE;
23
+ }
24
+ /**
25
+ * Creates an xAI code execution tool.
26
+ * Enables the model to write and execute Python code in real-time for
27
+ * calculations, data analysis, and complex computations.
28
+ *
29
+ * This tool is executed server-side by the xAI API in a secure, sandboxed
30
+ * Python environment with common libraries pre-installed (NumPy, Pandas,
31
+ * Matplotlib, SciPy).
32
+ *
33
+ * @returns An XAICodeExecutionTool object to pass to the model
34
+ *
35
+ * @example Basic usage
36
+ * ```typescript
37
+ * import { ChatXAIResponses, tools } from "@langchain/xai";
38
+ *
39
+ * const llm = new ChatXAIResponses({
40
+ * model: "grok-4-1-fast",
41
+ * });
42
+ *
43
+ * const codeExecution = tools.xaiCodeExecution();
44
+ * const result = await llm.invoke(
45
+ * "Calculate the compound interest for $10,000 at 5% annually for 10 years",
46
+ * { tools: [codeExecution] }
47
+ * );
48
+ * ```
49
+ *
50
+ * @example Combining with search tools
51
+ * ```typescript
52
+ * const webSearch = tools.xaiWebSearch();
53
+ * const codeExecution = tools.xaiCodeExecution();
54
+ *
55
+ * const result = await llm.invoke(
56
+ * "Find the current stock price of AAPL and calculate what it would be worth with 10% annual growth over 5 years",
57
+ * { tools: [webSearch, codeExecution] }
58
+ * );
59
+ * ```
60
+ */
61
+ declare function xaiCodeExecution(): XAICodeExecutionTool;
62
+ //#endregion
63
+ export { XAICodeExecutionTool, XAI_CODE_EXECUTION_TOOL_TYPE, xaiCodeExecution };
64
+ //# sourceMappingURL=code_execution.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code_execution.d.cts","names":["XAI_CODE_EXECUTION_TOOL_TYPE","XAICodeExecutionTool","xaiCodeExecution"],"sources":["../../src/tools/code_execution.d.ts"],"sourcesContent":["/**\n * xAI Code Execution tool type constant.\n * Note: The Responses API uses \"code_interpreter\" as the type name.\n */\nexport declare const XAI_CODE_EXECUTION_TOOL_TYPE = \"code_interpreter\";\n/**\n * xAI's built-in code execution tool interface.\n * Enables the model to write and execute Python code in real-time.\n *\n * This tool is part of xAI's agentic tool calling API and allows for:\n * - Mathematical computations\n * - Data analysis\n * - Financial modeling\n * - Scientific computing\n * - Code generation and testing\n */\nexport interface XAICodeExecutionTool {\n /**\n * The type of the tool. Must be \"code_interpreter\".\n */\n type: typeof XAI_CODE_EXECUTION_TOOL_TYPE;\n}\n/**\n * Creates an xAI code execution tool.\n * Enables the model to write and execute Python code in real-time for\n * calculations, data analysis, and complex computations.\n *\n * This tool is executed server-side by the xAI API in a secure, sandboxed\n * Python environment with common libraries pre-installed (NumPy, Pandas,\n * Matplotlib, SciPy).\n *\n * @returns An XAICodeExecutionTool object to pass to the model\n *\n * @example Basic usage\n * ```typescript\n * import { ChatXAIResponses, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAIResponses({\n * model: \"grok-4-1-fast\",\n * });\n *\n * const codeExecution = tools.xaiCodeExecution();\n * const result = await llm.invoke(\n * \"Calculate the compound interest for $10,000 at 5% annually for 10 years\",\n * { tools: [codeExecution] }\n * );\n * ```\n *\n * @example Combining with search tools\n * ```typescript\n * const webSearch = tools.xaiWebSearch();\n * const codeExecution = tools.xaiCodeExecution();\n *\n * const result = await llm.invoke(\n * \"Find the current stock price of AAPL and calculate what it would be worth with 10% annual growth over 5 years\",\n * { tools: [webSearch, codeExecution] }\n * );\n * ```\n */\nexport declare function xaiCodeExecution(): XAICodeExecutionTool;\n//# sourceMappingURL=code_execution.d.ts.map"],"mappings":";;AAIA;AAYA;AA2CA;cAvDqBA,4BAAAA;;;;;;;;;;;;UAYJC,oBAAAA;;;;eAIAD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuCOE,gBAAAA,CAAAA,GAAoBD"}
@@ -0,0 +1,64 @@
1
+ //#region src/tools/code_execution.d.ts
2
+ /**
3
+ * xAI Code Execution tool type constant.
4
+ * Note: The Responses API uses "code_interpreter" as the type name.
5
+ */
6
+ declare const XAI_CODE_EXECUTION_TOOL_TYPE = "code_interpreter";
7
+ /**
8
+ * xAI's built-in code execution tool interface.
9
+ * Enables the model to write and execute Python code in real-time.
10
+ *
11
+ * This tool is part of xAI's agentic tool calling API and allows for:
12
+ * - Mathematical computations
13
+ * - Data analysis
14
+ * - Financial modeling
15
+ * - Scientific computing
16
+ * - Code generation and testing
17
+ */
18
+ interface XAICodeExecutionTool {
19
+ /**
20
+ * The type of the tool. Must be "code_interpreter".
21
+ */
22
+ type: typeof XAI_CODE_EXECUTION_TOOL_TYPE;
23
+ }
24
+ /**
25
+ * Creates an xAI code execution tool.
26
+ * Enables the model to write and execute Python code in real-time for
27
+ * calculations, data analysis, and complex computations.
28
+ *
29
+ * This tool is executed server-side by the xAI API in a secure, sandboxed
30
+ * Python environment with common libraries pre-installed (NumPy, Pandas,
31
+ * Matplotlib, SciPy).
32
+ *
33
+ * @returns An XAICodeExecutionTool object to pass to the model
34
+ *
35
+ * @example Basic usage
36
+ * ```typescript
37
+ * import { ChatXAIResponses, tools } from "@langchain/xai";
38
+ *
39
+ * const llm = new ChatXAIResponses({
40
+ * model: "grok-4-1-fast",
41
+ * });
42
+ *
43
+ * const codeExecution = tools.xaiCodeExecution();
44
+ * const result = await llm.invoke(
45
+ * "Calculate the compound interest for $10,000 at 5% annually for 10 years",
46
+ * { tools: [codeExecution] }
47
+ * );
48
+ * ```
49
+ *
50
+ * @example Combining with search tools
51
+ * ```typescript
52
+ * const webSearch = tools.xaiWebSearch();
53
+ * const codeExecution = tools.xaiCodeExecution();
54
+ *
55
+ * const result = await llm.invoke(
56
+ * "Find the current stock price of AAPL and calculate what it would be worth with 10% annual growth over 5 years",
57
+ * { tools: [webSearch, codeExecution] }
58
+ * );
59
+ * ```
60
+ */
61
+ declare function xaiCodeExecution(): XAICodeExecutionTool;
62
+ //#endregion
63
+ export { XAICodeExecutionTool, XAI_CODE_EXECUTION_TOOL_TYPE, xaiCodeExecution };
64
+ //# sourceMappingURL=code_execution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code_execution.d.ts","names":["XAI_CODE_EXECUTION_TOOL_TYPE","XAICodeExecutionTool","xaiCodeExecution"],"sources":["../../src/tools/code_execution.d.ts"],"sourcesContent":["/**\n * xAI Code Execution tool type constant.\n * Note: The Responses API uses \"code_interpreter\" as the type name.\n */\nexport declare const XAI_CODE_EXECUTION_TOOL_TYPE = \"code_interpreter\";\n/**\n * xAI's built-in code execution tool interface.\n * Enables the model to write and execute Python code in real-time.\n *\n * This tool is part of xAI's agentic tool calling API and allows for:\n * - Mathematical computations\n * - Data analysis\n * - Financial modeling\n * - Scientific computing\n * - Code generation and testing\n */\nexport interface XAICodeExecutionTool {\n /**\n * The type of the tool. Must be \"code_interpreter\".\n */\n type: typeof XAI_CODE_EXECUTION_TOOL_TYPE;\n}\n/**\n * Creates an xAI code execution tool.\n * Enables the model to write and execute Python code in real-time for\n * calculations, data analysis, and complex computations.\n *\n * This tool is executed server-side by the xAI API in a secure, sandboxed\n * Python environment with common libraries pre-installed (NumPy, Pandas,\n * Matplotlib, SciPy).\n *\n * @returns An XAICodeExecutionTool object to pass to the model\n *\n * @example Basic usage\n * ```typescript\n * import { ChatXAIResponses, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAIResponses({\n * model: \"grok-4-1-fast\",\n * });\n *\n * const codeExecution = tools.xaiCodeExecution();\n * const result = await llm.invoke(\n * \"Calculate the compound interest for $10,000 at 5% annually for 10 years\",\n * { tools: [codeExecution] }\n * );\n * ```\n *\n * @example Combining with search tools\n * ```typescript\n * const webSearch = tools.xaiWebSearch();\n * const codeExecution = tools.xaiCodeExecution();\n *\n * const result = await llm.invoke(\n * \"Find the current stock price of AAPL and calculate what it would be worth with 10% annual growth over 5 years\",\n * { tools: [webSearch, codeExecution] }\n * );\n * ```\n */\nexport declare function xaiCodeExecution(): XAICodeExecutionTool;\n//# sourceMappingURL=code_execution.d.ts.map"],"mappings":";;AAIA;AAYA;AA2CA;cAvDqBA,4BAAAA;;;;;;;;;;;;UAYJC,oBAAAA;;;;eAIAD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuCOE,gBAAAA,CAAAA,GAAoBD"}
@@ -0,0 +1,50 @@
1
+ //#region src/tools/code_execution.ts
2
+ /**
3
+ * xAI Code Execution tool type constant.
4
+ * Note: The Responses API uses "code_interpreter" as the type name.
5
+ */
6
+ const XAI_CODE_EXECUTION_TOOL_TYPE = "code_interpreter";
7
+ /**
8
+ * Creates an xAI code execution tool.
9
+ * Enables the model to write and execute Python code in real-time for
10
+ * calculations, data analysis, and complex computations.
11
+ *
12
+ * This tool is executed server-side by the xAI API in a secure, sandboxed
13
+ * Python environment with common libraries pre-installed (NumPy, Pandas,
14
+ * Matplotlib, SciPy).
15
+ *
16
+ * @returns An XAICodeExecutionTool object to pass to the model
17
+ *
18
+ * @example Basic usage
19
+ * ```typescript
20
+ * import { ChatXAIResponses, tools } from "@langchain/xai";
21
+ *
22
+ * const llm = new ChatXAIResponses({
23
+ * model: "grok-4-1-fast",
24
+ * });
25
+ *
26
+ * const codeExecution = tools.xaiCodeExecution();
27
+ * const result = await llm.invoke(
28
+ * "Calculate the compound interest for $10,000 at 5% annually for 10 years",
29
+ * { tools: [codeExecution] }
30
+ * );
31
+ * ```
32
+ *
33
+ * @example Combining with search tools
34
+ * ```typescript
35
+ * const webSearch = tools.xaiWebSearch();
36
+ * const codeExecution = tools.xaiCodeExecution();
37
+ *
38
+ * const result = await llm.invoke(
39
+ * "Find the current stock price of AAPL and calculate what it would be worth with 10% annual growth over 5 years",
40
+ * { tools: [webSearch, codeExecution] }
41
+ * );
42
+ * ```
43
+ */
44
+ function xaiCodeExecution() {
45
+ return { type: XAI_CODE_EXECUTION_TOOL_TYPE };
46
+ }
47
+
48
+ //#endregion
49
+ export { XAI_CODE_EXECUTION_TOOL_TYPE, xaiCodeExecution };
50
+ //# sourceMappingURL=code_execution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code_execution.js","names":[],"sources":["../../src/tools/code_execution.ts"],"sourcesContent":["/**\n * xAI Code Execution tool type constant.\n * Note: The Responses API uses \"code_interpreter\" as the type name.\n */\nexport const XAI_CODE_EXECUTION_TOOL_TYPE = \"code_interpreter\";\n\n/**\n * xAI's built-in code execution tool interface.\n * Enables the model to write and execute Python code in real-time.\n *\n * This tool is part of xAI's agentic tool calling API and allows for:\n * - Mathematical computations\n * - Data analysis\n * - Financial modeling\n * - Scientific computing\n * - Code generation and testing\n */\nexport interface XAICodeExecutionTool {\n /**\n * The type of the tool. Must be \"code_interpreter\".\n */\n type: typeof XAI_CODE_EXECUTION_TOOL_TYPE;\n}\n\n/**\n * Creates an xAI code execution tool.\n * Enables the model to write and execute Python code in real-time for\n * calculations, data analysis, and complex computations.\n *\n * This tool is executed server-side by the xAI API in a secure, sandboxed\n * Python environment with common libraries pre-installed (NumPy, Pandas,\n * Matplotlib, SciPy).\n *\n * @returns An XAICodeExecutionTool object to pass to the model\n *\n * @example Basic usage\n * ```typescript\n * import { ChatXAIResponses, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAIResponses({\n * model: \"grok-4-1-fast\",\n * });\n *\n * const codeExecution = tools.xaiCodeExecution();\n * const result = await llm.invoke(\n * \"Calculate the compound interest for $10,000 at 5% annually for 10 years\",\n * { tools: [codeExecution] }\n * );\n * ```\n *\n * @example Combining with search tools\n * ```typescript\n * const webSearch = tools.xaiWebSearch();\n * const codeExecution = tools.xaiCodeExecution();\n *\n * const result = await llm.invoke(\n * \"Find the current stock price of AAPL and calculate what it would be worth with 10% annual growth over 5 years\",\n * { tools: [webSearch, codeExecution] }\n * );\n * ```\n */\nexport function xaiCodeExecution(): XAICodeExecutionTool {\n return {\n type: XAI_CODE_EXECUTION_TOOL_TYPE,\n };\n}\n"],"mappings":";;;;;AAIA,MAAa,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyD5C,SAAgB,mBAAyC;AACvD,QAAO,EACL,MAAM,6BACP;AACF"}
@@ -0,0 +1,60 @@
1
+
2
+ //#region src/tools/collections_search.ts
3
+ /**
4
+ * xAI Collections Search tool type constant.
5
+ * Note: The Responses API uses "file_search" as the type name.
6
+ */
7
+ const XAI_COLLECTIONS_SEARCH_TOOL_TYPE = "file_search";
8
+ /**
9
+ * Creates an xAI collections search tool.
10
+ * Enables the model to search through your uploaded knowledge bases (collections)
11
+ * to retrieve relevant information from your documents.
12
+ *
13
+ * This tool is executed server-side by the xAI API as part of the agentic
14
+ * tool calling workflow.
15
+ *
16
+ * @param options - Configuration options for the collections search tool
17
+ * @returns An XAICollectionsSearchTool object to pass to the model
18
+ *
19
+ * @example Basic usage with collection IDs
20
+ * ```typescript
21
+ * import { ChatXAIResponses, tools } from "@langchain/xai";
22
+ *
23
+ * const llm = new ChatXAIResponses({
24
+ * model: "grok-4-1-fast",
25
+ * });
26
+ *
27
+ * const collectionsSearch = tools.xaiCollectionsSearch({
28
+ * vectorStoreIds: ["collection_abc123"],
29
+ * });
30
+ *
31
+ * const result = await llm.invoke(
32
+ * "What are the key findings in the Q3 report?",
33
+ * { tools: [collectionsSearch] }
34
+ * );
35
+ * ```
36
+ *
37
+ * @example Combining with other tools for hybrid analysis
38
+ * ```typescript
39
+ * const collectionsSearch = tools.xaiCollectionsSearch({
40
+ * vectorStoreIds: ["collection_sec_filings"],
41
+ * });
42
+ * const webSearch = tools.xaiWebSearch();
43
+ * const codeExecution = tools.xaiCodeExecution();
44
+ *
45
+ * const result = await llm.invoke(
46
+ * "Based on our internal SEC filings, what is the market sentiment on our performance?",
47
+ * { tools: [collectionsSearch, webSearch, codeExecution] }
48
+ * );
49
+ * ```
50
+ */
51
+ function xaiCollectionsSearch(options = {}) {
52
+ const tool = { type: XAI_COLLECTIONS_SEARCH_TOOL_TYPE };
53
+ if (options.vectorStoreIds !== void 0) tool.vector_store_ids = options.vectorStoreIds;
54
+ return tool;
55
+ }
56
+
57
+ //#endregion
58
+ exports.XAI_COLLECTIONS_SEARCH_TOOL_TYPE = XAI_COLLECTIONS_SEARCH_TOOL_TYPE;
59
+ exports.xaiCollectionsSearch = xaiCollectionsSearch;
60
+ //# sourceMappingURL=collections_search.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collections_search.cjs","names":["options: XAICollectionsSearchToolOptions","tool: XAICollectionsSearchTool"],"sources":["../../src/tools/collections_search.ts"],"sourcesContent":["/**\n * xAI Collections Search tool type constant.\n * Note: The Responses API uses \"file_search\" as the type name.\n */\nexport const XAI_COLLECTIONS_SEARCH_TOOL_TYPE = \"file_search\";\n\n/**\n * xAI's built-in collections search tool interface.\n * Enables the model to search through uploaded knowledge bases (collections)\n * to retrieve relevant information from your documents.\n *\n * This tool is part of xAI's agentic tool calling API and is particularly\n * powerful for:\n * - Document retrieval from uploaded files\n * - Semantic search across knowledge bases\n * - RAG (Retrieval-Augmented Generation) applications\n * - Enterprise knowledge base queries\n */\nexport interface XAICollectionsSearchTool {\n /**\n * The type of the tool. Must be \"file_search\".\n */\n type: typeof XAI_COLLECTIONS_SEARCH_TOOL_TYPE;\n /**\n * List of vector store (collection) IDs to search.\n * These are the IDs of collections created via the xAI Collections API.\n */\n vector_store_ids?: string[];\n}\n\n/**\n * Options for the xAI collections search tool (camelCase).\n * All fields are camel-cased for the TypeScript API and are mapped to the\n * corresponding snake_case fields in the API request.\n */\nexport interface XAICollectionsSearchToolOptions {\n /**\n * List of vector store (collection) IDs to search.\n * These are the IDs of collections created via the xAI Collections API.\n *\n * @example [\"collection_abc123\", \"collection_def456\"]\n */\n vectorStoreIds?: string[];\n}\n\n/**\n * Creates an xAI collections search tool.\n * Enables the model to search through your uploaded knowledge bases (collections)\n * to retrieve relevant information from your documents.\n *\n * This tool is executed server-side by the xAI API as part of the agentic\n * tool calling workflow.\n *\n * @param options - Configuration options for the collections search tool\n * @returns An XAICollectionsSearchTool object to pass to the model\n *\n * @example Basic usage with collection IDs\n * ```typescript\n * import { ChatXAIResponses, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAIResponses({\n * model: \"grok-4-1-fast\",\n * });\n *\n * const collectionsSearch = tools.xaiCollectionsSearch({\n * vectorStoreIds: [\"collection_abc123\"],\n * });\n *\n * const result = await llm.invoke(\n * \"What are the key findings in the Q3 report?\",\n * { tools: [collectionsSearch] }\n * );\n * ```\n *\n * @example Combining with other tools for hybrid analysis\n * ```typescript\n * const collectionsSearch = tools.xaiCollectionsSearch({\n * vectorStoreIds: [\"collection_sec_filings\"],\n * });\n * const webSearch = tools.xaiWebSearch();\n * const codeExecution = tools.xaiCodeExecution();\n *\n * const result = await llm.invoke(\n * \"Based on our internal SEC filings, what is the market sentiment on our performance?\",\n * { tools: [collectionsSearch, webSearch, codeExecution] }\n * );\n * ```\n */\nexport function xaiCollectionsSearch(\n options: XAICollectionsSearchToolOptions = {}\n): XAICollectionsSearchTool {\n const tool: XAICollectionsSearchTool = {\n type: XAI_COLLECTIONS_SEARCH_TOOL_TYPE,\n };\n\n if (options.vectorStoreIds !== undefined) {\n tool.vector_store_ids = options.vectorStoreIds;\n }\n\n return tool;\n}\n"],"mappings":";;;;;;AAIA,MAAa,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFhD,SAAgB,qBACdA,UAA2C,CAAE,GACnB;CAC1B,MAAMC,OAAiC,EACrC,MAAM,iCACP;AAED,KAAI,QAAQ,mBAAmB,QAC7B,KAAK,mBAAmB,QAAQ;AAGlC,QAAO;AACR"}
@@ -0,0 +1,90 @@
1
+ //#region src/tools/collections_search.d.ts
2
+ /**
3
+ * xAI Collections Search tool type constant.
4
+ * Note: The Responses API uses "file_search" as the type name.
5
+ */
6
+ declare const XAI_COLLECTIONS_SEARCH_TOOL_TYPE = "file_search";
7
+ /**
8
+ * xAI's built-in collections search tool interface.
9
+ * Enables the model to search through uploaded knowledge bases (collections)
10
+ * to retrieve relevant information from your documents.
11
+ *
12
+ * This tool is part of xAI's agentic tool calling API and is particularly
13
+ * powerful for:
14
+ * - Document retrieval from uploaded files
15
+ * - Semantic search across knowledge bases
16
+ * - RAG (Retrieval-Augmented Generation) applications
17
+ * - Enterprise knowledge base queries
18
+ */
19
+ interface XAICollectionsSearchTool {
20
+ /**
21
+ * The type of the tool. Must be "file_search".
22
+ */
23
+ type: typeof XAI_COLLECTIONS_SEARCH_TOOL_TYPE;
24
+ /**
25
+ * List of vector store (collection) IDs to search.
26
+ * These are the IDs of collections created via the xAI Collections API.
27
+ */
28
+ vector_store_ids?: string[];
29
+ }
30
+ /**
31
+ * Options for the xAI collections search tool (camelCase).
32
+ * All fields are camel-cased for the TypeScript API and are mapped to the
33
+ * corresponding snake_case fields in the API request.
34
+ */
35
+ interface XAICollectionsSearchToolOptions {
36
+ /**
37
+ * List of vector store (collection) IDs to search.
38
+ * These are the IDs of collections created via the xAI Collections API.
39
+ *
40
+ * @example ["collection_abc123", "collection_def456"]
41
+ */
42
+ vectorStoreIds?: string[];
43
+ }
44
+ /**
45
+ * Creates an xAI collections search tool.
46
+ * Enables the model to search through your uploaded knowledge bases (collections)
47
+ * to retrieve relevant information from your documents.
48
+ *
49
+ * This tool is executed server-side by the xAI API as part of the agentic
50
+ * tool calling workflow.
51
+ *
52
+ * @param options - Configuration options for the collections search tool
53
+ * @returns An XAICollectionsSearchTool object to pass to the model
54
+ *
55
+ * @example Basic usage with collection IDs
56
+ * ```typescript
57
+ * import { ChatXAIResponses, tools } from "@langchain/xai";
58
+ *
59
+ * const llm = new ChatXAIResponses({
60
+ * model: "grok-4-1-fast",
61
+ * });
62
+ *
63
+ * const collectionsSearch = tools.xaiCollectionsSearch({
64
+ * vectorStoreIds: ["collection_abc123"],
65
+ * });
66
+ *
67
+ * const result = await llm.invoke(
68
+ * "What are the key findings in the Q3 report?",
69
+ * { tools: [collectionsSearch] }
70
+ * );
71
+ * ```
72
+ *
73
+ * @example Combining with other tools for hybrid analysis
74
+ * ```typescript
75
+ * const collectionsSearch = tools.xaiCollectionsSearch({
76
+ * vectorStoreIds: ["collection_sec_filings"],
77
+ * });
78
+ * const webSearch = tools.xaiWebSearch();
79
+ * const codeExecution = tools.xaiCodeExecution();
80
+ *
81
+ * const result = await llm.invoke(
82
+ * "Based on our internal SEC filings, what is the market sentiment on our performance?",
83
+ * { tools: [collectionsSearch, webSearch, codeExecution] }
84
+ * );
85
+ * ```
86
+ */
87
+ declare function xaiCollectionsSearch(options?: XAICollectionsSearchToolOptions): XAICollectionsSearchTool;
88
+ //#endregion
89
+ export { XAICollectionsSearchTool, XAICollectionsSearchToolOptions, XAI_COLLECTIONS_SEARCH_TOOL_TYPE, xaiCollectionsSearch };
90
+ //# sourceMappingURL=collections_search.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collections_search.d.cts","names":["XAI_COLLECTIONS_SEARCH_TOOL_TYPE","XAICollectionsSearchTool","XAICollectionsSearchToolOptions","xaiCollectionsSearch"],"sources":["../../src/tools/collections_search.d.ts"],"sourcesContent":["/**\n * xAI Collections Search tool type constant.\n * Note: The Responses API uses \"file_search\" as the type name.\n */\nexport declare const XAI_COLLECTIONS_SEARCH_TOOL_TYPE = \"file_search\";\n/**\n * xAI's built-in collections search tool interface.\n * Enables the model to search through uploaded knowledge bases (collections)\n * to retrieve relevant information from your documents.\n *\n * This tool is part of xAI's agentic tool calling API and is particularly\n * powerful for:\n * - Document retrieval from uploaded files\n * - Semantic search across knowledge bases\n * - RAG (Retrieval-Augmented Generation) applications\n * - Enterprise knowledge base queries\n */\nexport interface XAICollectionsSearchTool {\n /**\n * The type of the tool. Must be \"file_search\".\n */\n type: typeof XAI_COLLECTIONS_SEARCH_TOOL_TYPE;\n /**\n * List of vector store (collection) IDs to search.\n * These are the IDs of collections created via the xAI Collections API.\n */\n vector_store_ids?: string[];\n}\n/**\n * Options for the xAI collections search tool (camelCase).\n * All fields are camel-cased for the TypeScript API and are mapped to the\n * corresponding snake_case fields in the API request.\n */\nexport interface XAICollectionsSearchToolOptions {\n /**\n * List of vector store (collection) IDs to search.\n * These are the IDs of collections created via the xAI Collections API.\n *\n * @example [\"collection_abc123\", \"collection_def456\"]\n */\n vectorStoreIds?: string[];\n}\n/**\n * Creates an xAI collections search tool.\n * Enables the model to search through your uploaded knowledge bases (collections)\n * to retrieve relevant information from your documents.\n *\n * This tool is executed server-side by the xAI API as part of the agentic\n * tool calling workflow.\n *\n * @param options - Configuration options for the collections search tool\n * @returns An XAICollectionsSearchTool object to pass to the model\n *\n * @example Basic usage with collection IDs\n * ```typescript\n * import { ChatXAIResponses, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAIResponses({\n * model: \"grok-4-1-fast\",\n * });\n *\n * const collectionsSearch = tools.xaiCollectionsSearch({\n * vectorStoreIds: [\"collection_abc123\"],\n * });\n *\n * const result = await llm.invoke(\n * \"What are the key findings in the Q3 report?\",\n * { tools: [collectionsSearch] }\n * );\n * ```\n *\n * @example Combining with other tools for hybrid analysis\n * ```typescript\n * const collectionsSearch = tools.xaiCollectionsSearch({\n * vectorStoreIds: [\"collection_sec_filings\"],\n * });\n * const webSearch = tools.xaiWebSearch();\n * const codeExecution = tools.xaiCodeExecution();\n *\n * const result = await llm.invoke(\n * \"Based on our internal SEC filings, what is the market sentiment on our performance?\",\n * { tools: [collectionsSearch, webSearch, codeExecution] }\n * );\n * ```\n */\nexport declare function xaiCollectionsSearch(options?: XAICollectionsSearchToolOptions): XAICollectionsSearchTool;\n//# sourceMappingURL=collections_search.d.ts.map"],"mappings":";;AAIA;AAaA;AAgBA;AAoDwBG,cAjFHH,gCAAAA,GAiFkCE,aAAAA;;;;;;;;;;;;;UApEtCD,wBAAAA;;;;eAIAD;;;;;;;;;;;;UAYAE,+BAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoDOC,oBAAAA,WAA+BD,kCAAkCD"}
@@ -0,0 +1,90 @@
1
+ //#region src/tools/collections_search.d.ts
2
+ /**
3
+ * xAI Collections Search tool type constant.
4
+ * Note: The Responses API uses "file_search" as the type name.
5
+ */
6
+ declare const XAI_COLLECTIONS_SEARCH_TOOL_TYPE = "file_search";
7
+ /**
8
+ * xAI's built-in collections search tool interface.
9
+ * Enables the model to search through uploaded knowledge bases (collections)
10
+ * to retrieve relevant information from your documents.
11
+ *
12
+ * This tool is part of xAI's agentic tool calling API and is particularly
13
+ * powerful for:
14
+ * - Document retrieval from uploaded files
15
+ * - Semantic search across knowledge bases
16
+ * - RAG (Retrieval-Augmented Generation) applications
17
+ * - Enterprise knowledge base queries
18
+ */
19
+ interface XAICollectionsSearchTool {
20
+ /**
21
+ * The type of the tool. Must be "file_search".
22
+ */
23
+ type: typeof XAI_COLLECTIONS_SEARCH_TOOL_TYPE;
24
+ /**
25
+ * List of vector store (collection) IDs to search.
26
+ * These are the IDs of collections created via the xAI Collections API.
27
+ */
28
+ vector_store_ids?: string[];
29
+ }
30
+ /**
31
+ * Options for the xAI collections search tool (camelCase).
32
+ * All fields are camel-cased for the TypeScript API and are mapped to the
33
+ * corresponding snake_case fields in the API request.
34
+ */
35
+ interface XAICollectionsSearchToolOptions {
36
+ /**
37
+ * List of vector store (collection) IDs to search.
38
+ * These are the IDs of collections created via the xAI Collections API.
39
+ *
40
+ * @example ["collection_abc123", "collection_def456"]
41
+ */
42
+ vectorStoreIds?: string[];
43
+ }
44
+ /**
45
+ * Creates an xAI collections search tool.
46
+ * Enables the model to search through your uploaded knowledge bases (collections)
47
+ * to retrieve relevant information from your documents.
48
+ *
49
+ * This tool is executed server-side by the xAI API as part of the agentic
50
+ * tool calling workflow.
51
+ *
52
+ * @param options - Configuration options for the collections search tool
53
+ * @returns An XAICollectionsSearchTool object to pass to the model
54
+ *
55
+ * @example Basic usage with collection IDs
56
+ * ```typescript
57
+ * import { ChatXAIResponses, tools } from "@langchain/xai";
58
+ *
59
+ * const llm = new ChatXAIResponses({
60
+ * model: "grok-4-1-fast",
61
+ * });
62
+ *
63
+ * const collectionsSearch = tools.xaiCollectionsSearch({
64
+ * vectorStoreIds: ["collection_abc123"],
65
+ * });
66
+ *
67
+ * const result = await llm.invoke(
68
+ * "What are the key findings in the Q3 report?",
69
+ * { tools: [collectionsSearch] }
70
+ * );
71
+ * ```
72
+ *
73
+ * @example Combining with other tools for hybrid analysis
74
+ * ```typescript
75
+ * const collectionsSearch = tools.xaiCollectionsSearch({
76
+ * vectorStoreIds: ["collection_sec_filings"],
77
+ * });
78
+ * const webSearch = tools.xaiWebSearch();
79
+ * const codeExecution = tools.xaiCodeExecution();
80
+ *
81
+ * const result = await llm.invoke(
82
+ * "Based on our internal SEC filings, what is the market sentiment on our performance?",
83
+ * { tools: [collectionsSearch, webSearch, codeExecution] }
84
+ * );
85
+ * ```
86
+ */
87
+ declare function xaiCollectionsSearch(options?: XAICollectionsSearchToolOptions): XAICollectionsSearchTool;
88
+ //#endregion
89
+ export { XAICollectionsSearchTool, XAICollectionsSearchToolOptions, XAI_COLLECTIONS_SEARCH_TOOL_TYPE, xaiCollectionsSearch };
90
+ //# sourceMappingURL=collections_search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collections_search.d.ts","names":["XAI_COLLECTIONS_SEARCH_TOOL_TYPE","XAICollectionsSearchTool","XAICollectionsSearchToolOptions","xaiCollectionsSearch"],"sources":["../../src/tools/collections_search.d.ts"],"sourcesContent":["/**\n * xAI Collections Search tool type constant.\n * Note: The Responses API uses \"file_search\" as the type name.\n */\nexport declare const XAI_COLLECTIONS_SEARCH_TOOL_TYPE = \"file_search\";\n/**\n * xAI's built-in collections search tool interface.\n * Enables the model to search through uploaded knowledge bases (collections)\n * to retrieve relevant information from your documents.\n *\n * This tool is part of xAI's agentic tool calling API and is particularly\n * powerful for:\n * - Document retrieval from uploaded files\n * - Semantic search across knowledge bases\n * - RAG (Retrieval-Augmented Generation) applications\n * - Enterprise knowledge base queries\n */\nexport interface XAICollectionsSearchTool {\n /**\n * The type of the tool. Must be \"file_search\".\n */\n type: typeof XAI_COLLECTIONS_SEARCH_TOOL_TYPE;\n /**\n * List of vector store (collection) IDs to search.\n * These are the IDs of collections created via the xAI Collections API.\n */\n vector_store_ids?: string[];\n}\n/**\n * Options for the xAI collections search tool (camelCase).\n * All fields are camel-cased for the TypeScript API and are mapped to the\n * corresponding snake_case fields in the API request.\n */\nexport interface XAICollectionsSearchToolOptions {\n /**\n * List of vector store (collection) IDs to search.\n * These are the IDs of collections created via the xAI Collections API.\n *\n * @example [\"collection_abc123\", \"collection_def456\"]\n */\n vectorStoreIds?: string[];\n}\n/**\n * Creates an xAI collections search tool.\n * Enables the model to search through your uploaded knowledge bases (collections)\n * to retrieve relevant information from your documents.\n *\n * This tool is executed server-side by the xAI API as part of the agentic\n * tool calling workflow.\n *\n * @param options - Configuration options for the collections search tool\n * @returns An XAICollectionsSearchTool object to pass to the model\n *\n * @example Basic usage with collection IDs\n * ```typescript\n * import { ChatXAIResponses, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAIResponses({\n * model: \"grok-4-1-fast\",\n * });\n *\n * const collectionsSearch = tools.xaiCollectionsSearch({\n * vectorStoreIds: [\"collection_abc123\"],\n * });\n *\n * const result = await llm.invoke(\n * \"What are the key findings in the Q3 report?\",\n * { tools: [collectionsSearch] }\n * );\n * ```\n *\n * @example Combining with other tools for hybrid analysis\n * ```typescript\n * const collectionsSearch = tools.xaiCollectionsSearch({\n * vectorStoreIds: [\"collection_sec_filings\"],\n * });\n * const webSearch = tools.xaiWebSearch();\n * const codeExecution = tools.xaiCodeExecution();\n *\n * const result = await llm.invoke(\n * \"Based on our internal SEC filings, what is the market sentiment on our performance?\",\n * { tools: [collectionsSearch, webSearch, codeExecution] }\n * );\n * ```\n */\nexport declare function xaiCollectionsSearch(options?: XAICollectionsSearchToolOptions): XAICollectionsSearchTool;\n//# sourceMappingURL=collections_search.d.ts.map"],"mappings":";;AAIA;AAaA;AAgBA;AAoDwBG,cAjFHH,gCAAAA,GAiFkCE,aAAAA;;;;;;;;;;;;;UApEtCD,wBAAAA;;;;eAIAD;;;;;;;;;;;;UAYAE,+BAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoDOC,oBAAAA,WAA+BD,kCAAkCD"}
@@ -0,0 +1,58 @@
1
+ //#region src/tools/collections_search.ts
2
+ /**
3
+ * xAI Collections Search tool type constant.
4
+ * Note: The Responses API uses "file_search" as the type name.
5
+ */
6
+ const XAI_COLLECTIONS_SEARCH_TOOL_TYPE = "file_search";
7
+ /**
8
+ * Creates an xAI collections search tool.
9
+ * Enables the model to search through your uploaded knowledge bases (collections)
10
+ * to retrieve relevant information from your documents.
11
+ *
12
+ * This tool is executed server-side by the xAI API as part of the agentic
13
+ * tool calling workflow.
14
+ *
15
+ * @param options - Configuration options for the collections search tool
16
+ * @returns An XAICollectionsSearchTool object to pass to the model
17
+ *
18
+ * @example Basic usage with collection IDs
19
+ * ```typescript
20
+ * import { ChatXAIResponses, tools } from "@langchain/xai";
21
+ *
22
+ * const llm = new ChatXAIResponses({
23
+ * model: "grok-4-1-fast",
24
+ * });
25
+ *
26
+ * const collectionsSearch = tools.xaiCollectionsSearch({
27
+ * vectorStoreIds: ["collection_abc123"],
28
+ * });
29
+ *
30
+ * const result = await llm.invoke(
31
+ * "What are the key findings in the Q3 report?",
32
+ * { tools: [collectionsSearch] }
33
+ * );
34
+ * ```
35
+ *
36
+ * @example Combining with other tools for hybrid analysis
37
+ * ```typescript
38
+ * const collectionsSearch = tools.xaiCollectionsSearch({
39
+ * vectorStoreIds: ["collection_sec_filings"],
40
+ * });
41
+ * const webSearch = tools.xaiWebSearch();
42
+ * const codeExecution = tools.xaiCodeExecution();
43
+ *
44
+ * const result = await llm.invoke(
45
+ * "Based on our internal SEC filings, what is the market sentiment on our performance?",
46
+ * { tools: [collectionsSearch, webSearch, codeExecution] }
47
+ * );
48
+ * ```
49
+ */
50
+ function xaiCollectionsSearch(options = {}) {
51
+ const tool = { type: XAI_COLLECTIONS_SEARCH_TOOL_TYPE };
52
+ if (options.vectorStoreIds !== void 0) tool.vector_store_ids = options.vectorStoreIds;
53
+ return tool;
54
+ }
55
+
56
+ //#endregion
57
+ export { XAI_COLLECTIONS_SEARCH_TOOL_TYPE, xaiCollectionsSearch };
58
+ //# sourceMappingURL=collections_search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collections_search.js","names":["options: XAICollectionsSearchToolOptions","tool: XAICollectionsSearchTool"],"sources":["../../src/tools/collections_search.ts"],"sourcesContent":["/**\n * xAI Collections Search tool type constant.\n * Note: The Responses API uses \"file_search\" as the type name.\n */\nexport const XAI_COLLECTIONS_SEARCH_TOOL_TYPE = \"file_search\";\n\n/**\n * xAI's built-in collections search tool interface.\n * Enables the model to search through uploaded knowledge bases (collections)\n * to retrieve relevant information from your documents.\n *\n * This tool is part of xAI's agentic tool calling API and is particularly\n * powerful for:\n * - Document retrieval from uploaded files\n * - Semantic search across knowledge bases\n * - RAG (Retrieval-Augmented Generation) applications\n * - Enterprise knowledge base queries\n */\nexport interface XAICollectionsSearchTool {\n /**\n * The type of the tool. Must be \"file_search\".\n */\n type: typeof XAI_COLLECTIONS_SEARCH_TOOL_TYPE;\n /**\n * List of vector store (collection) IDs to search.\n * These are the IDs of collections created via the xAI Collections API.\n */\n vector_store_ids?: string[];\n}\n\n/**\n * Options for the xAI collections search tool (camelCase).\n * All fields are camel-cased for the TypeScript API and are mapped to the\n * corresponding snake_case fields in the API request.\n */\nexport interface XAICollectionsSearchToolOptions {\n /**\n * List of vector store (collection) IDs to search.\n * These are the IDs of collections created via the xAI Collections API.\n *\n * @example [\"collection_abc123\", \"collection_def456\"]\n */\n vectorStoreIds?: string[];\n}\n\n/**\n * Creates an xAI collections search tool.\n * Enables the model to search through your uploaded knowledge bases (collections)\n * to retrieve relevant information from your documents.\n *\n * This tool is executed server-side by the xAI API as part of the agentic\n * tool calling workflow.\n *\n * @param options - Configuration options for the collections search tool\n * @returns An XAICollectionsSearchTool object to pass to the model\n *\n * @example Basic usage with collection IDs\n * ```typescript\n * import { ChatXAIResponses, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAIResponses({\n * model: \"grok-4-1-fast\",\n * });\n *\n * const collectionsSearch = tools.xaiCollectionsSearch({\n * vectorStoreIds: [\"collection_abc123\"],\n * });\n *\n * const result = await llm.invoke(\n * \"What are the key findings in the Q3 report?\",\n * { tools: [collectionsSearch] }\n * );\n * ```\n *\n * @example Combining with other tools for hybrid analysis\n * ```typescript\n * const collectionsSearch = tools.xaiCollectionsSearch({\n * vectorStoreIds: [\"collection_sec_filings\"],\n * });\n * const webSearch = tools.xaiWebSearch();\n * const codeExecution = tools.xaiCodeExecution();\n *\n * const result = await llm.invoke(\n * \"Based on our internal SEC filings, what is the market sentiment on our performance?\",\n * { tools: [collectionsSearch, webSearch, codeExecution] }\n * );\n * ```\n */\nexport function xaiCollectionsSearch(\n options: XAICollectionsSearchToolOptions = {}\n): XAICollectionsSearchTool {\n const tool: XAICollectionsSearchTool = {\n type: XAI_COLLECTIONS_SEARCH_TOOL_TYPE,\n };\n\n if (options.vectorStoreIds !== undefined) {\n tool.vector_store_ids = options.vectorStoreIds;\n }\n\n return tool;\n}\n"],"mappings":";;;;;AAIA,MAAa,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFhD,SAAgB,qBACdA,UAA2C,CAAE,GACnB;CAC1B,MAAMC,OAAiC,EACrC,MAAM,iCACP;AAED,KAAI,QAAQ,mBAAmB,QAC7B,KAAK,mBAAmB,QAAQ;AAGlC,QAAO;AACR"}
@@ -1,7 +1,17 @@
1
1
  const require_live_search = require('./live_search.cjs');
2
+ const require_web_search = require('./web_search.cjs');
3
+ const require_x_search = require('./x_search.cjs');
4
+ const require_code_execution = require('./code_execution.cjs');
5
+ const require_collections_search = require('./collections_search.cjs');
2
6
 
3
7
  //#region src/tools/index.ts
4
- const tools = { xaiLiveSearch: require_live_search.xaiLiveSearch };
8
+ const tools = {
9
+ xaiLiveSearch: require_live_search.xaiLiveSearch,
10
+ xaiWebSearch: require_web_search.xaiWebSearch,
11
+ xaiXSearch: require_x_search.xaiXSearch,
12
+ xaiCodeExecution: require_code_execution.xaiCodeExecution,
13
+ xaiCollectionsSearch: require_collections_search.xaiCollectionsSearch
14
+ };
5
15
 
6
16
  //#endregion
7
17
  exports.tools = tools;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../src/tools/index.ts"],"sourcesContent":["import { xaiLiveSearch } from \"./live_search.js\";\n\nexport const tools = {\n xaiLiveSearch,\n};\n"],"mappings":";;;AAEA,MAAa,QAAQ,EACnB,iDACD"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/tools/index.ts"],"sourcesContent":["import { xaiLiveSearch } from \"./live_search.js\";\nimport { xaiWebSearch } from \"./web_search.js\";\nimport { xaiXSearch } from \"./x_search.js\";\nimport { xaiCodeExecution } from \"./code_execution.js\";\nimport { xaiCollectionsSearch } from \"./collections_search.js\";\n\nexport const tools = {\n /** @deprecated Use xaiWebSearch and xaiXSearch instead */\n xaiLiveSearch,\n xaiWebSearch,\n xaiXSearch,\n xaiCodeExecution,\n xaiCollectionsSearch,\n};\n\n// Re-export types for convenience\nexport type {\n XAILiveSearchTool,\n XAILiveSearchToolOptions,\n} from \"./live_search.js\";\nexport type {\n XAIWebSearchTool,\n XAIWebSearchToolOptions,\n} from \"./web_search.js\";\nexport type { XAIXSearchTool, XAIXSearchToolOptions } from \"./x_search.js\";\nexport type { XAICodeExecutionTool } from \"./code_execution.js\";\nexport type {\n XAICollectionsSearchTool,\n XAICollectionsSearchToolOptions,\n} from \"./collections_search.js\";\n\n// Re-export tool type constants\nexport {\n XAI_LIVE_SEARCH_TOOL_TYPE,\n XAI_LIVE_SEARCH_TOOL_NAME,\n} from \"./live_search.js\";\nexport { XAI_WEB_SEARCH_TOOL_TYPE } from \"./web_search.js\";\nexport { XAI_X_SEARCH_TOOL_TYPE } from \"./x_search.js\";\nexport { XAI_CODE_EXECUTION_TOOL_TYPE } from \"./code_execution.js\";\nexport { XAI_COLLECTIONS_SEARCH_TOOL_TYPE } from \"./collections_search.js\";\n"],"mappings":";;;;;;;AAMA,MAAa,QAAQ;CAEnB;CACA;CACA;CACA;CACA;AACD"}
@@ -1,8 +1,17 @@
1
- import { xaiLiveSearch } from "./live_search.cjs";
1
+ import { XAILiveSearchTool, XAILiveSearchToolOptions, XAI_LIVE_SEARCH_TOOL_NAME, XAI_LIVE_SEARCH_TOOL_TYPE, xaiLiveSearch } from "./live_search.cjs";
2
+ import { XAIWebSearchTool, XAIWebSearchToolOptions, XAI_WEB_SEARCH_TOOL_TYPE, xaiWebSearch } from "./web_search.cjs";
3
+ import { XAIXSearchTool, XAIXSearchToolOptions, XAI_X_SEARCH_TOOL_TYPE, xaiXSearch } from "./x_search.cjs";
4
+ import { XAICodeExecutionTool, XAI_CODE_EXECUTION_TOOL_TYPE, xaiCodeExecution } from "./code_execution.cjs";
5
+ import { XAICollectionsSearchTool, XAICollectionsSearchToolOptions, XAI_COLLECTIONS_SEARCH_TOOL_TYPE, xaiCollectionsSearch } from "./collections_search.cjs";
2
6
 
3
7
  //#region src/tools/index.d.ts
4
8
  declare const tools: {
9
+ /** @deprecated Use xaiWebSearch and xaiXSearch instead */
5
10
  xaiLiveSearch: typeof xaiLiveSearch;
11
+ xaiWebSearch: typeof xaiWebSearch;
12
+ xaiXSearch: typeof xaiXSearch;
13
+ xaiCodeExecution: typeof xaiCodeExecution;
14
+ xaiCollectionsSearch: typeof xaiCollectionsSearch;
6
15
  };
7
16
  //#endregion
8
17
  export { tools };