promptfoo 0.119.13 → 0.119.14
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/package.json +28 -26
- package/dist/src/app/assets/index-eJ2lMe94.js +51 -0
- package/dist/src/app/assets/{source-map-support-Bnh0UQ2S.js → source-map-support-1v4oeb7P.js} +1 -1
- package/dist/src/app/assets/sync-CtLQRuC1.js +1 -0
- package/dist/src/app/assets/{vendor-charts-T60Uk0Z3.js → vendor-charts-DnVv66VV.js} +1 -1
- package/dist/src/app/assets/{vendor-markdown-DLig-KJh.js → vendor-markdown-DCpQIyMA.js} +1 -1
- package/dist/src/app/assets/{vendor-mui-core-5BLaiG3c.js → vendor-mui-core-Boqnpf9f.js} +1 -1
- package/dist/src/app/assets/{vendor-mui-icons-fn39Fu2e.js → vendor-mui-icons-B8MqoVbj.js} +1 -1
- package/dist/src/app/assets/vendor-mui-x-CGSS6QHF.js +45 -0
- package/dist/src/app/assets/{vendor-utils-DYBMEuwX.js → vendor-utils-DdfHIEy8.js} +1 -1
- package/dist/src/app/index.html +7 -7
- package/dist/src/assertions/guardrails.d.ts +1 -1
- package/dist/src/assertions/guardrails.js +18 -9
- package/dist/src/assertions/index.d.ts +1 -1
- package/dist/src/assertions/index.js +9 -3
- package/dist/src/assertions/searchRubric.d.ts +3 -0
- package/dist/src/assertions/searchRubric.js +18 -0
- package/dist/src/commands/eval.js +1 -1
- package/dist/src/commands/modelScan.d.ts +7 -1
- package/dist/src/commands/modelScan.js +121 -59
- package/dist/src/database/index.d.ts +6 -0
- package/dist/src/database/index.js +11 -0
- package/dist/src/database/tables.d.ts +46 -24
- package/dist/src/envars.d.ts +17 -0
- package/dist/src/generated/constants.js +1 -1
- package/dist/src/logger.d.ts +5 -0
- package/dist/src/logger.js +28 -0
- package/dist/src/main.js +17 -6
- package/dist/src/matchers.d.ts +1 -0
- package/dist/src/matchers.js +80 -0
- package/dist/src/models/eval.d.ts +2 -1
- package/dist/src/models/eval.js +44 -2
- package/dist/src/prompts/grading.d.ts +1 -0
- package/dist/src/prompts/grading.js +26 -1
- package/dist/src/prompts/index.d.ts +1 -0
- package/dist/src/prompts/index.js +4 -1
- package/dist/src/providers/adaline.gateway.js +2 -2
- package/dist/src/providers/anthropic/defaults.d.ts +1 -1
- package/dist/src/providers/anthropic/defaults.js +15 -0
- package/dist/src/providers/azure/chat.d.ts +3 -1
- package/dist/src/providers/azure/chat.js +16 -3
- package/dist/src/providers/azure/defaults.js +660 -141
- package/dist/src/providers/azure/responses.d.ts +5 -0
- package/dist/src/providers/azure/responses.js +33 -4
- package/dist/src/providers/azure/types.d.ts +4 -0
- package/dist/src/providers/bedrock/agents.d.ts +1 -1
- package/dist/src/providers/bedrock/agents.js +2 -2
- package/dist/src/providers/bedrock/base.d.ts +40 -0
- package/dist/src/providers/bedrock/base.js +171 -0
- package/dist/src/providers/bedrock/converse.d.ts +146 -0
- package/dist/src/providers/bedrock/converse.js +1044 -0
- package/dist/src/providers/bedrock/index.d.ts +1 -34
- package/dist/src/providers/bedrock/index.js +4 -159
- package/dist/src/providers/bedrock/knowledgeBase.d.ts +1 -1
- package/dist/src/providers/bedrock/knowledgeBase.js +2 -2
- package/dist/src/providers/bedrock/nova-sonic.d.ts +2 -1
- package/dist/src/providers/bedrock/nova-sonic.js +2 -2
- package/dist/src/providers/claude-agent-sdk.d.ts +58 -1
- package/dist/src/providers/claude-agent-sdk.js +22 -1
- package/dist/src/providers/defaults.js +4 -0
- package/dist/src/providers/github/defaults.js +6 -6
- package/dist/src/providers/google/types.d.ts +25 -0
- package/dist/src/providers/google/util.d.ts +2 -0
- package/dist/src/providers/google/vertex.js +78 -22
- package/dist/src/providers/{groq.d.ts → groq/chat.d.ts} +26 -20
- package/dist/src/providers/groq/chat.js +79 -0
- package/dist/src/providers/groq/index.d.ts +5 -0
- package/dist/src/providers/groq/index.js +24 -0
- package/dist/src/providers/groq/responses.d.ts +106 -0
- package/dist/src/providers/groq/responses.js +64 -0
- package/dist/src/providers/groq/types.d.ts +44 -0
- package/dist/src/providers/groq/types.js +3 -0
- package/dist/src/providers/groq/util.d.ts +15 -0
- package/dist/src/providers/groq/util.js +28 -0
- package/dist/src/providers/mcp/client.d.ts +8 -0
- package/dist/src/providers/mcp/client.js +60 -10
- package/dist/src/providers/mcp/types.d.ts +21 -0
- package/dist/src/providers/openai/chatkit-pool.d.ts +114 -0
- package/dist/src/providers/openai/chatkit-pool.js +548 -0
- package/dist/src/providers/openai/chatkit-types.d.ts +73 -0
- package/dist/src/providers/openai/chatkit-types.js +3 -0
- package/dist/src/providers/openai/chatkit.d.ts +76 -0
- package/dist/src/providers/openai/chatkit.js +879 -0
- package/dist/src/providers/openai/codex-sdk.d.ts +109 -0
- package/dist/src/providers/openai/codex-sdk.js +346 -0
- package/dist/src/providers/openai/defaults.d.ts +2 -0
- package/dist/src/providers/openai/defaults.js +10 -4
- package/dist/src/providers/registry.js +48 -9
- package/dist/src/providers/responses/types.d.ts +1 -1
- package/dist/src/providers/sagemaker.d.ts +2 -2
- package/dist/src/providers/webSearchUtils.d.ts +17 -0
- package/dist/src/providers/webSearchUtils.js +169 -0
- package/dist/src/providers/xai/chat.d.ts +61 -0
- package/dist/src/providers/xai/chat.js +68 -3
- package/dist/src/providers/xai/responses.d.ts +189 -0
- package/dist/src/providers/xai/responses.js +268 -0
- package/dist/src/redteam/constants/plugins.d.ts +1 -1
- package/dist/src/redteam/constants/plugins.js +1 -1
- package/dist/src/redteam/constants/strategies.d.ts +1 -1
- package/dist/src/redteam/constants/strategies.js +1 -0
- package/dist/src/redteam/plugins/vlguard.d.ts +53 -4
- package/dist/src/redteam/plugins/vlguard.js +362 -46
- package/dist/src/redteam/providers/constants.d.ts +2 -2
- package/dist/src/redteam/providers/constants.js +2 -2
- package/dist/src/redteam/providers/crescendo/index.d.ts +1 -1
- package/dist/src/redteam/providers/crescendo/index.js +5 -3
- package/dist/src/redteam/providers/hydra/index.js +1 -1
- package/dist/src/server/routes/modelAudit.js +4 -4
- package/dist/src/share.js +4 -2
- package/dist/src/telemetry.js +44 -8
- package/dist/src/types/env.d.ts +3 -0
- package/dist/src/types/env.js +1 -0
- package/dist/src/types/index.d.ts +896 -615
- package/dist/src/types/index.js +1 -0
- package/dist/src/types/providers.d.ts +1 -0
- package/dist/src/types/tracing.d.ts +3 -0
- package/dist/src/util/database.d.ts +6 -4
- package/dist/src/util/file.js +6 -4
- package/dist/src/util/modelAuditCliParser.d.ts +4 -4
- package/dist/src/util/xlsx.js +52 -26
- package/dist/src/validators/providers.d.ts +142 -122
- package/dist/src/validators/providers.js +4 -6
- package/dist/src/validators/redteam.d.ts +36 -28
- package/dist/src/validators/redteam.js +9 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +28 -26
- package/dist/drizzle/CLAUDE.md +0 -65
- package/dist/src/app/assets/index-DifT6VGT.js +0 -51
- package/dist/src/app/assets/sync-Oo-W_Rbj.js +0 -1
- package/dist/src/app/assets/vendor-mui-x-C2xF-yiO.js +0 -45
- package/dist/src/providers/groq.js +0 -48
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ApiProvider } from '../types/index';
|
|
2
|
+
/**
|
|
3
|
+
* Check if a provider has web search capabilities
|
|
4
|
+
* @param provider The provider to check
|
|
5
|
+
* @returns true if the provider supports web search
|
|
6
|
+
*/
|
|
7
|
+
export declare function hasWebSearchCapability(provider: ApiProvider | null | undefined): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Load a provider with web search capabilities.
|
|
10
|
+
* Tries multiple providers in order of preference until one succeeds.
|
|
11
|
+
* Uses the latest and most capable models from each provider with specific checkpoint IDs.
|
|
12
|
+
*
|
|
13
|
+
* @param preferAnthropic Whether to try Anthropic first (true) or OpenAI first (false)
|
|
14
|
+
* @returns A provider with web search capabilities or null
|
|
15
|
+
*/
|
|
16
|
+
export declare function loadWebSearchProvider(preferAnthropic?: boolean): Promise<ApiProvider | null>;
|
|
17
|
+
//# sourceMappingURL=webSearchUtils.d.ts.map
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.hasWebSearchCapability = hasWebSearchCapability;
|
|
7
|
+
exports.loadWebSearchProvider = loadWebSearchProvider;
|
|
8
|
+
const logger_1 = __importDefault(require("../logger"));
|
|
9
|
+
const index_1 = require("../providers/index");
|
|
10
|
+
/**
|
|
11
|
+
* Check if a provider has web search capabilities
|
|
12
|
+
* @param provider The provider to check
|
|
13
|
+
* @returns true if the provider supports web search
|
|
14
|
+
*/
|
|
15
|
+
function hasWebSearchCapability(provider) {
|
|
16
|
+
if (!provider) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
const id = provider.id();
|
|
20
|
+
// Perplexity has built-in web search
|
|
21
|
+
if (id.includes('perplexity')) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
// Check for Google/Gemini with search tools
|
|
25
|
+
if ((id.includes('google') || id.includes('gemini') || id.includes('vertex')) &&
|
|
26
|
+
provider.config?.tools?.some((t) => t.googleSearch !== undefined)) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
// Check for xAI with search parameters
|
|
30
|
+
if (id.includes('xai') && provider.config?.search_parameters?.mode === 'on') {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
// Check for OpenAI responses API with web_search_preview tool
|
|
34
|
+
if (id.includes('openai:responses') &&
|
|
35
|
+
provider.config?.tools?.some((t) => t.type === 'web_search_preview')) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
// Check for Anthropic with web_search tool
|
|
39
|
+
if (id.includes('anthropic') &&
|
|
40
|
+
provider.config?.tools?.some((t) => t.type === 'web_search_20250305')) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Load a provider with web search capabilities.
|
|
47
|
+
* Tries multiple providers in order of preference until one succeeds.
|
|
48
|
+
* Uses the latest and most capable models from each provider with specific checkpoint IDs.
|
|
49
|
+
*
|
|
50
|
+
* @param preferAnthropic Whether to try Anthropic first (true) or OpenAI first (false)
|
|
51
|
+
* @returns A provider with web search capabilities or null
|
|
52
|
+
*/
|
|
53
|
+
async function loadWebSearchProvider(preferAnthropic = false) {
|
|
54
|
+
// Anthropic Claude 4.5 Opus (November 2024 checkpoint) with web search tool
|
|
55
|
+
const loadAnthropicWebSearch = async () => {
|
|
56
|
+
try {
|
|
57
|
+
return await (0, index_1.loadApiProvider)('anthropic:messages:claude-opus-4-5-20251101', {
|
|
58
|
+
options: {
|
|
59
|
+
config: {
|
|
60
|
+
tools: [
|
|
61
|
+
{
|
|
62
|
+
type: 'web_search_20250305',
|
|
63
|
+
name: 'web_search',
|
|
64
|
+
max_uses: 5,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
logger_1.default.debug(`Failed to load Anthropic web search provider: ${err}`);
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
// OpenAI GPT-5.1 with web search tool (via responses API)
|
|
77
|
+
const loadOpenAIWebSearch = async () => {
|
|
78
|
+
try {
|
|
79
|
+
return await (0, index_1.loadApiProvider)('openai:responses:gpt-5.1', {
|
|
80
|
+
options: {
|
|
81
|
+
config: { tools: [{ type: 'web_search_preview' }] },
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
logger_1.default.debug(`Failed to load OpenAI web search provider: ${err}`);
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
// Perplexity Sonar Pro (built-in web search)
|
|
91
|
+
const loadPerplexity = async () => {
|
|
92
|
+
try {
|
|
93
|
+
return await (0, index_1.loadApiProvider)('perplexity:sonar-pro');
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
logger_1.default.debug(`Failed to load Perplexity provider: ${err}`);
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
// Google Gemini 3 Pro Preview with googleSearch tool
|
|
101
|
+
const loadGoogleWebSearch = async () => {
|
|
102
|
+
try {
|
|
103
|
+
return await (0, index_1.loadApiProvider)('google:gemini-3-pro-preview', {
|
|
104
|
+
options: {
|
|
105
|
+
config: { tools: [{ googleSearch: {} }] },
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
logger_1.default.debug(`Failed to load Google web search provider: ${err}`);
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
// Vertex AI Gemini 3 Pro Preview with googleSearch tool
|
|
115
|
+
const loadVertexWebSearch = async () => {
|
|
116
|
+
try {
|
|
117
|
+
return await (0, index_1.loadApiProvider)('vertex:gemini-3-pro-preview', {
|
|
118
|
+
options: {
|
|
119
|
+
config: { tools: [{ googleSearch: {} }] },
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
logger_1.default.debug(`Failed to load Vertex web search provider: ${err}`);
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
// xAI Grok 4.1 Fast Reasoning with live web search
|
|
129
|
+
const loadXaiWebSearch = async () => {
|
|
130
|
+
try {
|
|
131
|
+
return await (0, index_1.loadApiProvider)('xai:grok-4-1-fast-reasoning', {
|
|
132
|
+
options: {
|
|
133
|
+
config: { search_parameters: { mode: 'on' } },
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
catch (err) {
|
|
138
|
+
logger_1.default.debug(`Failed to load xAI web search provider: ${err}`);
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
// Order providers based on preference
|
|
143
|
+
const providers = preferAnthropic
|
|
144
|
+
? [
|
|
145
|
+
loadAnthropicWebSearch,
|
|
146
|
+
loadOpenAIWebSearch,
|
|
147
|
+
loadPerplexity,
|
|
148
|
+
loadGoogleWebSearch,
|
|
149
|
+
loadVertexWebSearch,
|
|
150
|
+
loadXaiWebSearch,
|
|
151
|
+
]
|
|
152
|
+
: [
|
|
153
|
+
loadOpenAIWebSearch,
|
|
154
|
+
loadAnthropicWebSearch,
|
|
155
|
+
loadPerplexity,
|
|
156
|
+
loadGoogleWebSearch,
|
|
157
|
+
loadVertexWebSearch,
|
|
158
|
+
loadXaiWebSearch,
|
|
159
|
+
];
|
|
160
|
+
for (const getProvider of providers) {
|
|
161
|
+
const provider = await getProvider();
|
|
162
|
+
if (provider) {
|
|
163
|
+
logger_1.default.info(`Using ${provider.id()} as web search provider`);
|
|
164
|
+
return provider;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=webSearchUtils.js.map
|
|
@@ -1,9 +1,70 @@
|
|
|
1
1
|
import type { ApiProvider, ProviderOptions } from '../../types/index';
|
|
2
2
|
import type { OpenAiCompletionOptions } from '../openai/types';
|
|
3
|
+
/**
|
|
4
|
+
* xAI Agent Tools API - Server-side tool types
|
|
5
|
+
*
|
|
6
|
+
* TODO: These interfaces are defined for future use when the xAI Responses API
|
|
7
|
+
* is supported. Currently, Agent Tools (web_search, x_search, code_execution,
|
|
8
|
+
* collections_search, mcp) require the Responses API endpoint which is different
|
|
9
|
+
* from the Chat Completions API we currently use.
|
|
10
|
+
*
|
|
11
|
+
* For now, use `search_parameters` (Live Search) for real-time web/X search,
|
|
12
|
+
* which works with the Chat Completions API.
|
|
13
|
+
*
|
|
14
|
+
* See: https://docs.x.ai/docs/tools/overview
|
|
15
|
+
*/
|
|
16
|
+
export interface XAIWebSearchTool {
|
|
17
|
+
type: 'web_search';
|
|
18
|
+
filters?: {
|
|
19
|
+
/** Only search within these domains (max 5). Cannot be used with excluded_domains. */
|
|
20
|
+
allowed_domains?: string[];
|
|
21
|
+
/** Exclude these domains from search (max 5). Cannot be used with allowed_domains. */
|
|
22
|
+
excluded_domains?: string[];
|
|
23
|
+
};
|
|
24
|
+
/** Enable the model to view and analyze images encountered during search */
|
|
25
|
+
enable_image_understanding?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface XAIXSearchTool {
|
|
28
|
+
type: 'x_search';
|
|
29
|
+
/** Only consider posts from these X handles (max 10). Cannot be used with excluded_x_handles. */
|
|
30
|
+
allowed_x_handles?: string[];
|
|
31
|
+
/** Exclude posts from these X handles (max 10). Cannot be used with allowed_x_handles. */
|
|
32
|
+
excluded_x_handles?: string[];
|
|
33
|
+
/** Start date for search results (ISO8601 format: YYYY-MM-DD) */
|
|
34
|
+
from_date?: string;
|
|
35
|
+
/** End date for search results (ISO8601 format: YYYY-MM-DD) */
|
|
36
|
+
to_date?: string;
|
|
37
|
+
/** Enable the model to view and analyze images in X posts */
|
|
38
|
+
enable_image_understanding?: boolean;
|
|
39
|
+
/** Enable the model to view and analyze videos in X posts */
|
|
40
|
+
enable_video_understanding?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface XAICodeExecutionTool {
|
|
43
|
+
type: 'code_execution' | 'code_interpreter';
|
|
44
|
+
}
|
|
45
|
+
export interface XAICollectionsSearchTool {
|
|
46
|
+
type: 'collections_search' | 'file_search';
|
|
47
|
+
/** Collection IDs to search within */
|
|
48
|
+
collection_ids?: string[];
|
|
49
|
+
}
|
|
50
|
+
export interface XAIMCPTool {
|
|
51
|
+
type: 'mcp';
|
|
52
|
+
/** URL of the MCP server */
|
|
53
|
+
server_url: string;
|
|
54
|
+
/** Optional label for the MCP server */
|
|
55
|
+
server_label?: string;
|
|
56
|
+
/** Headers to send with MCP requests */
|
|
57
|
+
headers?: Record<string, string>;
|
|
58
|
+
/** Allowed tools from this MCP server */
|
|
59
|
+
allowed_tools?: string[];
|
|
60
|
+
}
|
|
61
|
+
export type XAIAgentTool = XAIWebSearchTool | XAIXSearchTool | XAICodeExecutionTool | XAICollectionsSearchTool | XAIMCPTool;
|
|
3
62
|
type XAIConfig = {
|
|
4
63
|
region?: string;
|
|
5
64
|
reasoning_effort?: 'low' | 'high';
|
|
6
65
|
search_parameters?: Record<string, any>;
|
|
66
|
+
/** xAI Agent Tools - server-side tools for agentic workflows */
|
|
67
|
+
agent_tools?: XAIAgentTool[];
|
|
7
68
|
} & OpenAiCompletionOptions;
|
|
8
69
|
type XAIProviderOptions = Omit<ProviderOptions, 'config'> & {
|
|
9
70
|
config?: {
|
|
@@ -11,6 +11,24 @@ const index_1 = require("../../util/index");
|
|
|
11
11
|
const invariant_1 = __importDefault(require("../../util/invariant"));
|
|
12
12
|
const chat_1 = require("../openai/chat");
|
|
13
13
|
exports.XAI_CHAT_MODELS = [
|
|
14
|
+
// Grok 4.1 Fast Models (2M context window)
|
|
15
|
+
{
|
|
16
|
+
id: 'grok-4-1-fast-reasoning',
|
|
17
|
+
cost: {
|
|
18
|
+
input: 0.2 / 1e6,
|
|
19
|
+
output: 0.5 / 1e6,
|
|
20
|
+
cache_read: 0.05 / 1e6,
|
|
21
|
+
},
|
|
22
|
+
aliases: ['grok-4-1-fast', 'grok-4-1-fast-latest'],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: 'grok-4-1-fast-non-reasoning',
|
|
26
|
+
cost: {
|
|
27
|
+
input: 0.2 / 1e6,
|
|
28
|
+
output: 0.5 / 1e6,
|
|
29
|
+
cache_read: 0.05 / 1e6,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
14
32
|
// Grok Code Fast Models
|
|
15
33
|
{
|
|
16
34
|
id: 'grok-code-fast-1',
|
|
@@ -29,6 +47,24 @@ exports.XAI_CHAT_MODELS = [
|
|
|
29
47
|
cache_read: 0.02 / 1e6,
|
|
30
48
|
},
|
|
31
49
|
},
|
|
50
|
+
// Grok-4 Fast Models (2M context window)
|
|
51
|
+
{
|
|
52
|
+
id: 'grok-4-fast-reasoning',
|
|
53
|
+
cost: {
|
|
54
|
+
input: 0.2 / 1e6,
|
|
55
|
+
output: 0.5 / 1e6,
|
|
56
|
+
cache_read: 0.05 / 1e6,
|
|
57
|
+
},
|
|
58
|
+
aliases: ['grok-4-fast', 'grok-4-fast-latest'],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: 'grok-4-fast-non-reasoning',
|
|
62
|
+
cost: {
|
|
63
|
+
input: 0.2 / 1e6,
|
|
64
|
+
output: 0.5 / 1e6,
|
|
65
|
+
cache_read: 0.05 / 1e6,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
32
68
|
// Grok-4 Models
|
|
33
69
|
{
|
|
34
70
|
id: 'grok-4-0709',
|
|
@@ -123,12 +159,23 @@ exports.GROK_REASONING_EFFORT_MODELS = [
|
|
|
123
159
|
];
|
|
124
160
|
// All reasoning models (including Grok-4 which doesn't support reasoning_effort)
|
|
125
161
|
exports.GROK_REASONING_MODELS = [
|
|
162
|
+
// Grok 4.1 Fast reasoning
|
|
163
|
+
'grok-4-1-fast-reasoning',
|
|
164
|
+
'grok-4-1-fast',
|
|
165
|
+
'grok-4-1-fast-latest',
|
|
166
|
+
// Grok Code Fast
|
|
126
167
|
'grok-code-fast-1',
|
|
127
168
|
'grok-code-fast',
|
|
128
169
|
'grok-code-fast-1-0825',
|
|
170
|
+
// Grok 4 Fast reasoning
|
|
171
|
+
'grok-4-fast-reasoning',
|
|
172
|
+
'grok-4-fast',
|
|
173
|
+
'grok-4-fast-latest',
|
|
174
|
+
// Grok 4
|
|
129
175
|
'grok-4-0709',
|
|
130
176
|
'grok-4',
|
|
131
177
|
'grok-4-latest',
|
|
178
|
+
// Grok 3 mini
|
|
132
179
|
'grok-3-mini-beta',
|
|
133
180
|
'grok-3-mini',
|
|
134
181
|
'grok-3-mini-latest',
|
|
@@ -136,8 +183,23 @@ exports.GROK_REASONING_MODELS = [
|
|
|
136
183
|
'grok-3-mini-fast',
|
|
137
184
|
'grok-3-mini-fast-latest',
|
|
138
185
|
];
|
|
139
|
-
// Grok-4 models that have specific parameter restrictions
|
|
140
|
-
exports.GROK_4_MODELS = [
|
|
186
|
+
// Grok-4+ models that have specific parameter restrictions (no presence_penalty, frequency_penalty, stop, reasoning_effort)
|
|
187
|
+
exports.GROK_4_MODELS = [
|
|
188
|
+
// Grok 4.1 Fast
|
|
189
|
+
'grok-4-1-fast-reasoning',
|
|
190
|
+
'grok-4-1-fast',
|
|
191
|
+
'grok-4-1-fast-latest',
|
|
192
|
+
'grok-4-1-fast-non-reasoning',
|
|
193
|
+
// Grok 4 Fast
|
|
194
|
+
'grok-4-fast-reasoning',
|
|
195
|
+
'grok-4-fast',
|
|
196
|
+
'grok-4-fast-latest',
|
|
197
|
+
'grok-4-fast-non-reasoning',
|
|
198
|
+
// Grok 4
|
|
199
|
+
'grok-4-0709',
|
|
200
|
+
'grok-4',
|
|
201
|
+
'grok-4-latest',
|
|
202
|
+
];
|
|
141
203
|
/**
|
|
142
204
|
* Calculate xAI Grok cost based on model name and token usage
|
|
143
205
|
*/
|
|
@@ -190,11 +252,14 @@ class XAIProvider extends chat_1.OpenAiChatCompletionProvider {
|
|
|
190
252
|
if (!this.supportsReasoningEffort() && result.body.reasoning_effort) {
|
|
191
253
|
delete result.body.reasoning_effort;
|
|
192
254
|
}
|
|
193
|
-
// Handle search parameters
|
|
255
|
+
// Handle search parameters (Live Search)
|
|
194
256
|
const searchParams = this.originalConfig?.search_parameters;
|
|
195
257
|
if (searchParams) {
|
|
196
258
|
result.body.search_parameters = (0, index_1.renderVarsInObject)(searchParams, context?.vars);
|
|
197
259
|
}
|
|
260
|
+
// Note: xAI Agent Tools (web_search, x_search, code_execution, etc.) require
|
|
261
|
+
// the Responses API endpoint which is not yet implemented. For now, use
|
|
262
|
+
// search_parameters for live search functionality.
|
|
198
263
|
return result;
|
|
199
264
|
}
|
|
200
265
|
constructor(modelName, providerOptions) {
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import type { ApiProvider, CallApiContextParams, CallApiOptionsParams, ProviderOptions, ProviderResponse } from '../../types/index';
|
|
2
|
+
import type { EnvOverrides } from '../../types/env';
|
|
3
|
+
/**
|
|
4
|
+
* xAI Agent Tools - Server-side tools for autonomous agent workflows
|
|
5
|
+
* These tools run on xAI's infrastructure and enable the model to:
|
|
6
|
+
* - Search the web (web_search) and X (x_search) in real-time
|
|
7
|
+
* - Execute Python code (code_interpreter)
|
|
8
|
+
* - Search uploaded collections (collections_search)
|
|
9
|
+
* - Connect to MCP servers (mcp)
|
|
10
|
+
*/
|
|
11
|
+
export interface XAIWebSearchTool {
|
|
12
|
+
type: 'web_search';
|
|
13
|
+
/** Domain filters for web search */
|
|
14
|
+
filters?: {
|
|
15
|
+
allowed_domains?: string[];
|
|
16
|
+
excluded_domains?: string[];
|
|
17
|
+
};
|
|
18
|
+
/** Enable image understanding during web browsing */
|
|
19
|
+
enable_image_understanding?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface XAIXSearchTool {
|
|
22
|
+
type: 'x_search';
|
|
23
|
+
/** X handle filters */
|
|
24
|
+
allowed_x_handles?: string[];
|
|
25
|
+
excluded_x_handles?: string[];
|
|
26
|
+
/** Date range for search (ISO8601 format: YYYY-MM-DD) */
|
|
27
|
+
from_date?: string;
|
|
28
|
+
to_date?: string;
|
|
29
|
+
/** Enable multimodal understanding */
|
|
30
|
+
enable_image_understanding?: boolean;
|
|
31
|
+
enable_video_understanding?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface XAICodeInterpreterTool {
|
|
34
|
+
type: 'code_interpreter';
|
|
35
|
+
/** Container configuration */
|
|
36
|
+
container?: {
|
|
37
|
+
/** Pre-installed pip packages */
|
|
38
|
+
pip_packages?: string[];
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export interface XAICollectionsSearchTool {
|
|
42
|
+
type: 'collections_search';
|
|
43
|
+
/** Collection IDs to search */
|
|
44
|
+
collection_ids?: string[];
|
|
45
|
+
}
|
|
46
|
+
export interface XAIMCPTool {
|
|
47
|
+
type: 'mcp';
|
|
48
|
+
/** MCP server URL */
|
|
49
|
+
server_url: string;
|
|
50
|
+
/** Optional server label */
|
|
51
|
+
server_label?: string;
|
|
52
|
+
/** Headers for MCP requests */
|
|
53
|
+
headers?: Record<string, string>;
|
|
54
|
+
/** Allowed tools from this server */
|
|
55
|
+
allowed_tools?: string[];
|
|
56
|
+
}
|
|
57
|
+
export type XAIAgentTool = XAIWebSearchTool | XAIXSearchTool | XAICodeInterpreterTool | XAICollectionsSearchTool | XAIMCPTool;
|
|
58
|
+
export interface XAIResponsesConfig {
|
|
59
|
+
/** API key (defaults to XAI_API_KEY env var) */
|
|
60
|
+
apiKey?: string;
|
|
61
|
+
/** API base URL (defaults to https://api.x.ai/v1) */
|
|
62
|
+
apiBaseUrl?: string;
|
|
63
|
+
/** Region for regional endpoints (e.g., 'us-west-1') */
|
|
64
|
+
region?: string;
|
|
65
|
+
/** Temperature (0-2) */
|
|
66
|
+
temperature?: number;
|
|
67
|
+
/** Top P sampling */
|
|
68
|
+
top_p?: number;
|
|
69
|
+
/** Maximum output tokens */
|
|
70
|
+
max_output_tokens?: number;
|
|
71
|
+
/** System instructions */
|
|
72
|
+
instructions?: string;
|
|
73
|
+
/** Response format (json_object, json_schema, or text) */
|
|
74
|
+
response_format?: any;
|
|
75
|
+
/** xAI Agent Tools (server-side tools) */
|
|
76
|
+
tools?: (XAIAgentTool | any)[];
|
|
77
|
+
/** Tool choice configuration */
|
|
78
|
+
tool_choice?: 'auto' | 'required' | 'none' | {
|
|
79
|
+
type: 'function';
|
|
80
|
+
function: {
|
|
81
|
+
name: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
/** Enable parallel tool calls */
|
|
85
|
+
parallel_tool_calls?: boolean;
|
|
86
|
+
/** Store response for later retrieval */
|
|
87
|
+
store?: boolean;
|
|
88
|
+
/** Previous response ID for multi-turn conversations */
|
|
89
|
+
previous_response_id?: string;
|
|
90
|
+
/** User identifier */
|
|
91
|
+
user?: string;
|
|
92
|
+
/** Custom headers */
|
|
93
|
+
headers?: Record<string, string>;
|
|
94
|
+
/** Maximum retries */
|
|
95
|
+
maxRetries?: number;
|
|
96
|
+
/** Function callbacks for client-side function tools */
|
|
97
|
+
functionToolCallbacks?: Record<string, (args: string) => Promise<string>>;
|
|
98
|
+
/** Passthrough parameters */
|
|
99
|
+
passthrough?: Record<string, any>;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* xAI Responses API Provider
|
|
103
|
+
*
|
|
104
|
+
* Supports xAI's Responses API with Agent Tools for autonomous agent workflows.
|
|
105
|
+
* This enables Grok models to autonomously search the web, X, execute code,
|
|
106
|
+
* and interact with MCP servers.
|
|
107
|
+
*
|
|
108
|
+
* Usage:
|
|
109
|
+
* xai:responses:grok-4-1-fast-reasoning
|
|
110
|
+
* xai:responses:grok-4-fast
|
|
111
|
+
* xai:responses:grok-4
|
|
112
|
+
*/
|
|
113
|
+
export declare class XAIResponsesProvider implements ApiProvider {
|
|
114
|
+
modelName: string;
|
|
115
|
+
config: XAIResponsesConfig;
|
|
116
|
+
env?: EnvOverrides;
|
|
117
|
+
private functionCallbackHandler;
|
|
118
|
+
private processor;
|
|
119
|
+
constructor(modelName: string, options?: {
|
|
120
|
+
config?: XAIResponsesConfig;
|
|
121
|
+
id?: string;
|
|
122
|
+
env?: EnvOverrides;
|
|
123
|
+
});
|
|
124
|
+
id(): string;
|
|
125
|
+
toString(): string;
|
|
126
|
+
toJSON(): {
|
|
127
|
+
provider: string;
|
|
128
|
+
model: string;
|
|
129
|
+
config: {
|
|
130
|
+
apiKey: undefined;
|
|
131
|
+
/** API base URL (defaults to https://api.x.ai/v1) */
|
|
132
|
+
apiBaseUrl?: string;
|
|
133
|
+
/** Region for regional endpoints (e.g., 'us-west-1') */
|
|
134
|
+
region?: string;
|
|
135
|
+
/** Temperature (0-2) */
|
|
136
|
+
temperature?: number;
|
|
137
|
+
/** Top P sampling */
|
|
138
|
+
top_p?: number;
|
|
139
|
+
/** Maximum output tokens */
|
|
140
|
+
max_output_tokens?: number;
|
|
141
|
+
/** System instructions */
|
|
142
|
+
instructions?: string;
|
|
143
|
+
/** Response format (json_object, json_schema, or text) */
|
|
144
|
+
response_format?: any;
|
|
145
|
+
/** xAI Agent Tools (server-side tools) */
|
|
146
|
+
tools?: (XAIAgentTool | any)[];
|
|
147
|
+
/** Tool choice configuration */
|
|
148
|
+
tool_choice?: "auto" | "required" | "none" | {
|
|
149
|
+
type: "function";
|
|
150
|
+
function: {
|
|
151
|
+
name: string;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
/** Enable parallel tool calls */
|
|
155
|
+
parallel_tool_calls?: boolean;
|
|
156
|
+
/** Store response for later retrieval */
|
|
157
|
+
store?: boolean;
|
|
158
|
+
/** Previous response ID for multi-turn conversations */
|
|
159
|
+
previous_response_id?: string;
|
|
160
|
+
/** User identifier */
|
|
161
|
+
user?: string;
|
|
162
|
+
/** Custom headers */
|
|
163
|
+
headers?: Record<string, string>;
|
|
164
|
+
/** Maximum retries */
|
|
165
|
+
maxRetries?: number;
|
|
166
|
+
/** Function callbacks for client-side function tools */
|
|
167
|
+
functionToolCallbacks?: Record<string, (args: string) => Promise<string>>;
|
|
168
|
+
/** Passthrough parameters */
|
|
169
|
+
passthrough?: Record<string, any>;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
protected getApiKey(): string | undefined;
|
|
173
|
+
protected getApiUrl(): string;
|
|
174
|
+
getRequestBody(prompt: string, context?: CallApiContextParams, _callApiOptions?: CallApiOptionsParams): Promise<{
|
|
175
|
+
body: Record<string, any>;
|
|
176
|
+
config: any;
|
|
177
|
+
}>;
|
|
178
|
+
callApi(prompt: string, context?: CallApiContextParams, callApiOptions?: CallApiOptionsParams): Promise<ProviderResponse>;
|
|
179
|
+
private getTokenUsage;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Create an xAI Responses provider
|
|
183
|
+
*
|
|
184
|
+
* @param providerPath - Provider path in format xai:responses:<model>
|
|
185
|
+
* @param options - Provider options
|
|
186
|
+
* @returns XAIResponsesProvider instance
|
|
187
|
+
*/
|
|
188
|
+
export declare function createXAIResponsesProvider(providerPath: string, options?: ProviderOptions): ApiProvider;
|
|
189
|
+
//# sourceMappingURL=responses.d.ts.map
|