mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-05 14:52:09 +03:00
* fix(cloud-code): scope thinking stripping to executors * fix(cloud-code): guard antigravity normalized body
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import { supportsReasoning } from "./modelCapabilities.ts";
|
|
|
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
}
|
|
|
|
function stripGeminiThinkingConfig(value: unknown): unknown {
|
|
if (!isRecord(value)) return value;
|
|
if (!("thinkingConfig" in value) && !("thinking_config" in value)) return value;
|
|
|
|
const next = { ...value };
|
|
delete next.thinkingConfig;
|
|
delete next.thinking_config;
|
|
return next;
|
|
}
|
|
|
|
export function shouldStripCloudCodeThinking(provider: string, model: string): boolean {
|
|
if (!provider || !model) return false;
|
|
return !supportsReasoning(`${provider}/${model}`);
|
|
}
|
|
|
|
export function stripCloudCodeThinkingConfig(
|
|
body: Record<string, unknown>
|
|
): Record<string, unknown> {
|
|
const next = { ...body };
|
|
|
|
delete next.reasoning_effort;
|
|
delete next.reasoning;
|
|
delete next.thinking;
|
|
|
|
if ("generationConfig" in next) {
|
|
next.generationConfig = stripGeminiThinkingConfig(next.generationConfig);
|
|
}
|
|
|
|
if (isRecord(next.request)) {
|
|
const request = { ...next.request };
|
|
if ("generationConfig" in request) {
|
|
request.generationConfig = stripGeminiThinkingConfig(request.generationConfig);
|
|
}
|
|
next.request = request;
|
|
}
|
|
|
|
return next;
|
|
}
|