-
Notifications
You must be signed in to change notification settings - Fork 0
fix(api): pin Wiki Compose LLM to google:gemini-3.5-flash #990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /** | ||
| * Tests for fixed Wiki Compose model id resolution. | ||
| * 固定 Wiki Compose モデル id 解決のテスト。 | ||
| */ | ||
| import { describe, expect, it, vi, beforeEach } from "vitest"; | ||
| import { | ||
| resolveWikiComposeModelId, | ||
| WIKI_COMPOSE_MODEL_ID, | ||
| } from "../../../../agents/core/llm/wikiComposeModelId.js"; | ||
|
|
||
| const mockDb = { | ||
| select: vi.fn(), | ||
| }; | ||
|
|
||
| function chainLimit(rows: unknown[]) { | ||
| const chain = { | ||
| from: vi.fn().mockReturnThis(), | ||
| where: vi.fn().mockReturnThis(), | ||
| limit: vi.fn().mockResolvedValue(rows), | ||
| }; | ||
| return chain; | ||
| } | ||
|
|
||
| beforeEach(() => { | ||
| vi.clearAllMocks(); | ||
| }); | ||
|
|
||
| describe("resolveWikiComposeModelId", () => { | ||
| it("returns the fixed id when the row is active and tier-accessible", async () => { | ||
| mockDb.select.mockReturnValueOnce(chainLimit([{ id: WIKI_COMPOSE_MODEL_ID }])); | ||
| const id = await resolveWikiComposeModelId("orchestrator", "free", mockDb as never); | ||
| expect(id).toBe(WIKI_COMPOSE_MODEL_ID); | ||
| }); | ||
|
|
||
| it("returns the fixed id even when no DB row matches", async () => { | ||
| mockDb.select.mockReturnValueOnce(chainLimit([])); | ||
| const id = await resolveWikiComposeModelId("draft", "pro", mockDb as never); | ||
| expect(id).toBe("google:gemini-3.5-flash"); | ||
| }); | ||
|
|
||
| it("uses the same id for orchestrator and draft roles", async () => { | ||
| mockDb.select.mockReturnValue(chainLimit([{ id: WIKI_COMPOSE_MODEL_ID }])); | ||
| const orchestrator = await resolveWikiComposeModelId("orchestrator", "free", mockDb as never); | ||
| const draft = await resolveWikiComposeModelId("draft", "free", mockDb as never); | ||
| expect(orchestrator).toBe(draft); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /** | ||
| * Fixed Wiki Compose model id (temporary until per-role / per-backend selection returns). | ||
| * Wiki Compose 用の固定モデル id(将来ロール別選択に戻すまでの暫定)。 | ||
| */ | ||
| import { and, eq } from "drizzle-orm"; | ||
| import { aiModels } from "../../../schema/index.js"; | ||
| import type { Database, UserTier } from "../../../types/index.js"; | ||
| import { WIKI_COMPOSE_GRAPH_ID } from "../../graphs/wikiCompose/index.js"; | ||
| import { RESEARCH_GRAPH_ID } from "../../subgraphs/research/index.js"; | ||
| import type { ComposeModelRole } from "./resolveComposeModelId.js"; | ||
|
|
||
| /** | ||
| * `ai_models.id` used by every Wiki Compose LLM node and the `web_search` tool. | ||
| * すべての Wiki Compose LLM ノードと `web_search` ツールが使う `ai_models.id`。 | ||
| */ | ||
| export const WIKI_COMPOSE_MODEL_ID = "google:gemini-3.5-flash" as const; | ||
|
|
||
| /** Graph ids that pin LLM calls to {@link WIKI_COMPOSE_MODEL_ID}. */ | ||
| export function isFixedWikiComposeModelGraph(graphId: string): boolean { | ||
| return graphId === WIKI_COMPOSE_GRAPH_ID || graphId === RESEARCH_GRAPH_ID; | ||
| } | ||
|
Comment on lines
+18
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add Japanese text to this exported JSDoc block for guideline compliance. Line 18 currently has English-only documentation while this file otherwise follows bilingual EN/JA comments. Proposed fix-/** Graph ids that pin LLM calls to {`@link` WIKI_COMPOSE_MODEL_ID}. */
+/**
+ * Graph ids that pin LLM calls to {`@link` WIKI_COMPOSE_MODEL_ID}.
+ * LLM 呼び出しを {`@link` WIKI_COMPOSE_MODEL_ID} に固定する graph id。
+ */
export function isFixedWikiComposeModelGraph(graphId: string): boolean {
return graphId === WIKI_COMPOSE_GRAPH_ID || graphId === RESEARCH_GRAPH_ID;
}As per coding guidelines "Include both Japanese and English comments/documentation in code and documentation files to maintain project tone consistency". 🤖 Prompt for AI Agents |
||
|
|
||
| function tierFilter(tier: UserTier) { | ||
| if (tier === "pro") return undefined; | ||
| return eq(aiModels.tierRequired, "free"); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the fixed model row id when active and tier-accessible; otherwise `null`. | ||
| * `null` のとき呼び出し側はフォールバック(web_search の cheapest 探索など)へ進める。 | ||
| */ | ||
| export async function resolveActiveWikiComposeModelId( | ||
| db: Database, | ||
| tier: UserTier, | ||
| ): Promise<string | null> { | ||
| const tierClause = tierFilter(tier); | ||
| const [row] = await db | ||
| .select({ id: aiModels.id }) | ||
| .from(aiModels) | ||
| .where( | ||
| and( | ||
| eq(aiModels.id, WIKI_COMPOSE_MODEL_ID), | ||
| eq(aiModels.isActive, true), | ||
| ...(tierClause ? [tierClause] : []), | ||
| ), | ||
| ) | ||
| .limit(1); | ||
| return row?.id ?? null; | ||
| } | ||
|
|
||
| /** | ||
| * Resolve the model row id for Wiki Compose orchestrator / draft / research nodes. | ||
| * `role` is accepted for API stability; all roles map to {@link WIKI_COMPOSE_MODEL_ID} for now. | ||
| * | ||
| * Wiki Compose の model id 解決。現時点では role に関わらず gemini-3.5-flash 固定。 | ||
| */ | ||
| export async function resolveWikiComposeModelId( | ||
| _role: ComposeModelRole, | ||
| _tier: UserTier, | ||
| db: Database, | ||
| ): Promise<string> { | ||
| return (await resolveActiveWikiComposeModelId(db, _tier)) ?? WIKI_COMPOSE_MODEL_ID; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.