Просмотр исходного кода

refactor: remove all hardcoded model names and API URLs from templates

Ma 7 месяцев назад
Родитель
Сommit
cb5adfbab8

+ 2 - 2
packages/cli/src/__tests__/cli-integration.test.ts

@@ -76,8 +76,8 @@ describe("CLI integration", () => {
       const raw = await readFile(join(projectDir, "inkos.json"), "utf-8");
       const config = JSON.parse(raw);
       expect(config.llm).toBeDefined();
-      expect(config.llm.provider).toBe("openai");
-      expect(config.llm.model).toBe("gpt-4o");
+      expect(config.llm.provider).toBeDefined();
+      expect(config.llm.model).toBeDefined();
       expect(config.daemon).toBeDefined();
       expect(config.notify).toEqual([]);
     });

+ 1 - 1
packages/cli/src/commands/config.ts

@@ -165,7 +165,7 @@ configCommand
   .command("set-model")
   .description("Set model override for a specific agent (with optional provider routing)")
   .argument("<agent>", `Agent name (${KNOWN_AGENTS.join(", ")})`)
-  .argument("<model>", "Model name (e.g., gpt-4o, gemini-2.5-flash)")
+  .argument("<model>", "Model name")
   .option("--base-url <url>", "API base URL (for different provider)")
   .option("--provider <provider>", "Provider type (openai / anthropic / custom)")
   .option("--api-key-env <envVar>", "Env variable name for API key (e.g., PACKYAPI_KEY)")

+ 12 - 11
packages/cli/src/commands/init.ts

@@ -42,8 +42,8 @@ export const initCommand = new Command("init")
         language: opts.lang ?? "zh",
         llm: {
           provider: process.env.INKOS_LLM_PROVIDER ?? "openai",
-          baseUrl: process.env.INKOS_LLM_BASE_URL ?? "https://api.openai.com/v1",
-          model: process.env.INKOS_LLM_MODEL ?? "gpt-4o",
+          baseUrl: process.env.INKOS_LLM_BASE_URL ?? "",
+          model: process.env.INKOS_LLM_MODEL ?? "",
         },
         notify: [],
         daemon: {
@@ -71,9 +71,9 @@ export const initCommand = new Command("init")
             "# Global config at ~/.inkos/.env will be used by default.",
             "# Uncomment below to override for this project only:",
             "# INKOS_LLM_PROVIDER=openai",
-            "# INKOS_LLM_BASE_URL=https://api.openai.com/v1",
-            "# INKOS_LLM_API_KEY=your-api-key-here",
-            "# INKOS_LLM_MODEL=gpt-4o",
+            "# INKOS_LLM_BASE_URL=",
+            "# INKOS_LLM_API_KEY=",
+            "# INKOS_LLM_MODEL=",
             "",
             "# Web search (optional):",
             "# TAVILY_API_KEY=tvly-xxxxx",
@@ -88,9 +88,9 @@ export const initCommand = new Command("init")
             "# Tip: Run 'inkos config set-global' to set once for all projects.",
             "# Provider: openai (OpenAI / compatible proxy), anthropic (Anthropic native)",
             "INKOS_LLM_PROVIDER=openai",
-            "INKOS_LLM_BASE_URL=https://api.openai.com/v1",
-            "INKOS_LLM_API_KEY=your-api-key-here",
-            "INKOS_LLM_MODEL=gpt-4o",
+            "INKOS_LLM_BASE_URL=",
+            "INKOS_LLM_API_KEY=",
+            "INKOS_LLM_MODEL=",
             "",
             "# Optional parameters (defaults shown):",
             "# INKOS_LLM_TEMPERATURE=0.7",
@@ -103,8 +103,9 @@ export const initCommand = new Command("init")
             "",
             "# Anthropic example:",
             "# INKOS_LLM_PROVIDER=anthropic",
-            "# INKOS_LLM_BASE_URL=https://api.anthropic.com",
-            "# INKOS_LLM_MODEL=claude-sonnet-4-5-20250514",
+            "# INKOS_LLM_PROVIDER=anthropic",
+            "# INKOS_LLM_BASE_URL=",
+            "# INKOS_LLM_MODEL=",
           ].join("\n"),
           "utf-8",
         );
@@ -128,7 +129,7 @@ export const initCommand = new Command("init")
         log("Next steps:");
         if (name) log(`  cd ${name}`);
         log("  # Option 1: Set global config (recommended, one-time):");
-        log("  inkos config set-global --provider openai --base-url https://api.openai.com/v1 --api-key sk-xxx --model gpt-4o");
+        log("  inkos config set-global --provider openai --base-url <your-api-url> --api-key <your-key> --model <your-model>");
         log("  # Option 2: Edit .env for this project only");
         log("");
         log("  inkos book create --title '我的小说' --genre xuanhuan --platform tomato");