@nocobase/plugin-ai 2.1.0-beta.25 → 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/client/{559.c119db3f985a695f.js → 559.39872901b9053629.js} +1 -1
- package/dist/client/index.js +3 -3
- package/dist/client/llm-providers/xai/ModelSettings.d.ts +10 -0
- package/dist/client/llm-providers/xai/index.d.ts +10 -0
- package/dist/externalVersion.js +15 -15
- 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 +11 -7
- package/dist/server/llm-providers/xai.d.ts +17 -0
- package/dist/server/llm-providers/xai.js +88 -0
- package/dist/server/plugin.js +3 -0
- package/dist/server/workflow/nodes/employee/files.js +7 -4
- package/dist/server/workflow/nodes/employee/index.js +4 -3
- package/dist/server/workflow/nodes/employee/types.d.ts +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { XAISearchParameters } from "../live_search.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/tools/live_search.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* xAI's deprecated live_search tool type.
|
|
7
|
+
*/
|
|
8
|
+
declare const XAI_LIVE_SEARCH_TOOL_TYPE = "live_search_deprecated_20251215";
|
|
9
|
+
declare const XAI_LIVE_SEARCH_TOOL_NAME = "live_search";
|
|
10
|
+
/**
|
|
11
|
+
* xAI's built-in live_search tool type.
|
|
12
|
+
* Enables the model to search the web for real-time information.
|
|
13
|
+
*/
|
|
14
|
+
interface XAILiveSearchTool extends XAISearchParameters {
|
|
15
|
+
/**
|
|
16
|
+
* The name of the tool. Must be "live_search" for xAI's built-in search.
|
|
17
|
+
*/
|
|
18
|
+
name: typeof XAI_LIVE_SEARCH_TOOL_NAME;
|
|
19
|
+
/**
|
|
20
|
+
* The type of the tool. This uses a deprecated Live Search API shape:
|
|
21
|
+
* the advanced agentic search capabilities powering grok.com are generally
|
|
22
|
+
* available in the new agentic tool calling API, and the Live Search API
|
|
23
|
+
* will be deprecated by December 15, 2025.
|
|
24
|
+
*/
|
|
25
|
+
type: typeof XAI_LIVE_SEARCH_TOOL_TYPE;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Web search source configuration for the xAI live search tool (camelCase).
|
|
29
|
+
* This is converted to the snake_case `XAIWebSource` internally.
|
|
30
|
+
*/
|
|
31
|
+
interface XAIWebSearchToolSource {
|
|
32
|
+
type: "web";
|
|
33
|
+
country?: string;
|
|
34
|
+
excludedWebsites?: string[];
|
|
35
|
+
allowedWebsites?: string[];
|
|
36
|
+
safeSearch?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* News search source configuration for the xAI live search tool (camelCase).
|
|
40
|
+
* This is converted to the snake_case `XAINewsSource` internally.
|
|
41
|
+
*/
|
|
42
|
+
interface XAINewsSearchToolSource {
|
|
43
|
+
type: "news";
|
|
44
|
+
country?: string;
|
|
45
|
+
excludedWebsites?: string[];
|
|
46
|
+
safeSearch?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* X (formerly Twitter) search source configuration for the xAI live search tool (camelCase).
|
|
50
|
+
* This is converted to the snake_case `XAIXSource` internally.
|
|
51
|
+
*/
|
|
52
|
+
interface XAIXSearchToolSource {
|
|
53
|
+
type: "x";
|
|
54
|
+
includedXHandles?: string[];
|
|
55
|
+
excludedXHandles?: string[];
|
|
56
|
+
postFavoriteCount?: number;
|
|
57
|
+
postViewCount?: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* RSS feed search source configuration for the xAI live search tool.
|
|
61
|
+
* The structure matches `XAIRssSource` (only `links`).
|
|
62
|
+
*/
|
|
63
|
+
interface XAIRssSearchToolSource {
|
|
64
|
+
type: "rss";
|
|
65
|
+
links: string[];
|
|
66
|
+
}
|
|
67
|
+
type XAISearchToolSource = XAIWebSearchToolSource | XAINewsSearchToolSource | XAIXSearchToolSource | XAIRssSearchToolSource;
|
|
68
|
+
/**
|
|
69
|
+
* Options for the xAI live search tool (camelCase).
|
|
70
|
+
* All fields are camel-cased for the TypeScript API and are mapped to the
|
|
71
|
+
* corresponding snake_case fields in the underlying `XAISearchParameters`
|
|
72
|
+
* object that is sent to xAI's deprecated Live Search API.
|
|
73
|
+
*/
|
|
74
|
+
interface XAILiveSearchToolOptions {
|
|
75
|
+
/**
|
|
76
|
+
* Controls when the model should perform a search.
|
|
77
|
+
* - "auto": Let the model decide when to search (default)
|
|
78
|
+
* - "on": Always search for every request
|
|
79
|
+
* - "off": Never search
|
|
80
|
+
*/
|
|
81
|
+
mode?: "auto" | "on" | "off";
|
|
82
|
+
/**
|
|
83
|
+
* Maximum number of search results to return.
|
|
84
|
+
* @default 20
|
|
85
|
+
*/
|
|
86
|
+
maxSearchResults?: number;
|
|
87
|
+
/**
|
|
88
|
+
* Filter search results to only include content from after this date.
|
|
89
|
+
* Format: ISO 8601 date string (e.g., "2024-01-01")
|
|
90
|
+
*/
|
|
91
|
+
fromDate?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Filter search results to only include content from before this date.
|
|
94
|
+
* Format: ISO 8601 date string (e.g., "2024-12-31")
|
|
95
|
+
*/
|
|
96
|
+
toDate?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Whether to return citations/sources for the search results.
|
|
99
|
+
* @default true
|
|
100
|
+
*/
|
|
101
|
+
returnCitations?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Specific web/news/X/RSS sources that can be used for the search.
|
|
104
|
+
* These are converted to the snake_case `XAISearchSource` structures
|
|
105
|
+
* used by the underlying xAI Live Search API.
|
|
106
|
+
*/
|
|
107
|
+
sources?: XAISearchToolSource[];
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Creates an xAI built-in live search tool.
|
|
111
|
+
* Enables the model to search the web for real-time information.
|
|
112
|
+
*
|
|
113
|
+
* This tool is executed server-side by the xAI API.
|
|
114
|
+
*
|
|
115
|
+
* @deprecated The Live Search API was deprecated by xAI on December 15, 2025.
|
|
116
|
+
* Use the new agentic tool calling API instead with `xaiWebSearch()` and `xaiXSearch()`.
|
|
117
|
+
*
|
|
118
|
+
* @example Migration to new tools:
|
|
119
|
+
* ```typescript
|
|
120
|
+
* // Old (deprecated):
|
|
121
|
+
* const searchTool = tools.xaiLiveSearch({ maxSearchResults: 5 });
|
|
122
|
+
*
|
|
123
|
+
* // New (recommended):
|
|
124
|
+
* const webSearch = tools.xaiWebSearch({ allowedDomains: ["example.com"] });
|
|
125
|
+
* const xSearch = tools.xaiXSearch({ allowedXHandles: ["elonmusk"] });
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* import { ChatXAI, tools } from "@langchain/xai";
|
|
131
|
+
*
|
|
132
|
+
* const llm = new ChatXAI({
|
|
133
|
+
* model: "grok-beta",
|
|
134
|
+
* });
|
|
135
|
+
*
|
|
136
|
+
* const searchTool = tools.xaiLiveSearch({
|
|
137
|
+
* maxSearchResults: 5,
|
|
138
|
+
* fromDate: "2024-01-01",
|
|
139
|
+
* returnCitations: true
|
|
140
|
+
* });
|
|
141
|
+
*
|
|
142
|
+
* const llmWithSearch = llm.bindTools([searchTool]);
|
|
143
|
+
* const result = await llmWithSearch.invoke("What happened in tech today?");
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
declare function xaiLiveSearch(options?: XAILiveSearchToolOptions): XAILiveSearchTool;
|
|
147
|
+
//#endregion
|
|
148
|
+
export { XAILiveSearchTool, XAILiveSearchToolOptions, XAI_LIVE_SEARCH_TOOL_NAME, XAI_LIVE_SEARCH_TOOL_TYPE, xaiLiveSearch };
|
|
149
|
+
//# sourceMappingURL=live_search.d.cts.map
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { XAISearchParameters } from "../live_search.js";
|
|
2
|
+
|
|
3
|
+
//#region src/tools/live_search.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* xAI's deprecated live_search tool type.
|
|
7
|
+
*/
|
|
8
|
+
declare const XAI_LIVE_SEARCH_TOOL_TYPE = "live_search_deprecated_20251215";
|
|
9
|
+
declare const XAI_LIVE_SEARCH_TOOL_NAME = "live_search";
|
|
10
|
+
/**
|
|
11
|
+
* xAI's built-in live_search tool type.
|
|
12
|
+
* Enables the model to search the web for real-time information.
|
|
13
|
+
*/
|
|
14
|
+
interface XAILiveSearchTool extends XAISearchParameters {
|
|
15
|
+
/**
|
|
16
|
+
* The name of the tool. Must be "live_search" for xAI's built-in search.
|
|
17
|
+
*/
|
|
18
|
+
name: typeof XAI_LIVE_SEARCH_TOOL_NAME;
|
|
19
|
+
/**
|
|
20
|
+
* The type of the tool. This uses a deprecated Live Search API shape:
|
|
21
|
+
* the advanced agentic search capabilities powering grok.com are generally
|
|
22
|
+
* available in the new agentic tool calling API, and the Live Search API
|
|
23
|
+
* will be deprecated by December 15, 2025.
|
|
24
|
+
*/
|
|
25
|
+
type: typeof XAI_LIVE_SEARCH_TOOL_TYPE;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Web search source configuration for the xAI live search tool (camelCase).
|
|
29
|
+
* This is converted to the snake_case `XAIWebSource` internally.
|
|
30
|
+
*/
|
|
31
|
+
interface XAIWebSearchToolSource {
|
|
32
|
+
type: "web";
|
|
33
|
+
country?: string;
|
|
34
|
+
excludedWebsites?: string[];
|
|
35
|
+
allowedWebsites?: string[];
|
|
36
|
+
safeSearch?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* News search source configuration for the xAI live search tool (camelCase).
|
|
40
|
+
* This is converted to the snake_case `XAINewsSource` internally.
|
|
41
|
+
*/
|
|
42
|
+
interface XAINewsSearchToolSource {
|
|
43
|
+
type: "news";
|
|
44
|
+
country?: string;
|
|
45
|
+
excludedWebsites?: string[];
|
|
46
|
+
safeSearch?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* X (formerly Twitter) search source configuration for the xAI live search tool (camelCase).
|
|
50
|
+
* This is converted to the snake_case `XAIXSource` internally.
|
|
51
|
+
*/
|
|
52
|
+
interface XAIXSearchToolSource {
|
|
53
|
+
type: "x";
|
|
54
|
+
includedXHandles?: string[];
|
|
55
|
+
excludedXHandles?: string[];
|
|
56
|
+
postFavoriteCount?: number;
|
|
57
|
+
postViewCount?: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* RSS feed search source configuration for the xAI live search tool.
|
|
61
|
+
* The structure matches `XAIRssSource` (only `links`).
|
|
62
|
+
*/
|
|
63
|
+
interface XAIRssSearchToolSource {
|
|
64
|
+
type: "rss";
|
|
65
|
+
links: string[];
|
|
66
|
+
}
|
|
67
|
+
type XAISearchToolSource = XAIWebSearchToolSource | XAINewsSearchToolSource | XAIXSearchToolSource | XAIRssSearchToolSource;
|
|
68
|
+
/**
|
|
69
|
+
* Options for the xAI live search tool (camelCase).
|
|
70
|
+
* All fields are camel-cased for the TypeScript API and are mapped to the
|
|
71
|
+
* corresponding snake_case fields in the underlying `XAISearchParameters`
|
|
72
|
+
* object that is sent to xAI's deprecated Live Search API.
|
|
73
|
+
*/
|
|
74
|
+
interface XAILiveSearchToolOptions {
|
|
75
|
+
/**
|
|
76
|
+
* Controls when the model should perform a search.
|
|
77
|
+
* - "auto": Let the model decide when to search (default)
|
|
78
|
+
* - "on": Always search for every request
|
|
79
|
+
* - "off": Never search
|
|
80
|
+
*/
|
|
81
|
+
mode?: "auto" | "on" | "off";
|
|
82
|
+
/**
|
|
83
|
+
* Maximum number of search results to return.
|
|
84
|
+
* @default 20
|
|
85
|
+
*/
|
|
86
|
+
maxSearchResults?: number;
|
|
87
|
+
/**
|
|
88
|
+
* Filter search results to only include content from after this date.
|
|
89
|
+
* Format: ISO 8601 date string (e.g., "2024-01-01")
|
|
90
|
+
*/
|
|
91
|
+
fromDate?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Filter search results to only include content from before this date.
|
|
94
|
+
* Format: ISO 8601 date string (e.g., "2024-12-31")
|
|
95
|
+
*/
|
|
96
|
+
toDate?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Whether to return citations/sources for the search results.
|
|
99
|
+
* @default true
|
|
100
|
+
*/
|
|
101
|
+
returnCitations?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Specific web/news/X/RSS sources that can be used for the search.
|
|
104
|
+
* These are converted to the snake_case `XAISearchSource` structures
|
|
105
|
+
* used by the underlying xAI Live Search API.
|
|
106
|
+
*/
|
|
107
|
+
sources?: XAISearchToolSource[];
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Creates an xAI built-in live search tool.
|
|
111
|
+
* Enables the model to search the web for real-time information.
|
|
112
|
+
*
|
|
113
|
+
* This tool is executed server-side by the xAI API.
|
|
114
|
+
*
|
|
115
|
+
* @deprecated The Live Search API was deprecated by xAI on December 15, 2025.
|
|
116
|
+
* Use the new agentic tool calling API instead with `xaiWebSearch()` and `xaiXSearch()`.
|
|
117
|
+
*
|
|
118
|
+
* @example Migration to new tools:
|
|
119
|
+
* ```typescript
|
|
120
|
+
* // Old (deprecated):
|
|
121
|
+
* const searchTool = tools.xaiLiveSearch({ maxSearchResults: 5 });
|
|
122
|
+
*
|
|
123
|
+
* // New (recommended):
|
|
124
|
+
* const webSearch = tools.xaiWebSearch({ allowedDomains: ["example.com"] });
|
|
125
|
+
* const xSearch = tools.xaiXSearch({ allowedXHandles: ["elonmusk"] });
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* import { ChatXAI, tools } from "@langchain/xai";
|
|
131
|
+
*
|
|
132
|
+
* const llm = new ChatXAI({
|
|
133
|
+
* model: "grok-beta",
|
|
134
|
+
* });
|
|
135
|
+
*
|
|
136
|
+
* const searchTool = tools.xaiLiveSearch({
|
|
137
|
+
* maxSearchResults: 5,
|
|
138
|
+
* fromDate: "2024-01-01",
|
|
139
|
+
* returnCitations: true
|
|
140
|
+
* });
|
|
141
|
+
*
|
|
142
|
+
* const llmWithSearch = llm.bindTools([searchTool]);
|
|
143
|
+
* const result = await llmWithSearch.invoke("What happened in tech today?");
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
declare function xaiLiveSearch(options?: XAILiveSearchToolOptions): XAILiveSearchTool;
|
|
147
|
+
//#endregion
|
|
148
|
+
export { XAILiveSearchTool, XAILiveSearchToolOptions, XAI_LIVE_SEARCH_TOOL_NAME, XAI_LIVE_SEARCH_TOOL_TYPE, xaiLiveSearch };
|
|
149
|
+
//# sourceMappingURL=live_search.d.ts.map
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
//#region src/tools/live_search.ts
|
|
2
|
+
/**
|
|
3
|
+
* xAI's deprecated live_search tool type.
|
|
4
|
+
*/
|
|
5
|
+
const XAI_LIVE_SEARCH_TOOL_TYPE = "live_search_deprecated_20251215";
|
|
6
|
+
const XAI_LIVE_SEARCH_TOOL_NAME = "live_search";
|
|
7
|
+
function mapToolSourceToSearchSource(source) {
|
|
8
|
+
switch (source.type) {
|
|
9
|
+
case "web": return {
|
|
10
|
+
type: "web",
|
|
11
|
+
...source.country !== void 0 && { country: source.country },
|
|
12
|
+
...source.allowedWebsites !== void 0 && { allowed_websites: source.allowedWebsites },
|
|
13
|
+
...source.excludedWebsites !== void 0 && { excluded_websites: source.excludedWebsites },
|
|
14
|
+
...source.safeSearch !== void 0 && { safe_search: source.safeSearch }
|
|
15
|
+
};
|
|
16
|
+
case "news": return {
|
|
17
|
+
type: "news",
|
|
18
|
+
...source.country !== void 0 && { country: source.country },
|
|
19
|
+
...source.excludedWebsites !== void 0 && { excluded_websites: source.excludedWebsites },
|
|
20
|
+
...source.safeSearch !== void 0 && { safe_search: source.safeSearch }
|
|
21
|
+
};
|
|
22
|
+
case "x": return {
|
|
23
|
+
type: "x",
|
|
24
|
+
...source.includedXHandles !== void 0 && { included_x_handles: source.includedXHandles },
|
|
25
|
+
...source.excludedXHandles !== void 0 && { excluded_x_handles: source.excludedXHandles },
|
|
26
|
+
...source.postFavoriteCount !== void 0 && { post_favorite_count: source.postFavoriteCount },
|
|
27
|
+
...source.postViewCount !== void 0 && { post_view_count: source.postViewCount }
|
|
28
|
+
};
|
|
29
|
+
case "rss": return {
|
|
30
|
+
type: "rss",
|
|
31
|
+
links: source.links
|
|
32
|
+
};
|
|
33
|
+
default: {
|
|
34
|
+
const _exhaustive = source;
|
|
35
|
+
return _exhaustive;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates an xAI built-in live search tool.
|
|
41
|
+
* Enables the model to search the web for real-time information.
|
|
42
|
+
*
|
|
43
|
+
* This tool is executed server-side by the xAI API.
|
|
44
|
+
*
|
|
45
|
+
* @deprecated The Live Search API was deprecated by xAI on December 15, 2025.
|
|
46
|
+
* Use the new agentic tool calling API instead with `xaiWebSearch()` and `xaiXSearch()`.
|
|
47
|
+
*
|
|
48
|
+
* @example Migration to new tools:
|
|
49
|
+
* ```typescript
|
|
50
|
+
* // Old (deprecated):
|
|
51
|
+
* const searchTool = tools.xaiLiveSearch({ maxSearchResults: 5 });
|
|
52
|
+
*
|
|
53
|
+
* // New (recommended):
|
|
54
|
+
* const webSearch = tools.xaiWebSearch({ allowedDomains: ["example.com"] });
|
|
55
|
+
* const xSearch = tools.xaiXSearch({ allowedXHandles: ["elonmusk"] });
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* import { ChatXAI, tools } from "@langchain/xai";
|
|
61
|
+
*
|
|
62
|
+
* const llm = new ChatXAI({
|
|
63
|
+
* model: "grok-beta",
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* const searchTool = tools.xaiLiveSearch({
|
|
67
|
+
* maxSearchResults: 5,
|
|
68
|
+
* fromDate: "2024-01-01",
|
|
69
|
+
* returnCitations: true
|
|
70
|
+
* });
|
|
71
|
+
*
|
|
72
|
+
* const llmWithSearch = llm.bindTools([searchTool]);
|
|
73
|
+
* const result = await llmWithSearch.invoke("What happened in tech today?");
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
function xaiLiveSearch(options = {}) {
|
|
77
|
+
return {
|
|
78
|
+
type: XAI_LIVE_SEARCH_TOOL_TYPE,
|
|
79
|
+
name: XAI_LIVE_SEARCH_TOOL_NAME,
|
|
80
|
+
mode: options?.mode,
|
|
81
|
+
max_search_results: options?.maxSearchResults,
|
|
82
|
+
from_date: options?.fromDate,
|
|
83
|
+
to_date: options?.toDate,
|
|
84
|
+
return_citations: options?.returnCitations,
|
|
85
|
+
sources: options?.sources?.map(mapToolSourceToSearchSource)
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
export { XAI_LIVE_SEARCH_TOOL_NAME, XAI_LIVE_SEARCH_TOOL_TYPE, xaiLiveSearch };
|
|
91
|
+
//# sourceMappingURL=live_search.js.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/tools/web_search.ts
|
|
3
|
+
/**
|
|
4
|
+
* xAI Web Search tool type constant.
|
|
5
|
+
*/
|
|
6
|
+
const XAI_WEB_SEARCH_TOOL_TYPE = "web_search";
|
|
7
|
+
/**
|
|
8
|
+
* Creates an xAI web search tool.
|
|
9
|
+
* Enables the model to search the web and browse pages for real-time information.
|
|
10
|
+
*
|
|
11
|
+
* This tool is executed server-side by the xAI API as part of the agentic
|
|
12
|
+
* tool calling workflow.
|
|
13
|
+
*
|
|
14
|
+
* @param options - Configuration options for the web search tool
|
|
15
|
+
* @returns An XAIWebSearchTool object to pass to the model
|
|
16
|
+
*
|
|
17
|
+
* @example Basic usage
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { ChatXAIResponses, tools } from "@langchain/xai";
|
|
20
|
+
*
|
|
21
|
+
* const llm = new ChatXAIResponses({
|
|
22
|
+
* model: "grok-4-1-fast",
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* const webSearch = tools.xaiWebSearch();
|
|
26
|
+
* const result = await llm.invoke("What are the latest AI developments?", {
|
|
27
|
+
* tools: [webSearch],
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example With domain filtering
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const webSearch = tools.xaiWebSearch({
|
|
34
|
+
* allowedDomains: ["wikipedia.org", "arxiv.org"],
|
|
35
|
+
* enableImageUnderstanding: true,
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example Excluding specific domains
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const webSearch = tools.xaiWebSearch({
|
|
42
|
+
* excludedDomains: ["example.com"],
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
function xaiWebSearch(options = {}) {
|
|
47
|
+
const tool = { type: XAI_WEB_SEARCH_TOOL_TYPE };
|
|
48
|
+
if (options.allowedDomains !== void 0) tool.allowed_domains = options.allowedDomains;
|
|
49
|
+
if (options.excludedDomains !== void 0) tool.excluded_domains = options.excludedDomains;
|
|
50
|
+
if (options.enableImageUnderstanding !== void 0) tool.enable_image_understanding = options.enableImageUnderstanding;
|
|
51
|
+
return tool;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
exports.XAI_WEB_SEARCH_TOOL_TYPE = XAI_WEB_SEARCH_TOOL_TYPE;
|
|
56
|
+
exports.xaiWebSearch = xaiWebSearch;
|
|
57
|
+
//# sourceMappingURL=web_search.cjs.map
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
//#region src/tools/web_search.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* xAI Web Search tool type constant.
|
|
4
|
+
*/
|
|
5
|
+
declare const XAI_WEB_SEARCH_TOOL_TYPE = "web_search";
|
|
6
|
+
/**
|
|
7
|
+
* xAI's built-in web search tool interface.
|
|
8
|
+
* Enables the model to search the web and browse pages for real-time information.
|
|
9
|
+
*
|
|
10
|
+
* This tool is part of xAI's agentic tool calling API.
|
|
11
|
+
*/
|
|
12
|
+
interface XAIWebSearchTool {
|
|
13
|
+
/**
|
|
14
|
+
* The type of the tool. Must be "web_search".
|
|
15
|
+
*/
|
|
16
|
+
type: typeof XAI_WEB_SEARCH_TOOL_TYPE;
|
|
17
|
+
/**
|
|
18
|
+
* Domains to exclusively include in the search (max 5).
|
|
19
|
+
* Cannot be used together with `excluded_domains`.
|
|
20
|
+
*/
|
|
21
|
+
allowed_domains?: string[];
|
|
22
|
+
/**
|
|
23
|
+
* Domains to exclude from the search (max 5).
|
|
24
|
+
* Cannot be used together with `allowed_domains`.
|
|
25
|
+
*/
|
|
26
|
+
excluded_domains?: string[];
|
|
27
|
+
/**
|
|
28
|
+
* Whether to enable image understanding.
|
|
29
|
+
* When enabled, the model can analyze images encountered during search.
|
|
30
|
+
*/
|
|
31
|
+
enable_image_understanding?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Options for the xAI web search tool (camelCase).
|
|
35
|
+
* All fields are camel-cased for the TypeScript API and are mapped to the
|
|
36
|
+
* corresponding snake_case fields in the API request.
|
|
37
|
+
*/
|
|
38
|
+
interface XAIWebSearchToolOptions {
|
|
39
|
+
/**
|
|
40
|
+
* Domains to exclusively include in the search (max 5).
|
|
41
|
+
* Cannot be used together with `excludedDomains`.
|
|
42
|
+
*
|
|
43
|
+
* @example ["wikipedia.org", "github.com"]
|
|
44
|
+
*/
|
|
45
|
+
allowedDomains?: string[];
|
|
46
|
+
/**
|
|
47
|
+
* Domains to exclude from the search (max 5).
|
|
48
|
+
* Cannot be used together with `allowedDomains`.
|
|
49
|
+
*
|
|
50
|
+
* @example ["example.com"]
|
|
51
|
+
*/
|
|
52
|
+
excludedDomains?: string[];
|
|
53
|
+
/**
|
|
54
|
+
* Whether to enable image understanding.
|
|
55
|
+
* When enabled, the model can analyze images encountered during search.
|
|
56
|
+
* Note: This increases token usage as images are processed.
|
|
57
|
+
*
|
|
58
|
+
* @default false
|
|
59
|
+
*/
|
|
60
|
+
enableImageUnderstanding?: boolean;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Creates an xAI web search tool.
|
|
64
|
+
* Enables the model to search the web and browse pages for real-time information.
|
|
65
|
+
*
|
|
66
|
+
* This tool is executed server-side by the xAI API as part of the agentic
|
|
67
|
+
* tool calling workflow.
|
|
68
|
+
*
|
|
69
|
+
* @param options - Configuration options for the web search tool
|
|
70
|
+
* @returns An XAIWebSearchTool object to pass to the model
|
|
71
|
+
*
|
|
72
|
+
* @example Basic usage
|
|
73
|
+
* ```typescript
|
|
74
|
+
* import { ChatXAIResponses, tools } from "@langchain/xai";
|
|
75
|
+
*
|
|
76
|
+
* const llm = new ChatXAIResponses({
|
|
77
|
+
* model: "grok-4-1-fast",
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* const webSearch = tools.xaiWebSearch();
|
|
81
|
+
* const result = await llm.invoke("What are the latest AI developments?", {
|
|
82
|
+
* tools: [webSearch],
|
|
83
|
+
* });
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @example With domain filtering
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const webSearch = tools.xaiWebSearch({
|
|
89
|
+
* allowedDomains: ["wikipedia.org", "arxiv.org"],
|
|
90
|
+
* enableImageUnderstanding: true,
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @example Excluding specific domains
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const webSearch = tools.xaiWebSearch({
|
|
97
|
+
* excludedDomains: ["example.com"],
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare function xaiWebSearch(options?: XAIWebSearchToolOptions): XAIWebSearchTool;
|
|
102
|
+
//#endregion
|
|
103
|
+
export { XAIWebSearchTool, XAIWebSearchToolOptions, XAI_WEB_SEARCH_TOOL_TYPE, xaiWebSearch };
|
|
104
|
+
//# sourceMappingURL=web_search.d.cts.map
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
//#region src/tools/web_search.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* xAI Web Search tool type constant.
|
|
4
|
+
*/
|
|
5
|
+
declare const XAI_WEB_SEARCH_TOOL_TYPE = "web_search";
|
|
6
|
+
/**
|
|
7
|
+
* xAI's built-in web search tool interface.
|
|
8
|
+
* Enables the model to search the web and browse pages for real-time information.
|
|
9
|
+
*
|
|
10
|
+
* This tool is part of xAI's agentic tool calling API.
|
|
11
|
+
*/
|
|
12
|
+
interface XAIWebSearchTool {
|
|
13
|
+
/**
|
|
14
|
+
* The type of the tool. Must be "web_search".
|
|
15
|
+
*/
|
|
16
|
+
type: typeof XAI_WEB_SEARCH_TOOL_TYPE;
|
|
17
|
+
/**
|
|
18
|
+
* Domains to exclusively include in the search (max 5).
|
|
19
|
+
* Cannot be used together with `excluded_domains`.
|
|
20
|
+
*/
|
|
21
|
+
allowed_domains?: string[];
|
|
22
|
+
/**
|
|
23
|
+
* Domains to exclude from the search (max 5).
|
|
24
|
+
* Cannot be used together with `allowed_domains`.
|
|
25
|
+
*/
|
|
26
|
+
excluded_domains?: string[];
|
|
27
|
+
/**
|
|
28
|
+
* Whether to enable image understanding.
|
|
29
|
+
* When enabled, the model can analyze images encountered during search.
|
|
30
|
+
*/
|
|
31
|
+
enable_image_understanding?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Options for the xAI web search tool (camelCase).
|
|
35
|
+
* All fields are camel-cased for the TypeScript API and are mapped to the
|
|
36
|
+
* corresponding snake_case fields in the API request.
|
|
37
|
+
*/
|
|
38
|
+
interface XAIWebSearchToolOptions {
|
|
39
|
+
/**
|
|
40
|
+
* Domains to exclusively include in the search (max 5).
|
|
41
|
+
* Cannot be used together with `excludedDomains`.
|
|
42
|
+
*
|
|
43
|
+
* @example ["wikipedia.org", "github.com"]
|
|
44
|
+
*/
|
|
45
|
+
allowedDomains?: string[];
|
|
46
|
+
/**
|
|
47
|
+
* Domains to exclude from the search (max 5).
|
|
48
|
+
* Cannot be used together with `allowedDomains`.
|
|
49
|
+
*
|
|
50
|
+
* @example ["example.com"]
|
|
51
|
+
*/
|
|
52
|
+
excludedDomains?: string[];
|
|
53
|
+
/**
|
|
54
|
+
* Whether to enable image understanding.
|
|
55
|
+
* When enabled, the model can analyze images encountered during search.
|
|
56
|
+
* Note: This increases token usage as images are processed.
|
|
57
|
+
*
|
|
58
|
+
* @default false
|
|
59
|
+
*/
|
|
60
|
+
enableImageUnderstanding?: boolean;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Creates an xAI web search tool.
|
|
64
|
+
* Enables the model to search the web and browse pages for real-time information.
|
|
65
|
+
*
|
|
66
|
+
* This tool is executed server-side by the xAI API as part of the agentic
|
|
67
|
+
* tool calling workflow.
|
|
68
|
+
*
|
|
69
|
+
* @param options - Configuration options for the web search tool
|
|
70
|
+
* @returns An XAIWebSearchTool object to pass to the model
|
|
71
|
+
*
|
|
72
|
+
* @example Basic usage
|
|
73
|
+
* ```typescript
|
|
74
|
+
* import { ChatXAIResponses, tools } from "@langchain/xai";
|
|
75
|
+
*
|
|
76
|
+
* const llm = new ChatXAIResponses({
|
|
77
|
+
* model: "grok-4-1-fast",
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* const webSearch = tools.xaiWebSearch();
|
|
81
|
+
* const result = await llm.invoke("What are the latest AI developments?", {
|
|
82
|
+
* tools: [webSearch],
|
|
83
|
+
* });
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @example With domain filtering
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const webSearch = tools.xaiWebSearch({
|
|
89
|
+
* allowedDomains: ["wikipedia.org", "arxiv.org"],
|
|
90
|
+
* enableImageUnderstanding: true,
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @example Excluding specific domains
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const webSearch = tools.xaiWebSearch({
|
|
97
|
+
* excludedDomains: ["example.com"],
|
|
98
|
+
* });
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare function xaiWebSearch(options?: XAIWebSearchToolOptions): XAIWebSearchTool;
|
|
102
|
+
//#endregion
|
|
103
|
+
export { XAIWebSearchTool, XAIWebSearchToolOptions, XAI_WEB_SEARCH_TOOL_TYPE, xaiWebSearch };
|
|
104
|
+
//# sourceMappingURL=web_search.d.ts.map
|