Unverified 提交 4926a01a authored 作者: Will Chen's avatar Will Chen 提交者: GitHub

always use engine (#1525)

<!-- CURSOR_SUMMARY --> > [!NOTE] > Always route Dyad Pro through the Dyad engine (no gateway), simplify logging/flags, and remove DYAD_GATEWAY usage and staging gateway script. > > - **Engine/Model client (`src/ipc/utils/get_model_client.ts`)**: > - Always use `createDyadEngine` when Dyad Pro is enabled; remove gateway fallback and `DYAD_GATEWAY_URL` usage. > - Simplify logs to engine-only; drop conditional gateway/engine logging. > - Always set `isEngineEnabled: true`; pass `{ files }` to the provider unconditionally; strip `:free` from model names. > - **Scripts (`package.json`)**: > - Remove `staging:gateway` script. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 5fdbbb703c47de4623ceeb82e6678ace34dc268e. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
上级 348521ce
import { testSkipIfWindows } from "./helpers/test_helper";
testSkipIfWindows("claude 4 sonnet", async ({ po }) => {
await po.setUpDyadPro();
// Disable the pro modes so it routes to gateway.
const proModesDialog = await po.openProModesDialog({
location: "home-chat-input-container",
});
await proModesDialog.toggleTurboEdits();
await proModesDialog.setSmartContextMode("off");
await proModesDialog.close();
await po.selectModel({ provider: "Anthropic", model: "Claude 4 Sonnet" });
await po.sendPrompt("[dump] tc=gateway-simple");
await po.snapshotServerDump("request");
await po.snapshotMessages({ replaceDumpPath: true });
});
......@@ -16,7 +16,6 @@
"start": "electron-forge start",
"dev:engine": "cross-env DYAD_ENGINE_URL=http://localhost:8080/v1 npm start",
"staging:engine": "cross-env DYAD_ENGINE_URL=https://staging---dyad-llm-engine-kq7pivehnq-uc.a.run.app/v1 npm start",
"staging:gateway": "cross-env DYAD_GATEWAY_URL=https://staging---litellm-gcp-cloud-run-kq7pivehnq-uc.a.run.app/v1 npm start",
"package": "npm run clean && electron-forge package",
"make": "npm run clean && electron-forge make",
"publish": "npm run clean && electron-forge publish",
......
......@@ -27,7 +27,6 @@ import { getOllamaApiUrl } from "../handlers/local_model_ollama_handler";
import { createFallback } from "./fallback_ai_model";
const dyadEngineUrl = process.env.DYAD_ENGINE_URL;
const dyadGatewayUrl = process.env.DYAD_GATEWAY_URL;
const AUTO_MODELS = [
{
......@@ -85,12 +84,7 @@ export async function getModelClient(
// IMPORTANT: some providers like OpenAI have an empty string gateway prefix,
// so we do a nullish and not a truthy check here.
if (providerConfig.gatewayPrefix != null || dyadEngineUrl) {
const isEngineEnabled =
settings.enableProSmartFilesContextMode ||
settings.enableProLazyEditsMode ||
settings.enableProWebSearch;
const provider = isEngineEnabled
? createDyadEngine({
const provider = createDyadEngine({
apiKey: dyadApiKey,
baseURL: dyadEngineUrl ?? "https://engine.dyad.sh/v1",
originalProviderId: model.provider,
......@@ -105,42 +99,28 @@ export async function getModelClient(
enableWebSearch: settings.enableProWebSearch,
},
settings,
})
: createOpenAICompatible({
name: "dyad-gateway",
apiKey: dyadApiKey,
baseURL: dyadGatewayUrl ?? "https://llm-gateway.dyad.sh/v1",
});
logger.info(
`\x1b[1;97;44m Using Dyad Pro API key for model: ${model.name}. engine_enabled=${isEngineEnabled} \x1b[0m`,
`\x1b[1;97;44m Using Dyad Pro API key for model: ${model.name} \x1b[0m`,
);
if (isEngineEnabled) {
logger.info(
`\x1b[1;30;42m Using Dyad Pro engine: ${dyadEngineUrl ?? "<prod>"} \x1b[0m`,
);
} else {
logger.info(
`\x1b[1;30;43m Using Dyad Pro gateway: ${dyadGatewayUrl ?? "<prod>"} \x1b[0m`,
);
}
// Do not use free variant (for openrouter).
const modelName = model.name.split(":free")[0];
const autoModelClient = {
model: provider(
`${providerConfig.gatewayPrefix || ""}${modelName}`,
isEngineEnabled
? {
model: provider(`${providerConfig.gatewayPrefix || ""}${modelName}`, {
files,
}
: undefined,
),
}),
builtinProviderId: model.provider,
};
return {
modelClient: autoModelClient,
isEngineEnabled,
isEngineEnabled: true,
};
} else {
logger.warn(
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论