Browse Source

feat(config): make small model configurable (#1030)

Timo Clasen 7 months ago
parent
commit
18abcab208

+ 6 - 0
packages/opencode/src/config/config.ts

@@ -149,6 +149,12 @@ export namespace Config {
       autoupdate: z.boolean().optional().describe("Automatically update to the latest version"),
       disabled_providers: z.array(z.string()).optional().describe("Disable providers that are loaded automatically"),
       model: z.string().describe("Model to use in the format of provider/model, eg anthropic/claude-2").optional(),
+      small_model: z
+        .string()
+        .describe(
+          "Small model to use for tasks like summarization and title generation in the format of provider/model",
+        )
+        .optional(),
       username: z
         .string()
         .optional()

+ 7 - 0
packages/opencode/src/provider/provider.ts

@@ -416,6 +416,13 @@ export namespace Provider {
   }
 
   export async function getSmallModel(providerID: string) {
+    const cfg = await Config.get()
+
+    if (cfg.small_model) {
+      const parsed = parseModel(cfg.small_model)
+      return getModel(parsed.providerID, parsed.modelID)
+    }
+
     const provider = await state().then((state) => state.providers[providerID])
     if (!provider) return
     const priority = ["3-5-haiku", "3.5-haiku", "gemini-2.5-flash"]