@langchain/xai 1.0.3-dev-1765433794876 → 1.1.0

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.
@@ -0,0 +1,136 @@
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
+ * @example
116
+ * ```typescript
117
+ * import { ChatXAI, tools } from "@langchain/xai";
118
+ *
119
+ * const llm = new ChatXAI({
120
+ * model: "grok-beta",
121
+ * });
122
+ *
123
+ * const searchTool = tools.xaiLiveSearch({
124
+ * maxSearchResults: 5,
125
+ * fromDate: "2024-01-01",
126
+ * returnCitations: true
127
+ * });
128
+ *
129
+ * const llmWithSearch = llm.bindTools([searchTool]);
130
+ * const result = await llmWithSearch.invoke("What happened in tech today?");
131
+ * ```
132
+ */
133
+ declare function xaiLiveSearch(options?: XAILiveSearchToolOptions): XAILiveSearchTool;
134
+ //#endregion
135
+ export { XAILiveSearchTool, xaiLiveSearch };
136
+ //# sourceMappingURL=live_search.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live_search.d.cts","names":["XAISearchParameters","XAI_LIVE_SEARCH_TOOL_TYPE","XAI_LIVE_SEARCH_TOOL_NAME","XAILiveSearchTool","XAIWebSearchToolSource","XAINewsSearchToolSource","XAIXSearchToolSource","XAIRssSearchToolSource","XAISearchToolSource","XAILiveSearchToolOptions","xaiLiveSearch"],"sources":["../../src/tools/live_search.d.ts"],"sourcesContent":["import type { XAISearchParameters } from \"../live_search.js\";\n/**\n * xAI's deprecated live_search tool type.\n */\nexport declare const XAI_LIVE_SEARCH_TOOL_TYPE = \"live_search_deprecated_20251215\";\nexport declare const XAI_LIVE_SEARCH_TOOL_NAME = \"live_search\";\n/**\n * xAI's built-in live_search tool type.\n * Enables the model to search the web for real-time information.\n */\nexport interface XAILiveSearchTool extends XAISearchParameters {\n /**\n * The name of the tool. Must be \"live_search\" for xAI's built-in search.\n */\n name: typeof XAI_LIVE_SEARCH_TOOL_NAME;\n /**\n * The type of the tool. This uses a deprecated Live Search API shape:\n * the advanced agentic search capabilities powering grok.com are generally\n * available in the new agentic tool calling API, and the Live Search API\n * will be deprecated by December 15, 2025.\n */\n type: typeof XAI_LIVE_SEARCH_TOOL_TYPE;\n}\n/**\n * Web search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAIWebSource` internally.\n */\nexport interface XAIWebSearchToolSource {\n type: \"web\";\n country?: string;\n excludedWebsites?: string[];\n allowedWebsites?: string[];\n safeSearch?: boolean;\n}\n/**\n * News search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAINewsSource` internally.\n */\nexport interface XAINewsSearchToolSource {\n type: \"news\";\n country?: string;\n excludedWebsites?: string[];\n safeSearch?: boolean;\n}\n/**\n * X (formerly Twitter) search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAIXSource` internally.\n */\nexport interface XAIXSearchToolSource {\n type: \"x\";\n includedXHandles?: string[];\n excludedXHandles?: string[];\n postFavoriteCount?: number;\n postViewCount?: number;\n}\n/**\n * RSS feed search source configuration for the xAI live search tool.\n * The structure matches `XAIRssSource` (only `links`).\n */\nexport interface XAIRssSearchToolSource {\n type: \"rss\";\n links: string[];\n}\nexport type XAISearchToolSource = XAIWebSearchToolSource | XAINewsSearchToolSource | XAIXSearchToolSource | XAIRssSearchToolSource;\n/**\n * Options for the xAI live 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 underlying `XAISearchParameters`\n * object that is sent to xAI's deprecated Live Search API.\n */\nexport interface XAILiveSearchToolOptions {\n /**\n * Controls when the model should perform a search.\n * - \"auto\": Let the model decide when to search (default)\n * - \"on\": Always search for every request\n * - \"off\": Never search\n */\n mode?: \"auto\" | \"on\" | \"off\";\n /**\n * Maximum number of search results to return.\n * @default 20\n */\n maxSearchResults?: number;\n /**\n * Filter search results to only include content from after this date.\n * Format: ISO 8601 date string (e.g., \"2024-01-01\")\n */\n fromDate?: string;\n /**\n * Filter search results to only include content from before this date.\n * Format: ISO 8601 date string (e.g., \"2024-12-31\")\n */\n toDate?: string;\n /**\n * Whether to return citations/sources for the search results.\n * @default true\n */\n returnCitations?: boolean;\n /**\n * Specific web/news/X/RSS sources that can be used for the search.\n * These are converted to the snake_case `XAISearchSource` structures\n * used by the underlying xAI Live Search API.\n */\n sources?: XAISearchToolSource[];\n}\n/**\n * Creates an xAI built-in live search tool.\n * Enables the model to search the web for real-time information.\n *\n * This tool is executed server-side by the xAI API.\n *\n * @example\n * ```typescript\n * import { ChatXAI, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAI({\n * model: \"grok-beta\",\n * });\n *\n * const searchTool = tools.xaiLiveSearch({\n * maxSearchResults: 5,\n * fromDate: \"2024-01-01\",\n * returnCitations: true\n * });\n *\n * const llmWithSearch = llm.bindTools([searchTool]);\n * const result = await llmWithSearch.invoke(\"What happened in tech today?\");\n * ```\n */\nexport declare function xaiLiveSearch(options?: XAILiveSearchToolOptions): XAILiveSearchTool;\n//# sourceMappingURL=live_search.d.ts.map"],"mappings":";;;;;;AAIA;AACqBE,cADAD,yBAAAA,GACyB,iCAAA;AAK7BE,cALID,yBAAAA,GAKa,aAAA;;;;AAA4B;AAiB7CE,UAjBAD,iBAAAA,SAA0BH,mBAiBJ,CAAA;EAWtBK;AAUjB;AAWA;EAIYG,IAAAA,EAAAA,OAjDKN,yBAiDc;EAAGE;;;;AAAgG;AAOlI;EA2DwBM,IAAAA,EAAAA,OA5GPT,yBA4G+BQ;;;;;;UAtG/BL,sBAAAA;;;;;;;;;;;UAWAC,uBAAAA;;;;;;;;;;UAUAC,oBAAAA;;;;;;;;;;;UAWAC,sBAAAA;;;;KAILC,mBAAAA,GAAsBJ,yBAAyBC,0BAA0BC,uBAAuBC;;;;;;;UAO3FE,wBAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAiCHD;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0BUE,aAAAA,WAAwBD,2BAA2BN"}
@@ -0,0 +1,136 @@
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
+ * @example
116
+ * ```typescript
117
+ * import { ChatXAI, tools } from "@langchain/xai";
118
+ *
119
+ * const llm = new ChatXAI({
120
+ * model: "grok-beta",
121
+ * });
122
+ *
123
+ * const searchTool = tools.xaiLiveSearch({
124
+ * maxSearchResults: 5,
125
+ * fromDate: "2024-01-01",
126
+ * returnCitations: true
127
+ * });
128
+ *
129
+ * const llmWithSearch = llm.bindTools([searchTool]);
130
+ * const result = await llmWithSearch.invoke("What happened in tech today?");
131
+ * ```
132
+ */
133
+ declare function xaiLiveSearch(options?: XAILiveSearchToolOptions): XAILiveSearchTool;
134
+ //#endregion
135
+ export { XAILiveSearchTool, xaiLiveSearch };
136
+ //# sourceMappingURL=live_search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live_search.d.ts","names":["XAISearchParameters","XAI_LIVE_SEARCH_TOOL_TYPE","XAI_LIVE_SEARCH_TOOL_NAME","XAILiveSearchTool","XAIWebSearchToolSource","XAINewsSearchToolSource","XAIXSearchToolSource","XAIRssSearchToolSource","XAISearchToolSource","XAILiveSearchToolOptions","xaiLiveSearch"],"sources":["../../src/tools/live_search.d.ts"],"sourcesContent":["import type { XAISearchParameters } from \"../live_search.js\";\n/**\n * xAI's deprecated live_search tool type.\n */\nexport declare const XAI_LIVE_SEARCH_TOOL_TYPE = \"live_search_deprecated_20251215\";\nexport declare const XAI_LIVE_SEARCH_TOOL_NAME = \"live_search\";\n/**\n * xAI's built-in live_search tool type.\n * Enables the model to search the web for real-time information.\n */\nexport interface XAILiveSearchTool extends XAISearchParameters {\n /**\n * The name of the tool. Must be \"live_search\" for xAI's built-in search.\n */\n name: typeof XAI_LIVE_SEARCH_TOOL_NAME;\n /**\n * The type of the tool. This uses a deprecated Live Search API shape:\n * the advanced agentic search capabilities powering grok.com are generally\n * available in the new agentic tool calling API, and the Live Search API\n * will be deprecated by December 15, 2025.\n */\n type: typeof XAI_LIVE_SEARCH_TOOL_TYPE;\n}\n/**\n * Web search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAIWebSource` internally.\n */\nexport interface XAIWebSearchToolSource {\n type: \"web\";\n country?: string;\n excludedWebsites?: string[];\n allowedWebsites?: string[];\n safeSearch?: boolean;\n}\n/**\n * News search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAINewsSource` internally.\n */\nexport interface XAINewsSearchToolSource {\n type: \"news\";\n country?: string;\n excludedWebsites?: string[];\n safeSearch?: boolean;\n}\n/**\n * X (formerly Twitter) search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAIXSource` internally.\n */\nexport interface XAIXSearchToolSource {\n type: \"x\";\n includedXHandles?: string[];\n excludedXHandles?: string[];\n postFavoriteCount?: number;\n postViewCount?: number;\n}\n/**\n * RSS feed search source configuration for the xAI live search tool.\n * The structure matches `XAIRssSource` (only `links`).\n */\nexport interface XAIRssSearchToolSource {\n type: \"rss\";\n links: string[];\n}\nexport type XAISearchToolSource = XAIWebSearchToolSource | XAINewsSearchToolSource | XAIXSearchToolSource | XAIRssSearchToolSource;\n/**\n * Options for the xAI live 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 underlying `XAISearchParameters`\n * object that is sent to xAI's deprecated Live Search API.\n */\nexport interface XAILiveSearchToolOptions {\n /**\n * Controls when the model should perform a search.\n * - \"auto\": Let the model decide when to search (default)\n * - \"on\": Always search for every request\n * - \"off\": Never search\n */\n mode?: \"auto\" | \"on\" | \"off\";\n /**\n * Maximum number of search results to return.\n * @default 20\n */\n maxSearchResults?: number;\n /**\n * Filter search results to only include content from after this date.\n * Format: ISO 8601 date string (e.g., \"2024-01-01\")\n */\n fromDate?: string;\n /**\n * Filter search results to only include content from before this date.\n * Format: ISO 8601 date string (e.g., \"2024-12-31\")\n */\n toDate?: string;\n /**\n * Whether to return citations/sources for the search results.\n * @default true\n */\n returnCitations?: boolean;\n /**\n * Specific web/news/X/RSS sources that can be used for the search.\n * These are converted to the snake_case `XAISearchSource` structures\n * used by the underlying xAI Live Search API.\n */\n sources?: XAISearchToolSource[];\n}\n/**\n * Creates an xAI built-in live search tool.\n * Enables the model to search the web for real-time information.\n *\n * This tool is executed server-side by the xAI API.\n *\n * @example\n * ```typescript\n * import { ChatXAI, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAI({\n * model: \"grok-beta\",\n * });\n *\n * const searchTool = tools.xaiLiveSearch({\n * maxSearchResults: 5,\n * fromDate: \"2024-01-01\",\n * returnCitations: true\n * });\n *\n * const llmWithSearch = llm.bindTools([searchTool]);\n * const result = await llmWithSearch.invoke(\"What happened in tech today?\");\n * ```\n */\nexport declare function xaiLiveSearch(options?: XAILiveSearchToolOptions): XAILiveSearchTool;\n//# sourceMappingURL=live_search.d.ts.map"],"mappings":";;;;;;AAIA;AACqBE,cADAD,yBAAAA,GACyB,iCAAA;AAK7BE,cALID,yBAAAA,GAKa,aAAA;;;;AAA4B;AAiB7CE,UAjBAD,iBAAAA,SAA0BH,mBAiBJ,CAAA;EAWtBK;AAUjB;AAWA;EAIYG,IAAAA,EAAAA,OAjDKN,yBAiDc;EAAGE;;;;AAAgG;AAOlI;EA2DwBM,IAAAA,EAAAA,OA5GPT,yBA4G+BQ;;;;;;UAtG/BL,sBAAAA;;;;;;;;;;;UAWAC,uBAAAA;;;;;;;;;;UAUAC,oBAAAA;;;;;;;;;;;UAWAC,sBAAAA;;;;KAILC,mBAAAA,GAAsBJ,yBAAyBC,0BAA0BC,uBAAuBC;;;;;;;UAO3FE,wBAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAiCHD;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0BUE,aAAAA,WAAwBD,2BAA2BN"}
@@ -0,0 +1,78 @@
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
+ * @example
46
+ * ```typescript
47
+ * import { ChatXAI, tools } from "@langchain/xai";
48
+ *
49
+ * const llm = new ChatXAI({
50
+ * model: "grok-beta",
51
+ * });
52
+ *
53
+ * const searchTool = tools.xaiLiveSearch({
54
+ * maxSearchResults: 5,
55
+ * fromDate: "2024-01-01",
56
+ * returnCitations: true
57
+ * });
58
+ *
59
+ * const llmWithSearch = llm.bindTools([searchTool]);
60
+ * const result = await llmWithSearch.invoke("What happened in tech today?");
61
+ * ```
62
+ */
63
+ function xaiLiveSearch(options = {}) {
64
+ return {
65
+ type: XAI_LIVE_SEARCH_TOOL_TYPE,
66
+ name: XAI_LIVE_SEARCH_TOOL_NAME,
67
+ mode: options?.mode,
68
+ max_search_results: options?.maxSearchResults,
69
+ from_date: options?.fromDate,
70
+ to_date: options?.toDate,
71
+ return_citations: options?.returnCitations,
72
+ sources: options?.sources?.map(mapToolSourceToSearchSource)
73
+ };
74
+ }
75
+
76
+ //#endregion
77
+ export { XAI_LIVE_SEARCH_TOOL_TYPE, xaiLiveSearch };
78
+ //# sourceMappingURL=live_search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live_search.js","names":["source: XAISearchToolSource","_exhaustive: never","options: XAILiveSearchToolOptions"],"sources":["../../src/tools/live_search.ts"],"sourcesContent":["import type { XAISearchParameters, XAISearchSource } from \"../live_search.js\";\n\n/**\n * xAI's deprecated live_search tool type.\n */\nexport const XAI_LIVE_SEARCH_TOOL_TYPE = \"live_search_deprecated_20251215\";\nexport const XAI_LIVE_SEARCH_TOOL_NAME = \"live_search\";\n\n/**\n * xAI's built-in live_search tool type.\n * Enables the model to search the web for real-time information.\n */\nexport interface XAILiveSearchTool extends XAISearchParameters {\n /**\n * The name of the tool. Must be \"live_search\" for xAI's built-in search.\n */\n name: typeof XAI_LIVE_SEARCH_TOOL_NAME;\n /**\n * The type of the tool. This uses a deprecated Live Search API shape:\n * the advanced agentic search capabilities powering grok.com are generally\n * available in the new agentic tool calling API, and the Live Search API\n * will be deprecated by December 15, 2025.\n */\n type: typeof XAI_LIVE_SEARCH_TOOL_TYPE;\n}\n\n/**\n * Web search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAIWebSource` internally.\n */\nexport interface XAIWebSearchToolSource {\n type: \"web\";\n country?: string;\n excludedWebsites?: string[];\n allowedWebsites?: string[];\n safeSearch?: boolean;\n}\n\n/**\n * News search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAINewsSource` internally.\n */\nexport interface XAINewsSearchToolSource {\n type: \"news\";\n country?: string;\n excludedWebsites?: string[];\n safeSearch?: boolean;\n}\n\n/**\n * X (formerly Twitter) search source configuration for the xAI live search tool (camelCase).\n * This is converted to the snake_case `XAIXSource` internally.\n */\nexport interface XAIXSearchToolSource {\n type: \"x\";\n includedXHandles?: string[];\n excludedXHandles?: string[];\n postFavoriteCount?: number;\n postViewCount?: number;\n}\n\n/**\n * RSS feed search source configuration for the xAI live search tool.\n * The structure matches `XAIRssSource` (only `links`).\n */\nexport interface XAIRssSearchToolSource {\n type: \"rss\";\n links: string[];\n}\n\nexport type XAISearchToolSource =\n | XAIWebSearchToolSource\n | XAINewsSearchToolSource\n | XAIXSearchToolSource\n | XAIRssSearchToolSource;\n\n/**\n * Options for the xAI live 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 underlying `XAISearchParameters`\n * object that is sent to xAI's deprecated Live Search API.\n */\nexport interface XAILiveSearchToolOptions {\n /**\n * Controls when the model should perform a search.\n * - \"auto\": Let the model decide when to search (default)\n * - \"on\": Always search for every request\n * - \"off\": Never search\n */\n mode?: \"auto\" | \"on\" | \"off\";\n /**\n * Maximum number of search results to return.\n * @default 20\n */\n maxSearchResults?: number;\n /**\n * Filter search results to only include content from after this date.\n * Format: ISO 8601 date string (e.g., \"2024-01-01\")\n */\n fromDate?: string;\n /**\n * Filter search results to only include content from before this date.\n * Format: ISO 8601 date string (e.g., \"2024-12-31\")\n */\n toDate?: string;\n /**\n * Whether to return citations/sources for the search results.\n * @default true\n */\n returnCitations?: boolean;\n /**\n * Specific web/news/X/RSS sources that can be used for the search.\n * These are converted to the snake_case `XAISearchSource` structures\n * used by the underlying xAI Live Search API.\n */\n sources?: XAISearchToolSource[];\n}\n\nfunction mapToolSourceToSearchSource(\n source: XAISearchToolSource\n): XAISearchSource {\n switch (source.type) {\n case \"web\":\n return {\n type: \"web\",\n ...(source.country !== undefined && { country: source.country }),\n ...(source.allowedWebsites !== undefined && {\n allowed_websites: source.allowedWebsites,\n }),\n ...(source.excludedWebsites !== undefined && {\n excluded_websites: source.excludedWebsites,\n }),\n ...(source.safeSearch !== undefined && {\n safe_search: source.safeSearch,\n }),\n };\n case \"news\":\n return {\n type: \"news\",\n ...(source.country !== undefined && { country: source.country }),\n ...(source.excludedWebsites !== undefined && {\n excluded_websites: source.excludedWebsites,\n }),\n ...(source.safeSearch !== undefined && {\n safe_search: source.safeSearch,\n }),\n };\n case \"x\":\n return {\n type: \"x\",\n ...(source.includedXHandles !== undefined && {\n included_x_handles: source.includedXHandles,\n }),\n ...(source.excludedXHandles !== undefined && {\n excluded_x_handles: source.excludedXHandles,\n }),\n ...(source.postFavoriteCount !== undefined && {\n post_favorite_count: source.postFavoriteCount,\n }),\n ...(source.postViewCount !== undefined && {\n post_view_count: source.postViewCount,\n }),\n };\n case \"rss\":\n return {\n type: \"rss\",\n links: source.links,\n };\n default: {\n const _exhaustive: never = source;\n return _exhaustive;\n }\n }\n}\n\n/**\n * Creates an xAI built-in live search tool.\n * Enables the model to search the web for real-time information.\n *\n * This tool is executed server-side by the xAI API.\n *\n * @example\n * ```typescript\n * import { ChatXAI, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAI({\n * model: \"grok-beta\",\n * });\n *\n * const searchTool = tools.xaiLiveSearch({\n * maxSearchResults: 5,\n * fromDate: \"2024-01-01\",\n * returnCitations: true\n * });\n *\n * const llmWithSearch = llm.bindTools([searchTool]);\n * const result = await llmWithSearch.invoke(\"What happened in tech today?\");\n * ```\n */\nexport function xaiLiveSearch(\n options: XAILiveSearchToolOptions = {}\n): XAILiveSearchTool {\n return {\n type: XAI_LIVE_SEARCH_TOOL_TYPE,\n name: XAI_LIVE_SEARCH_TOOL_NAME,\n mode: options?.mode,\n max_search_results: options?.maxSearchResults,\n from_date: options?.fromDate,\n to_date: options?.toDate,\n return_citations: options?.returnCitations,\n sources: options?.sources?.map(mapToolSourceToSearchSource),\n } satisfies XAILiveSearchTool;\n}\n"],"mappings":";;;;AAKA,MAAa,4BAA4B;AACzC,MAAa,4BAA4B;AAgHzC,SAAS,4BACPA,QACiB;AACjB,SAAQ,OAAO,MAAf;EACE,KAAK,MACH,QAAO;GACL,MAAM;GACN,GAAI,OAAO,YAAY,UAAa,EAAE,SAAS,OAAO,QAAS;GAC/D,GAAI,OAAO,oBAAoB,UAAa,EAC1C,kBAAkB,OAAO,gBAC1B;GACD,GAAI,OAAO,qBAAqB,UAAa,EAC3C,mBAAmB,OAAO,iBAC3B;GACD,GAAI,OAAO,eAAe,UAAa,EACrC,aAAa,OAAO,WACrB;EACF;EACH,KAAK,OACH,QAAO;GACL,MAAM;GACN,GAAI,OAAO,YAAY,UAAa,EAAE,SAAS,OAAO,QAAS;GAC/D,GAAI,OAAO,qBAAqB,UAAa,EAC3C,mBAAmB,OAAO,iBAC3B;GACD,GAAI,OAAO,eAAe,UAAa,EACrC,aAAa,OAAO,WACrB;EACF;EACH,KAAK,IACH,QAAO;GACL,MAAM;GACN,GAAI,OAAO,qBAAqB,UAAa,EAC3C,oBAAoB,OAAO,iBAC5B;GACD,GAAI,OAAO,qBAAqB,UAAa,EAC3C,oBAAoB,OAAO,iBAC5B;GACD,GAAI,OAAO,sBAAsB,UAAa,EAC5C,qBAAqB,OAAO,kBAC7B;GACD,GAAI,OAAO,kBAAkB,UAAa,EACxC,iBAAiB,OAAO,cACzB;EACF;EACH,KAAK,MACH,QAAO;GACL,MAAM;GACN,OAAO,OAAO;EACf;EACH,SAAS;GACP,MAAMC,cAAqB;AAC3B,UAAO;EACR;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;AA0BD,SAAgB,cACdC,UAAoC,CAAE,GACnB;AACnB,QAAO;EACL,MAAM;EACN,MAAM;EACN,MAAM,SAAS;EACf,oBAAoB,SAAS;EAC7B,WAAW,SAAS;EACpB,SAAS,SAAS;EAClB,kBAAkB,SAAS;EAC3B,SAAS,SAAS,SAAS,IAAI,4BAA4B;CAC5D;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/xai",
3
- "version": "1.0.3-dev-1765433794876",
3
+ "version": "1.1.0",
4
4
  "description": "xAI integration for LangChain.js",
