ソースを参照

fix(core): loading models.dev in dev

Adam 1 ヶ月 前
コミット
d71153eae6
1 ファイル変更5 行追加1 行削除
  1. 5 1
      packages/opencode/src/provider/models.ts

+ 5 - 1
packages/opencode/src/provider/models.ts

@@ -81,7 +81,11 @@ export namespace ModelsDev {
     const file = Bun.file(filepath)
     const file = Bun.file(filepath)
     const result = await file.json().catch(() => {})
     const result = await file.json().catch(() => {})
     if (result) return result as Record<string, Provider>
     if (result) return result as Record<string, Provider>
-    const json = await data()
+    if (typeof data === "function") {
+      const json = await data()
+      return JSON.parse(json) as Record<string, Provider>
+    }
+    const json = await fetch("https://models.dev/api.json").then((x) => x.text())
     return JSON.parse(json) as Record<string, Provider>
     return JSON.parse(json) as Record<string, Provider>
   }
   }