diff --git a/src/agent/index.ts b/src/agent/index.ts index e63c31bd..cf46e040 100644 --- a/src/agent/index.ts +++ b/src/agent/index.ts @@ -5,7 +5,7 @@ import { ChatAnthropic } from "@langchain/anthropic"; import { SqliteSaver } from "@langchain/langgraph-checkpoint-sqlite"; import { ChatOpenAI } from "@langchain/openai"; import { ChatOpenRouter } from "@langchain/openrouter"; -import { ChatGoogle } from "@langchain/google"; +import { ChatGoogle } from "@langchain/google/node"; import { createDeepAgent, LocalShellBackend } from "deepagents"; import { loadOpenWikiEnv, openWikiEnvDir } from "../env.js"; import { createSystemPrompt, createUserPrompt } from "./prompt.js"; @@ -23,6 +23,7 @@ import { getProviderApiKeyEnvKey, getProviderConfig, getProviderLabel, + GOOGLE_CLOUD_PROJECT_ENV_KEY, isValidModelId, normalizeModelId, OPENAI_API_KEY_ENV_KEY, @@ -388,10 +389,13 @@ async function createModel(provider: OpenWikiProvider, modelId: string) { } if (provider === "gemini-enterprise") { + const projectId = process.env[GOOGLE_CLOUD_PROJECT_ENV_KEY]; + return new ChatGoogle({ model: modelId, platformType: "gcp", location: process.env.GOOGLE_CLOUD_LOCATION ?? "us-central1", + ...(projectId ? { googleAuthOptions: { projectId } } : {}), }); } diff --git a/src/credentials.tsx b/src/credentials.tsx index 92e825f2..5184f04d 100644 --- a/src/credentials.tsx +++ b/src/credentials.tsx @@ -298,38 +298,6 @@ export function InitSetup({ setIsSaving(true); try { - // Active credential validation - if (nextProvider === "gemini" || nextProvider === "gemini-enterprise") { - const testModelId = nextModelId ?? getDefaultModelId(nextProvider); - const resolvedValue = - nextApiKey ?? process.env[getProviderApiKeyEnvKey(nextProvider)]; - - let testModel; - if (nextProvider === "gemini") { - const { ChatGoogle } = await import("@langchain/google"); - testModel = new ChatGoogle({ - apiKey: resolvedValue, - model: testModelId, - platformType: "gai", - }); - } else { - const { ChatGoogle } = await import("@langchain/google"); - if (resolvedValue) { - process.env.GOOGLE_CLOUD_PROJECT = resolvedValue; - } - testModel = new ChatGoogle({ - model: testModelId, - platformType: "gcp", - location: process.env.GOOGLE_CLOUD_LOCATION ?? "us-central1", - }); - } - - // Execute a lightweight validation call - await testModel.invoke([{ role: "user", content: "ping" }], { - timeout: 5000, - }); - } - const updates: Record = {}; const providerEnvChanged = process.env[OPENWIKI_PROVIDER_ENV_KEY] !== nextProvider;