@nocobase/plugin-ai 2.1.0-beta.24 → 2.1.0-beta.26
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.
- package/dist/ai/ai-employees/dara.js +1 -0
- package/dist/ai/tools/sub-agents/shared.js +3 -1
- package/dist/client/343.6f36d97dd122c5b6.js +10 -0
- package/dist/client/{559.133d286a0a0a1d93.js → 559.39872901b9053629.js} +1 -1
- package/dist/client/646.afa699c92cd556f3.js +10 -0
- package/dist/client/ai-employees/types.d.ts +2 -0
- package/dist/client/components/skill-settings.d.ts +2 -0
- package/dist/client/index.js +3 -3
- package/dist/client/llm-providers/mimo/ModelSettings.d.ts +10 -0
- package/dist/client/llm-providers/mimo/index.d.ts +10 -0
- package/dist/client/llm-providers/xai/ModelSettings.d.ts +10 -0
- package/dist/client/llm-providers/xai/index.d.ts +10 -0
- package/dist/collections/ai-employees.d.ts +7 -0
- package/dist/collections/ai-employees.js +13 -0
- package/dist/externalVersion.js +15 -15
- package/dist/locale/en-US.json +2 -0
- package/dist/locale/zh-CN.json +2 -0
- package/dist/node_modules/@langchain/xai/LICENSE +21 -0
- package/dist/node_modules/@langchain/xai/dist/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/node_modules/@langchain/xai/dist/chat_models/completions.cjs +568 -0
- package/dist/node_modules/@langchain/xai/dist/chat_models/completions.d.cts +619 -0
- package/dist/node_modules/@langchain/xai/dist/chat_models/completions.d.ts +619 -0
- package/dist/node_modules/@langchain/xai/dist/chat_models/completions.js +566 -0
- package/dist/node_modules/@langchain/xai/dist/chat_models/index.cjs +2 -0
- package/dist/node_modules/@langchain/xai/dist/chat_models/index.d.ts +3 -0
- package/dist/node_modules/@langchain/xai/dist/chat_models/index.js +2 -0
- package/dist/node_modules/@langchain/xai/dist/chat_models/responses-types.d.cts +1178 -0
- package/dist/node_modules/@langchain/xai/dist/chat_models/responses-types.d.ts +1178 -0
- package/dist/node_modules/@langchain/xai/dist/chat_models/responses.cjs +233 -0
- package/dist/node_modules/@langchain/xai/dist/chat_models/responses.d.cts +70 -0
- package/dist/node_modules/@langchain/xai/dist/chat_models/responses.d.ts +70 -0
- package/dist/node_modules/@langchain/xai/dist/chat_models/responses.js +232 -0
- package/dist/node_modules/@langchain/xai/dist/converters/responses.cjs +168 -0
- package/dist/node_modules/@langchain/xai/dist/converters/responses.js +164 -0
- package/dist/node_modules/@langchain/xai/dist/index.cjs +7 -0
- package/dist/node_modules/@langchain/xai/dist/index.d.cts +5 -0
- package/dist/node_modules/@langchain/xai/dist/index.d.ts +6 -0
- package/dist/node_modules/@langchain/xai/dist/index.js +6 -0
- package/dist/node_modules/@langchain/xai/dist/live_search.cjs +54 -0
- package/dist/node_modules/@langchain/xai/dist/live_search.d.cts +145 -0
- package/dist/node_modules/@langchain/xai/dist/live_search.d.ts +145 -0
- package/dist/node_modules/@langchain/xai/dist/live_search.js +51 -0
- package/dist/node_modules/@langchain/xai/dist/profiles.cjs +289 -0
- package/dist/node_modules/@langchain/xai/dist/profiles.js +288 -0
- package/dist/node_modules/@langchain/xai/dist/tools/code_execution.cjs +52 -0
- package/dist/node_modules/@langchain/xai/dist/tools/code_execution.d.cts +64 -0
- package/dist/node_modules/@langchain/xai/dist/tools/code_execution.d.ts +64 -0
- package/dist/node_modules/@langchain/xai/dist/tools/code_execution.js +50 -0
- package/dist/node_modules/@langchain/xai/dist/tools/collections_search.cjs +60 -0
- package/dist/node_modules/@langchain/xai/dist/tools/collections_search.d.cts +90 -0
- package/dist/node_modules/@langchain/xai/dist/tools/collections_search.d.ts +90 -0
- package/dist/node_modules/@langchain/xai/dist/tools/collections_search.js +58 -0
- package/dist/node_modules/@langchain/xai/dist/tools/index.cjs +18 -0
- package/dist/node_modules/@langchain/xai/dist/tools/index.d.cts +18 -0
- package/dist/node_modules/@langchain/xai/dist/tools/index.d.ts +18 -0
- package/dist/node_modules/@langchain/xai/dist/tools/index.js +18 -0
- package/dist/node_modules/@langchain/xai/dist/tools/live_search.cjs +94 -0
- package/dist/node_modules/@langchain/xai/dist/tools/live_search.d.cts +149 -0
- package/dist/node_modules/@langchain/xai/dist/tools/live_search.d.ts +149 -0
- package/dist/node_modules/@langchain/xai/dist/tools/live_search.js +91 -0
- package/dist/node_modules/@langchain/xai/dist/tools/web_search.cjs +57 -0
- package/dist/node_modules/@langchain/xai/dist/tools/web_search.d.cts +104 -0
- package/dist/node_modules/@langchain/xai/dist/tools/web_search.d.ts +104 -0
- package/dist/node_modules/@langchain/xai/dist/tools/web_search.js +55 -0
- package/dist/node_modules/@langchain/xai/dist/tools/x_search.cjs +63 -0
- package/dist/node_modules/@langchain/xai/dist/tools/x_search.d.cts +145 -0
- package/dist/node_modules/@langchain/xai/dist/tools/x_search.d.ts +145 -0
- package/dist/node_modules/@langchain/xai/dist/tools/x_search.js +61 -0
- package/dist/node_modules/@langchain/xai/package.json +1 -0
- package/dist/node_modules/fast-glob/package.json +1 -1
- package/dist/node_modules/flexsearch/package.json +1 -1
- package/dist/node_modules/fs-extra/package.json +1 -1
- package/dist/node_modules/jsonrepair/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/node_modules/openai/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/ai-employees/ai-employee.js +20 -10
- package/dist/server/llm-providers/common/reasoning.js +2 -4
- package/dist/server/llm-providers/mimo.d.ts +37 -0
- package/dist/server/llm-providers/mimo.js +156 -0
- package/dist/server/llm-providers/xai.d.ts +17 -0
- package/dist/server/llm-providers/xai.js +88 -0
- package/dist/server/migrations/20260428175558-update-ai-employee-category.d.ts +14 -0
- package/dist/server/migrations/20260428175558-update-ai-employee-category.js +55 -0
- package/dist/server/migrations/20260429175132-ai-employee-deprecated-orin.d.ts +14 -0
- package/dist/server/migrations/20260429175132-ai-employee-deprecated-orin.js +53 -0
- package/dist/server/plugin.js +5 -0
- package/dist/server/resource/aiEmployees.js +10 -1
- package/dist/server/workflow/nodes/employee/files.js +7 -4
- package/dist/server/workflow/nodes/employee/index.js +136 -132
- package/dist/server/workflow/nodes/employee/types.d.ts +1 -1
- package/package.json +3 -2
- package/dist/client/343.83f7d96664e4e038.js +0 -10
- package/dist/client/646.cba98d80e9e6ea74.js +0 -10
|
@@ -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,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,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,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,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,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,18 @@
|
|
|
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');
|
|
6
|
+
|
|
7
|
+
//#region src/tools/index.ts
|
|
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
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.tools = tools;
|
|
18
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,18 @@
|
|
|
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";
|
|
6
|
+
|
|
7
|
+
//#region src/tools/index.d.ts
|
|
8
|
+
declare const tools: {
|
|
9
|
+
/** @deprecated Use xaiWebSearch and xaiXSearch instead */
|
|
10
|
+
xaiLiveSearch: typeof xaiLiveSearch;
|
|
11
|
+
xaiWebSearch: typeof xaiWebSearch;
|
|
12
|
+
xaiXSearch: typeof xaiXSearch;
|
|
13
|
+
xaiCodeExecution: typeof xaiCodeExecution;
|
|
14
|
+
xaiCollectionsSearch: typeof xaiCollectionsSearch;
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { tools };
|
|
18
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { XAILiveSearchTool, XAILiveSearchToolOptions, XAI_LIVE_SEARCH_TOOL_NAME, XAI_LIVE_SEARCH_TOOL_TYPE, xaiLiveSearch } from "./live_search.js";
|
|
2
|
+
import { XAIWebSearchTool, XAIWebSearchToolOptions, XAI_WEB_SEARCH_TOOL_TYPE, xaiWebSearch } from "./web_search.js";
|
|
3
|
+
import { XAIXSearchTool, XAIXSearchToolOptions, XAI_X_SEARCH_TOOL_TYPE, xaiXSearch } from "./x_search.js";
|
|
4
|
+
import { XAICodeExecutionTool, XAI_CODE_EXECUTION_TOOL_TYPE, xaiCodeExecution } from "./code_execution.js";
|
|
5
|
+
import { XAICollectionsSearchTool, XAICollectionsSearchToolOptions, XAI_COLLECTIONS_SEARCH_TOOL_TYPE, xaiCollectionsSearch } from "./collections_search.js";
|
|
6
|
+
|
|
7
|
+
//#region src/tools/index.d.ts
|
|
8
|
+
declare const tools: {
|
|
9
|
+
/** @deprecated Use xaiWebSearch and xaiXSearch instead */
|
|
10
|
+
xaiLiveSearch: typeof xaiLiveSearch;
|
|
11
|
+
xaiWebSearch: typeof xaiWebSearch;
|
|
12
|
+
xaiXSearch: typeof xaiXSearch;
|
|
13
|
+
xaiCodeExecution: typeof xaiCodeExecution;
|
|
14
|
+
xaiCollectionsSearch: typeof xaiCollectionsSearch;
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { tools };
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { XAI_LIVE_SEARCH_TOOL_NAME, XAI_LIVE_SEARCH_TOOL_TYPE, xaiLiveSearch } from "./live_search.js";
|
|
2
|
+
import { XAI_WEB_SEARCH_TOOL_TYPE, xaiWebSearch } from "./web_search.js";
|
|
3
|
+
import { XAI_X_SEARCH_TOOL_TYPE, xaiXSearch } from "./x_search.js";
|
|
4
|
+
import { XAI_CODE_EXECUTION_TOOL_TYPE, xaiCodeExecution } from "./code_execution.js";
|
|
5
|
+
import { XAI_COLLECTIONS_SEARCH_TOOL_TYPE, xaiCollectionsSearch } from "./collections_search.js";
|
|
6
|
+
|
|
7
|
+
//#region src/tools/index.ts
|
|
8
|
+
const tools = {
|
|
9
|
+
xaiLiveSearch,
|
|
10
|
+
xaiWebSearch,
|
|
11
|
+
xaiXSearch,
|
|
12
|
+
xaiCodeExecution,
|
|
13
|
+
xaiCollectionsSearch
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { tools };
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/tools/live_search.ts
|
|
3
|
+
/**
|
|
4
|
+
* xAI's deprecated live_search tool type.
|
|
5
|
+
*/
|
|
6
|
+
const XAI_LIVE_SEARCH_TOOL_TYPE = "live_search_deprecated_20251215";
|
|
7
|
+
const XAI_LIVE_SEARCH_TOOL_NAME = "live_search";
|
|
8
|
+
function mapToolSourceToSearchSource(source) {
|
|
9
|
+
switch (source.type) {
|
|
10
|
+
case "web": return {
|
|
11
|
+
type: "web",
|
|
12
|
+
...source.country !== void 0 && { country: source.country },
|
|
13
|
+
...source.allowedWebsites !== void 0 && { allowed_websites: source.allowedWebsites },
|
|
14
|
+
...source.excludedWebsites !== void 0 && { excluded_websites: source.excludedWebsites },
|
|
15
|
+
...source.safeSearch !== void 0 && { safe_search: source.safeSearch }
|
|
16
|
+
};
|
|
17
|
+
case "news": return {
|
|
18
|
+
type: "news",
|
|
19
|
+
...source.country !== void 0 && { country: source.country },
|
|
20
|
+
...source.excludedWebsites !== void 0 && { excluded_websites: source.excludedWebsites },
|
|
21
|
+
...source.safeSearch !== void 0 && { safe_search: source.safeSearch }
|
|
22
|
+
};
|
|
23
|
+
case "x": return {
|
|
24
|
+
type: "x",
|
|
25
|
+
...source.includedXHandles !== void 0 && { included_x_handles: source.includedXHandles },
|
|
26
|
+
...source.excludedXHandles !== void 0 && { excluded_x_handles: source.excludedXHandles },
|
|
27
|
+
...source.postFavoriteCount !== void 0 && { post_favorite_count: source.postFavoriteCount },
|
|
28
|
+
...source.postViewCount !== void 0 && { post_view_count: source.postViewCount }
|
|
29
|
+
};
|
|
30
|
+
case "rss": return {
|
|
31
|
+
type: "rss",
|
|
32
|
+
links: source.links
|
|
33
|
+
};
|
|
34
|
+
default: {
|
|
35
|
+
const _exhaustive = source;
|
|
36
|
+
return _exhaustive;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates an xAI built-in live search tool.
|
|
42
|
+
* Enables the model to search the web for real-time information.
|
|
43
|
+
*
|
|
44
|
+
* This tool is executed server-side by the xAI API.
|
|
45
|
+
*
|
|
46
|
+
* @deprecated The Live Search API was deprecated by xAI on December 15, 2025.
|
|
47
|
+
* Use the new agentic tool calling API instead with `xaiWebSearch()` and `xaiXSearch()`.
|
|
48
|
+
*
|
|
49
|
+
* @example Migration to new tools:
|
|
50
|
+
* ```typescript
|
|
51
|
+
* // Old (deprecated):
|
|
52
|
+
* const searchTool = tools.xaiLiveSearch({ maxSearchResults: 5 });
|
|
53
|
+
*
|
|
54
|
+
* // New (recommended):
|
|
55
|
+
* const webSearch = tools.xaiWebSearch({ allowedDomains: ["example.com"] });
|
|
56
|
+
* const xSearch = tools.xaiXSearch({ allowedXHandles: ["elonmusk"] });
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* import { ChatXAI, tools } from "@langchain/xai";
|
|
62
|
+
*
|
|
63
|
+
* const llm = new ChatXAI({
|
|
64
|
+
* model: "grok-beta",
|
|
65
|
+
* });
|
|
66
|
+
*
|
|
67
|
+
* const searchTool = tools.xaiLiveSearch({
|
|
68
|
+
* maxSearchResults: 5,
|
|
69
|
+
* fromDate: "2024-01-01",
|
|
70
|
+
* returnCitations: true
|
|
71
|
+
* });
|
|
72
|
+
*
|
|
73
|
+
* const llmWithSearch = llm.bindTools([searchTool]);
|
|
74
|
+
* const result = await llmWithSearch.invoke("What happened in tech today?");
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
function xaiLiveSearch(options = {}) {
|
|
78
|
+
return {
|
|
79
|
+
type: XAI_LIVE_SEARCH_TOOL_TYPE,
|
|
80
|
+
name: XAI_LIVE_SEARCH_TOOL_NAME,
|
|
81
|
+
mode: options?.mode,
|
|
82
|
+
max_search_results: options?.maxSearchResults,
|
|
83
|
+
from_date: options?.fromDate,
|
|
84
|
+
to_date: options?.toDate,
|
|
85
|
+
return_citations: options?.returnCitations,
|
|
86
|
+
sources: options?.sources?.map(mapToolSourceToSearchSource)
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
exports.XAI_LIVE_SEARCH_TOOL_NAME = XAI_LIVE_SEARCH_TOOL_NAME;
|
|
92
|
+
exports.XAI_LIVE_SEARCH_TOOL_TYPE = XAI_LIVE_SEARCH_TOOL_TYPE;
|
|
93
|
+
exports.xaiLiveSearch = xaiLiveSearch;
|
|
94
|
+
//# sourceMappingURL=live_search.cjs.map
|