5
5
  "author": "LangChain",
6
6
  "license": "MIT",
@@ -14,10 +14,10 @@
14
14
  },
15
15
  "homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-xai/",
16
16
  "dependencies": {
17
- "@langchain/openai": "1.2.0-dev-1765433794876"
17
+ "@langchain/openai": "1.2.0"
18
18
  },
19
19
  "peerDependencies": {
20
- "@langchain/core": "1.1.5-dev-1765433794876"
20
+ "@langchain/core": "^1.0.0"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@tsconfig/recommended": "^1.0.3",
@@ -31,11 +31,11 @@
31
31
  "typescript": "~5.8.3",
32
32
  "vitest": "^3.2.4",
33
33
  "zod": "^3.25.76",
34
- "@langchain/core": "1.1.5-dev-1765433794876",
34
+ "@langchain/openai": "^1.2.0",
35
35
  "@langchain/eslint": "0.1.1",
36
- "@langchain/tsconfig": "0.0.1",
37
- "@langchain/standard-tests": "0.0.8-dev-1765433794876",
38
- "@langchain/openai": "^1.2.0-dev-1765433794876"
36
+ "@langchain/standard-tests": "0.0.8",
37
+ "@langchain/core": "1.1.5",
38
+ "@langchain/tsconfig": "0.0.1"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"