Open source CapCut alternative.
TypeScript
Route Gemini decisions to Flash-Lite
David Le6423542f9a83
diff --git a/docs/guides/backend-apis.md b/docs/guides/backend-apis.mdindex f0bfaa19..8de65e40 100644--- a/docs/guides/backend-apis.md+++ b/docs/guides/backend-apis.md@@ -57,14 +57,15 @@ provider names are configuration/data inside private adapters only.OpenAI through `donkey_openai_mac_desktop_interaction`, which the hostedResponses adapter maps to OpenAI's `computer` tool.- The Gemini adapter uses the official `@google/genai` Node/TypeScript SDK for- general non-streaming chat, normal structured Responses calls, and browser+ general non-streaming chat, structured Responses calls, and browsercomputer-use calls. It uses Vertex AI's global endpoint only when`GOOGLE_APPLICATION_CREDENTIALS_JSON` includes a `project_id`. If the project- is missing, the provider is unavailable. The adapter's defaults should track- Google's newest supported Gemini models: use the latest stable Flash model for- normal chat and Responses calls, and the latest Google-listed Computer- Use-capable model for browser Computer Use tool calls. Keep model selection in- code rather than environment overrides. For Google Cloud credits, set+ is missing, the provider is unavailable. The adapter's defaults should route+ fast structured task-intent and follow-up decisions to `gemini-3.1-flash-lite`,+ keep `gemini-3.5-flash` available for general chat and non-decision Responses+ calls, and use `gemini-3-flash-preview` for browser Computer Use tool calls.+ Keep model selection in code rather than environment overrides. For Google+ Cloud credits, set`GOOGLE_APPLICATION_CREDENTIALS_JSON` as a hosted-deploy sensitive env varrather than storing Google provider credentials in the Mac app.- The OpenAI hosted Responses adapter uses `OPENAI_API_KEY` only for macOSdiff --git a/site/src/lib/inference/adapters/gemini-computer-use.ts b/site/src/lib/inference/adapters/gemini-computer-use.tsindex 28faa93d..a6abb607 100644--- a/site/src/lib/inference/adapters/gemini-computer-use.ts+++ b/site/src/lib/inference/adapters/gemini-computer-use.ts@@ -37,6 +37,7 @@ type GeminiClientFactory = (options: GoogleGenAIOptions) => GeminiClient;const providerID = "gemini-computer-use";const geminiProviderID = "gemini";+const defaultDecisionResponsesModel = "gemini-3.1-flash-lite";const defaultVertexResponsesModel = "gemini-3.5-flash";const defaultComputerUseModel = "gemini-3-flash-preview";const vertexLocation = "global";@@ -44,6 +45,16 @@ const vertexAIScope = "https://www.googleapis.com/auth/cloud-platform";export const geminiBrowserInteractionToolType = "donkey_gemini_browser_interaction";+const fastDecisionSchemaNames = new Set([+ "task_intent_v1",+ "task_followup_resolution_v1",+]);++const fastDecisionPromptVersions = new Set([+ "task-intent-v1",+ "task-followup-resolution-v1",+]);+const browserOnlyFunctionExclusions = ["drag_and_drop",];@@ -62,6 +73,7 @@ export function createGeminiComputerUseProvider(}return [+ staticModel(defaultDecisionResponsesModel, false),staticModel(defaultVertexResponsesModel, false),staticModel(defaultComputerUseModel, true),];@@ -87,9 +99,7 @@ export function createGeminiComputerUseProvider(const model = requestedModel(request.body,- registeredTools.length > 0- ? defaultComputerUseModel- : defaultVertexResponsesModel,+ defaultResponseModel(request.body, registeredTools),);const requestParameters = geminiGenerateContentParameters(request.body,@@ -425,6 +435,37 @@ function responseFormatFromBody(body: JsonObject): { json: boolean; schema?: Jsoreturn null;}+function defaultResponseModel(body: JsonObject, registeredTools: string[]) {+ if (registeredTools.length > 0) {+ return defaultComputerUseModel;+ }++ if (isFastDecisionRequest(body)) {+ return defaultDecisionResponsesModel;+ }++ return defaultVertexResponsesModel;+}++function isFastDecisionRequest(body: JsonObject) {+ const metadata = isJsonObject(body.metadata) ? body.metadata : {};+ const promptVersion =+ stringValue(metadata.prompt_version) ??+ stringValue(metadata.promptVersion);+ if (promptVersion && fastDecisionPromptVersions.has(promptVersion)) {+ return true;+ }++ const format =+ isJsonObject(body.text) && isJsonObject(body.text.format)+ ? body.text.format+ : isJsonObject(body.response_format)+ ? body.response_format+ : null;+ const schemaName = format ? stringValue(format.name) : undefined;+ return Boolean(schemaName && fastDecisionSchemaNames.has(schemaName));+}+function systemInstructionFromBody(body: JsonObject): string | undefined {const instruction = [stringValue(body.instructions),@@ -721,7 +762,7 @@ function staticModel(model: string, computerUse: boolean): InferenceModel {provider: geminiProviderID,inputModalities: ["text", "image"],outputModalities: ["text"],- contextLength: 128_000,+ contextLength: 1_048_576,pricing: null,metadata: {provider: geminiProviderID,