@kenkaiiii/gg-ai 5.80.1 → 5.82.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.
- package/dist/index.cjs +43 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -2
- package/dist/index.d.ts +25 -2
- package/dist/index.js +41 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -223,6 +223,10 @@ interface StreamOptions {
|
|
|
223
223
|
promptCacheKey?: string;
|
|
224
224
|
/** OpenAI service tier for latency-sensitive requests. Only sent to first-party OpenAI API calls. */
|
|
225
225
|
serviceTier?: "auto" | "default" | "flex" | "priority";
|
|
226
|
+
/** Provider speed tier. "fast" sends Anthropic `speed: "fast"` (first-party API
|
|
227
|
+
* only) or OpenAI/Codex `service_tier: "priority"`. Set automatically by
|
|
228
|
+
* `stream()` for fast-mode model ids (see `resolveFastModeModel`). */
|
|
229
|
+
speed?: "standard" | "fast";
|
|
226
230
|
/** Codex endpoint only: send the Responses-Lite request shape (lite header,
|
|
227
231
|
* `parallel_tool_calls: false`, all-turns reasoning context). Unset follows
|
|
228
232
|
* the model family (on for gpt-5.6/gpt-6 models). Lite allows only one tool
|
|
@@ -430,7 +434,26 @@ declare function localWireModelId(id: string): string;
|
|
|
430
434
|
* const response = await stream({ provider: "openai", model: "gpt-4.1", messages });
|
|
431
435
|
* ```
|
|
432
436
|
*/
|
|
433
|
-
declare function stream(
|
|
437
|
+
declare function stream(requested: StreamOptions): StreamResult;
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Fast-mode model ids: `<base model id>` + this suffix selects the same model
|
|
441
|
+
* at its provider's faster speed tier. The suffixed id is a registry/UI concept
|
|
442
|
+
* only — `stream()` rewrites it to the base id plus `speed: "fast"` before any
|
|
443
|
+
* provider sees it, so every model-id check downstream still matches.
|
|
444
|
+
*/
|
|
445
|
+
declare const FAST_MODE_SUFFIX = "-fast";
|
|
446
|
+
interface FastModeResolution {
|
|
447
|
+
/** The real model id to send on the wire. */
|
|
448
|
+
model: string;
|
|
449
|
+
/** True when the id selected a fast speed tier. */
|
|
450
|
+
fast: boolean;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Split a fast-mode model id into its base model. Ids without the suffix, or
|
|
454
|
+
* whose base doesn't support fast mode for `provider`, pass through unchanged.
|
|
455
|
+
*/
|
|
456
|
+
declare function resolveFastModeModel(provider: Provider, model: string): FastModeResolution;
|
|
434
457
|
|
|
435
458
|
/** What the embedded text will be used for. See `EmbedOptions.inputType`. */
|
|
436
459
|
type EmbedInputType = "query" | "document";
|
|
@@ -1031,4 +1054,4 @@ declare function palsuEmbedding(text: string, dimensions?: number): number[];
|
|
|
1031
1054
|
/** Deterministic fake relevance: the share of distinct query words found in the document (0–1). */
|
|
1032
1055
|
declare function palsuRerankScore(query: string, document: string): number;
|
|
1033
1056
|
|
|
1034
|
-
export { type AssistantMessage, type CacheRetention, type ChatErrorReason, type ContentPart, type DoneEvent, type EmbedInputType, type EmbedOptions, type EmbedResult, type EmbedUsage, type ErrorEvent, type ErrorSource, EventStream, type FormattedChatError, type FormattedError, GGAIError, type ImageContent, type Message, type MessageProvenance, type MessageProvenanceKind, type MessageProvenanceSource, type MessageProvenanceVisibility, type OpenRouterProviderPreferences, type PalsuModelConfig, type PalsuModelHandle, type PalsuProviderConfig, type PalsuProviderHandle, type PalsuProviderState, type PalsuResponse, type PalsuResponseFactory, type PreparedContext, type Provider, type ProviderCapability, type ProviderDiagnosticFn, type ProviderEmbedFn, type ProviderEmbedRequest, type ProviderEmbedResponse, type ProviderEntry, ProviderError, type ProviderOptions, type ProviderRerankFn, type ProviderRerankRequest, type ProviderRerankResponse, type ProviderStreamFn, REDACTED as REDACTION_MARKER, type RawContent, type RedactionOptions, type RerankOptions, type RerankResponse, type RerankResult, type RerankUsage, type ServerToolCall, type ServerToolCallEvent, type ServerToolDefinition, type ServerToolResult, type ServerToolResultEvent, type StopReason, type StreamEvent, type StreamOptions, type StreamResponse, StreamResult, type SystemMessage, TOOL_CALL_NAME_RULES, type TextContent, type TextDeltaEvent, type ThinkingContent, type ThinkingDeltaEvent, type ThinkingLevel, type Tool, type ToolCall, type ToolCallDeltaEvent, type ToolCallDoneEvent, type ToolCallNameRule, type ToolChoice, type ToolResult, type ToolResultContent, type ToolResultMessage, type Usage, type UserMessage, type VideoContent, clampProviderContextImages, classifyProviderError, continuesTurn, dropInvalidToolCalls, embed, environmentSecrets, formatChatError, formatError, formatErrorForDisplay, hasLoneSurrogate, isHardBillingMessage, isUsageLimitError, isValidToolCallName, localWireModelId, opensTurn, palsuAssistantMessage, palsuEmbedding, palsuRerankScore, palsuText, palsuThinking, palsuToolCall, prewarmAnthropicCache, providerRegistry, redactText, redactValue, registerPalsuProvider, rerank, resolveToolSchema, sanitizeMessagesForWire, setProviderDiagnostic, sliceHead, sliceTail, stream, toAnthropicMessages, toOpenAIMessages, toWellFormedText, toolCallNameRuleFor, usesResponsesLite };
|
|
1057
|
+
export { type AssistantMessage, type CacheRetention, type ChatErrorReason, type ContentPart, type DoneEvent, type EmbedInputType, type EmbedOptions, type EmbedResult, type EmbedUsage, type ErrorEvent, type ErrorSource, EventStream, FAST_MODE_SUFFIX, type FastModeResolution, type FormattedChatError, type FormattedError, GGAIError, type ImageContent, type Message, type MessageProvenance, type MessageProvenanceKind, type MessageProvenanceSource, type MessageProvenanceVisibility, type OpenRouterProviderPreferences, type PalsuModelConfig, type PalsuModelHandle, type PalsuProviderConfig, type PalsuProviderHandle, type PalsuProviderState, type PalsuResponse, type PalsuResponseFactory, type PreparedContext, type Provider, type ProviderCapability, type ProviderDiagnosticFn, type ProviderEmbedFn, type ProviderEmbedRequest, type ProviderEmbedResponse, type ProviderEntry, ProviderError, type ProviderOptions, type ProviderRerankFn, type ProviderRerankRequest, type ProviderRerankResponse, type ProviderStreamFn, REDACTED as REDACTION_MARKER, type RawContent, type RedactionOptions, type RerankOptions, type RerankResponse, type RerankResult, type RerankUsage, type ServerToolCall, type ServerToolCallEvent, type ServerToolDefinition, type ServerToolResult, type ServerToolResultEvent, type StopReason, type StreamEvent, type StreamOptions, type StreamResponse, StreamResult, type SystemMessage, TOOL_CALL_NAME_RULES, type TextContent, type TextDeltaEvent, type ThinkingContent, type ThinkingDeltaEvent, type ThinkingLevel, type Tool, type ToolCall, type ToolCallDeltaEvent, type ToolCallDoneEvent, type ToolCallNameRule, type ToolChoice, type ToolResult, type ToolResultContent, type ToolResultMessage, type Usage, type UserMessage, type VideoContent, clampProviderContextImages, classifyProviderError, continuesTurn, dropInvalidToolCalls, embed, environmentSecrets, formatChatError, formatError, formatErrorForDisplay, hasLoneSurrogate, isHardBillingMessage, isUsageLimitError, isValidToolCallName, localWireModelId, opensTurn, palsuAssistantMessage, palsuEmbedding, palsuRerankScore, palsuText, palsuThinking, palsuToolCall, prewarmAnthropicCache, providerRegistry, redactText, redactValue, registerPalsuProvider, rerank, resolveFastModeModel, resolveToolSchema, sanitizeMessagesForWire, setProviderDiagnostic, sliceHead, sliceTail, stream, toAnthropicMessages, toOpenAIMessages, toWellFormedText, toolCallNameRuleFor, usesResponsesLite };
|
package/dist/index.d.ts
CHANGED
|
@@ -223,6 +223,10 @@ interface StreamOptions {
|
|
|
223
223
|
promptCacheKey?: string;
|
|
224
224
|
/** OpenAI service tier for latency-sensitive requests. Only sent to first-party OpenAI API calls. */
|
|
225
225
|
serviceTier?: "auto" | "default" | "flex" | "priority";
|
|
226
|
+
/** Provider speed tier. "fast" sends Anthropic `speed: "fast"` (first-party API
|
|
227
|
+
* only) or OpenAI/Codex `service_tier: "priority"`. Set automatically by
|
|
228
|
+
* `stream()` for fast-mode model ids (see `resolveFastModeModel`). */
|
|
229
|
+
speed?: "standard" | "fast";
|
|
226
230
|
/** Codex endpoint only: send the Responses-Lite request shape (lite header,
|
|
227
231
|
* `parallel_tool_calls: false`, all-turns reasoning context). Unset follows
|
|
228
232
|
* the model family (on for gpt-5.6/gpt-6 models). Lite allows only one tool
|
|
@@ -430,7 +434,26 @@ declare function localWireModelId(id: string): string;
|
|
|
430
434
|
* const response = await stream({ provider: "openai", model: "gpt-4.1", messages });
|
|
431
435
|
* ```
|
|
432
436
|
*/
|
|
433
|
-
declare function stream(
|
|
437
|
+
declare function stream(requested: StreamOptions): StreamResult;
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Fast-mode model ids: `<base model id>` + this suffix selects the same model
|
|
441
|
+
* at its provider's faster speed tier. The suffixed id is a registry/UI concept
|
|
442
|
+
* only — `stream()` rewrites it to the base id plus `speed: "fast"` before any
|
|
443
|
+
* provider sees it, so every model-id check downstream still matches.
|
|
444
|
+
*/
|
|
445
|
+
declare const FAST_MODE_SUFFIX = "-fast";
|
|
446
|
+
interface FastModeResolution {
|
|
447
|
+
/** The real model id to send on the wire. */
|
|
448
|
+
model: string;
|
|
449
|
+
/** True when the id selected a fast speed tier. */
|
|
450
|
+
fast: boolean;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Split a fast-mode model id into its base model. Ids without the suffix, or
|
|
454
|
+
* whose base doesn't support fast mode for `provider`, pass through unchanged.
|
|
455
|
+
*/
|
|
456
|
+
declare function resolveFastModeModel(provider: Provider, model: string): FastModeResolution;
|
|
434
457
|
|
|
435
458
|
/** What the embedded text will be used for. See `EmbedOptions.inputType`. */
|
|
436
459
|
type EmbedInputType = "query" | "document";
|
|
@@ -1031,4 +1054,4 @@ declare function palsuEmbedding(text: string, dimensions?: number): number[];
|
|
|
1031
1054
|
/** Deterministic fake relevance: the share of distinct query words found in the document (0–1). */
|
|
1032
1055
|
declare function palsuRerankScore(query: string, document: string): number;
|
|
1033
1056
|
|
|
1034
|
-
export { type AssistantMessage, type CacheRetention, type ChatErrorReason, type ContentPart, type DoneEvent, type EmbedInputType, type EmbedOptions, type EmbedResult, type EmbedUsage, type ErrorEvent, type ErrorSource, EventStream, type FormattedChatError, type FormattedError, GGAIError, type ImageContent, type Message, type MessageProvenance, type MessageProvenanceKind, type MessageProvenanceSource, type MessageProvenanceVisibility, type OpenRouterProviderPreferences, type PalsuModelConfig, type PalsuModelHandle, type PalsuProviderConfig, type PalsuProviderHandle, type PalsuProviderState, type PalsuResponse, type PalsuResponseFactory, type PreparedContext, type Provider, type ProviderCapability, type ProviderDiagnosticFn, type ProviderEmbedFn, type ProviderEmbedRequest, type ProviderEmbedResponse, type ProviderEntry, ProviderError, type ProviderOptions, type ProviderRerankFn, type ProviderRerankRequest, type ProviderRerankResponse, type ProviderStreamFn, REDACTED as REDACTION_MARKER, type RawContent, type RedactionOptions, type RerankOptions, type RerankResponse, type RerankResult, type RerankUsage, type ServerToolCall, type ServerToolCallEvent, type ServerToolDefinition, type ServerToolResult, type ServerToolResultEvent, type StopReason, type StreamEvent, type StreamOptions, type StreamResponse, StreamResult, type SystemMessage, TOOL_CALL_NAME_RULES, type TextContent, type TextDeltaEvent, type ThinkingContent, type ThinkingDeltaEvent, type ThinkingLevel, type Tool, type ToolCall, type ToolCallDeltaEvent, type ToolCallDoneEvent, type ToolCallNameRule, type ToolChoice, type ToolResult, type ToolResultContent, type ToolResultMessage, type Usage, type UserMessage, type VideoContent, clampProviderContextImages, classifyProviderError, continuesTurn, dropInvalidToolCalls, embed, environmentSecrets, formatChatError, formatError, formatErrorForDisplay, hasLoneSurrogate, isHardBillingMessage, isUsageLimitError, isValidToolCallName, localWireModelId, opensTurn, palsuAssistantMessage, palsuEmbedding, palsuRerankScore, palsuText, palsuThinking, palsuToolCall, prewarmAnthropicCache, providerRegistry, redactText, redactValue, registerPalsuProvider, rerank, resolveToolSchema, sanitizeMessagesForWire, setProviderDiagnostic, sliceHead, sliceTail, stream, toAnthropicMessages, toOpenAIMessages, toWellFormedText, toolCallNameRuleFor, usesResponsesLite };
|
|
1057
|
+
export { type AssistantMessage, type CacheRetention, type ChatErrorReason, type ContentPart, type DoneEvent, type EmbedInputType, type EmbedOptions, type EmbedResult, type EmbedUsage, type ErrorEvent, type ErrorSource, EventStream, FAST_MODE_SUFFIX, type FastModeResolution, type FormattedChatError, type FormattedError, GGAIError, type ImageContent, type Message, type MessageProvenance, type MessageProvenanceKind, type MessageProvenanceSource, type MessageProvenanceVisibility, type OpenRouterProviderPreferences, type PalsuModelConfig, type PalsuModelHandle, type PalsuProviderConfig, type PalsuProviderHandle, type PalsuProviderState, type PalsuResponse, type PalsuResponseFactory, type PreparedContext, type Provider, type ProviderCapability, type ProviderDiagnosticFn, type ProviderEmbedFn, type ProviderEmbedRequest, type ProviderEmbedResponse, type ProviderEntry, ProviderError, type ProviderOptions, type ProviderRerankFn, type ProviderRerankRequest, type ProviderRerankResponse, type ProviderStreamFn, REDACTED as REDACTION_MARKER, type RawContent, type RedactionOptions, type RerankOptions, type RerankResponse, type RerankResult, type RerankUsage, type ServerToolCall, type ServerToolCallEvent, type ServerToolDefinition, type ServerToolResult, type ServerToolResultEvent, type StopReason, type StreamEvent, type StreamOptions, type StreamResponse, StreamResult, type SystemMessage, TOOL_CALL_NAME_RULES, type TextContent, type TextDeltaEvent, type ThinkingContent, type ThinkingDeltaEvent, type ThinkingLevel, type Tool, type ToolCall, type ToolCallDeltaEvent, type ToolCallDoneEvent, type ToolCallNameRule, type ToolChoice, type ToolResult, type ToolResultContent, type ToolResultMessage, type Usage, type UserMessage, type VideoContent, clampProviderContextImages, classifyProviderError, continuesTurn, dropInvalidToolCalls, embed, environmentSecrets, formatChatError, formatError, formatErrorForDisplay, hasLoneSurrogate, isHardBillingMessage, isUsageLimitError, isValidToolCallName, localWireModelId, opensTurn, palsuAssistantMessage, palsuEmbedding, palsuRerankScore, palsuText, palsuThinking, palsuToolCall, prewarmAnthropicCache, providerRegistry, redactText, redactValue, registerPalsuProvider, rerank, resolveFastModeModel, resolveToolSchema, sanitizeMessagesForWire, setProviderDiagnostic, sliceHead, sliceTail, stream, toAnthropicMessages, toOpenAIMessages, toWellFormedText, toolCallNameRuleFor, usesResponsesLite };
|
package/dist/index.js
CHANGED
|
@@ -77,7 +77,8 @@ function isUsageLimitError(err) {
|
|
|
77
77
|
}
|
|
78
78
|
function isHardBillingMessage(message) {
|
|
79
79
|
const lower = message.toLowerCase();
|
|
80
|
-
return lower.includes("insufficient balance") || lower.includes("insufficient credits") || lower.includes("more credits") || lower.includes("insufficient_quota") || lower.includes("exceeded your current quota") || lower.includes("quota exceeded") || lower.includes("no resource package") || lower.includes("recharge") || lower.includes("balance is too low") || lower.includes("out of credits") ||
|
|
80
|
+
return lower.includes("insufficient balance") || lower.includes("insufficient credits") || lower.includes("more credits") || lower.includes("insufficient_quota") || lower.includes("exceeded your current quota") || lower.includes("quota exceeded") || lower.includes("no resource package") || lower.includes("recharge") || lower.includes("balance is too low") || lower.includes("out of credits") || // Anthropic fast mode on a subscription without usage credits turned on.
|
|
81
|
+
lower.includes("usage credits are required") || lower.includes("arrears") || lower.includes("arrearage") || lower.includes("token quota") || lower.includes("exceeded_current_quota_error") || lower.includes("check your account balance") || lower.includes("does not yet include access") || lower.includes("subscription plan") || lower.includes("billing");
|
|
81
82
|
}
|
|
82
83
|
function formatResetTime(resetsAt) {
|
|
83
84
|
const when = new Date(resetsAt * 1e3);
|
|
@@ -1574,6 +1575,7 @@ function fineGrainedToolStreamingEnabled() {
|
|
|
1574
1575
|
return v === "1" || v === "true" || v === "yes" || v === "on";
|
|
1575
1576
|
}
|
|
1576
1577
|
var SERVER_FALLBACK_BETA = "server-side-fallback-2026-07-01";
|
|
1578
|
+
var FAST_MODE_BETA = "fast-mode-2026-02-01";
|
|
1577
1579
|
var anthropicServerFallback = {
|
|
1578
1580
|
disabled: /* @__PURE__ */ new Set(),
|
|
1579
1581
|
reset() {
|
|
@@ -1716,6 +1718,7 @@ async function* runStream(options) {
|
|
|
1716
1718
|
const { system: rawSystem, messages } = toAnthropicMessages(downgradedMessages, cacheControl, {
|
|
1717
1719
|
fallbackBlocks: useServerFallback
|
|
1718
1720
|
});
|
|
1721
|
+
const useFastMode = options.speed === "fast" && options.provider === "anthropic" && isDirectAnthropicApi(options.baseUrl);
|
|
1719
1722
|
const system = isOAuth ? [
|
|
1720
1723
|
{
|
|
1721
1724
|
type: "text",
|
|
@@ -1786,6 +1789,7 @@ async function* runStream(options) {
|
|
|
1786
1789
|
return contextEdits.length ? { context_management: { edits: contextEdits } } : {};
|
|
1787
1790
|
})(),
|
|
1788
1791
|
...useServerFallback ? { fallbacks: "default" } : {},
|
|
1792
|
+
...useFastMode ? { speed: "fast" } : {},
|
|
1789
1793
|
stream: useStreaming
|
|
1790
1794
|
};
|
|
1791
1795
|
const params = mergeProviderOptions(baseParams, options.providerOptions);
|
|
@@ -1804,7 +1808,8 @@ async function* runStream(options) {
|
|
|
1804
1808
|
// so a pre-warmed cache expires before the user's first turn. cacheControl.ttl
|
|
1805
1809
|
// is only "1h" on the first-party endpoint (see toAnthropicCacheControl).
|
|
1806
1810
|
...cacheControl?.ttl === "1h" ? ["extended-cache-ttl-2025-04-11"] : [],
|
|
1807
|
-
...useServerFallback ? [SERVER_FALLBACK_BETA] : []
|
|
1811
|
+
...useServerFallback ? [SERVER_FALLBACK_BETA] : [],
|
|
1812
|
+
...useFastMode ? [FAST_MODE_BETA] : []
|
|
1808
1813
|
];
|
|
1809
1814
|
const toRequestOptions = (betas) => ({
|
|
1810
1815
|
signal: options.signal ?? void 0,
|
|
@@ -2189,6 +2194,9 @@ function messageToResponse(message) {
|
|
|
2189
2194
|
}
|
|
2190
2195
|
};
|
|
2191
2196
|
}
|
|
2197
|
+
function isFastModeCreditsMessage(message) {
|
|
2198
|
+
return /usage credits are required for fast mode/i.test(message);
|
|
2199
|
+
}
|
|
2192
2200
|
function readUnifiedRateLimit(headers) {
|
|
2193
2201
|
const status = readHeader(headers, "anthropic-ratelimit-unified-status");
|
|
2194
2202
|
const resetRaw = readHeader(
|
|
@@ -2212,6 +2220,14 @@ function toError(err) {
|
|
|
2212
2220
|
const fallbackMessage = isRawJsonErrorEcho(err.message) ? emptyProviderErrorMessage(err.status) : err.message;
|
|
2213
2221
|
const messageCandidate = bodyMessage ?? err.message;
|
|
2214
2222
|
const message = isRawHtmlErrorEcho(messageCandidate) ? providerHtmlErrorMessage(err.status) : bodyType && bodyMessage ? `${bodyType}: ${bodyMessage}` : bodyMessage ?? fallbackMessage;
|
|
2223
|
+
if (isFastModeCreditsMessage(message)) {
|
|
2224
|
+
return new ProviderError("anthropic", message, {
|
|
2225
|
+
statusCode: err.status,
|
|
2226
|
+
...requestId ? { requestId } : {},
|
|
2227
|
+
hint: "Fast mode bills Claude usage credits, not your plan. Turn them on at claude.ai/settings/usage, or switch to Claude Opus 5.5 (standard speed) in the model selector.",
|
|
2228
|
+
cause: err
|
|
2229
|
+
});
|
|
2230
|
+
}
|
|
2215
2231
|
if (err.status === 429) {
|
|
2216
2232
|
const limit = readUnifiedRateLimit(err.headers);
|
|
2217
2233
|
const farOff = limit.resetsAt != null && limit.resetsAt * 1e3 - Date.now() > 6e4;
|
|
@@ -2467,8 +2483,9 @@ async function* runStream2(options) {
|
|
|
2467
2483
|
if (options.provider === "sakana" && options.model === "fugu-ultra" && (options.thinking === "max" || options.thinking === "ultra")) {
|
|
2468
2484
|
params.reasoning_effort = "max";
|
|
2469
2485
|
}
|
|
2470
|
-
|
|
2471
|
-
|
|
2486
|
+
const serviceTier = options.serviceTier ?? (options.speed === "fast" ? "priority" : void 0);
|
|
2487
|
+
if (options.provider === "openai" && serviceTier) {
|
|
2488
|
+
params.service_tier = serviceTier;
|
|
2472
2489
|
}
|
|
2473
2490
|
if (isKimiK3) {
|
|
2474
2491
|
const paramsAny = params;
|
|
@@ -2978,6 +2995,9 @@ async function* runStream3(options, retriedWithoutReasoning = false) {
|
|
|
2978
2995
|
if (options.temperature != null && !options.thinking) {
|
|
2979
2996
|
body.temperature = options.temperature;
|
|
2980
2997
|
}
|
|
2998
|
+
if (options.speed === "fast") {
|
|
2999
|
+
body.service_tier = "priority";
|
|
3000
|
+
}
|
|
2981
3001
|
body.reasoning = {
|
|
2982
3002
|
// GPT-5.6/6 require at least low; older models still support thinking off.
|
|
2983
3003
|
// Apply the floor here for every caller, including one-off prompt rewrites.
|
|
@@ -4713,6 +4733,18 @@ function observePreparedContext(before, after, tools) {
|
|
|
4713
4733
|
};
|
|
4714
4734
|
}
|
|
4715
4735
|
|
|
4736
|
+
// src/fast-mode.ts
|
|
4737
|
+
var FAST_MODE_SUFFIX = "-fast";
|
|
4738
|
+
var FAST_MODE_BASE_MODELS = {
|
|
4739
|
+
anthropic: ["claude-opus-5-5"],
|
|
4740
|
+
openai: ["gpt-6-astra", "gpt-6.1-sol", "gpt-6-luna"]
|
|
4741
|
+
};
|
|
4742
|
+
function resolveFastModeModel(provider, model) {
|
|
4743
|
+
if (!model.endsWith(FAST_MODE_SUFFIX)) return { model, fast: false };
|
|
4744
|
+
const base = model.slice(0, -FAST_MODE_SUFFIX.length);
|
|
4745
|
+
return FAST_MODE_BASE_MODELS[provider]?.includes(base) ? { model: base, fast: true } : { model, fast: false };
|
|
4746
|
+
}
|
|
4747
|
+
|
|
4716
4748
|
// src/stream.ts
|
|
4717
4749
|
var OPENAI_EMBED_BATCH_SIZE = 2048;
|
|
4718
4750
|
var OPENROUTER_EMBED_BATCH_SIZE = 64;
|
|
@@ -4887,7 +4919,9 @@ function requireLocalBaseUrl(baseUrl) {
|
|
|
4887
4919
|
}
|
|
4888
4920
|
return baseUrl;
|
|
4889
4921
|
}
|
|
4890
|
-
function stream(
|
|
4922
|
+
function stream(requested) {
|
|
4923
|
+
const fastMode = resolveFastModeModel(requested.provider, requested.model);
|
|
4924
|
+
const options = fastMode.fast ? { ...requested, model: fastMode.model, speed: "fast" } : requested;
|
|
4891
4925
|
const entry = providerRegistry.get(options.provider);
|
|
4892
4926
|
if (!entry) {
|
|
4893
4927
|
throw new GGAIError(
|
|
@@ -5518,6 +5552,7 @@ function palsuRerankScore(query, document) {
|
|
|
5518
5552
|
}
|
|
5519
5553
|
export {
|
|
5520
5554
|
EventStream,
|
|
5555
|
+
FAST_MODE_SUFFIX,
|
|
5521
5556
|
GGAIError,
|
|
5522
5557
|
ProviderError,
|
|
5523
5558
|
REDACTED as REDACTION_MARKER,
|
|
@@ -5550,6 +5585,7 @@ export {
|
|
|
5550
5585
|
redactValue,
|
|
5551
5586
|
registerPalsuProvider,
|
|
5552
5587
|
rerank,
|
|
5588
|
+
resolveFastModeModel,
|
|
5553
5589
|
resolveToolSchema,
|
|
5554
5590
|
sanitizeMessagesForWire,
|
|
5555
5591
|
setProviderDiagnostic,
|