Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@tailwindcss/vite": "4.1.11",
"diff": "8.0.2",
"dompurify": "3.3.1",
"@types/dompurify": "3.2.0",
"ai": "5.0.119",
"hono": "4.10.7",
"hono-openapi": "1.1.2",
Expand Down
3 changes: 2 additions & 1 deletion packages/app/src/custom-elements.d.ts
3 changes: 2 additions & 1 deletion packages/enterprise/src/custom-elements.d.ts
11 changes: 0 additions & 11 deletions packages/opencode/src/provider/models-macro.ts

This file was deleted.

23 changes: 20 additions & 3 deletions packages/opencode/src/provider/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,32 @@ import { Global } from "../global"
import { Log } from "../util/log"
import path from "path"
import z from "zod"
import { data } from "./models-macro" with { type: "macro" }
import { Installation } from "../installation"
import { Flag } from "../flag/flag"

export namespace ModelsDev {
const log = Log.create({ service: "models.dev" })
const filepath = path.join(Global.Path.cache, "models.json")

async function fetchModelsData() {
const envPath = Bun.env.MODELS_DEV_API_JSON
if (envPath) {
const file = Bun.file(envPath)
if (await file.exists()) {
return await file.json()
}
}
const res = await fetch("https://models.dev/api.json", {
headers: {
"User-Agent": Installation.USER_AGENT,
},
}).catch(() => null)
if (res && res.ok) {
return await res.json()
}
return {}
}

export const Model = z.object({
id: z.string(),
name: z.string(),
Expand Down Expand Up @@ -80,8 +98,7 @@ export namespace ModelsDev {
const file = Bun.file(filepath)
const result = await file.json().catch(() => {})
if (result) return result as Record<string, Provider>
const json = await data()
return JSON.parse(json) as Record<string, Provider>
return (await fetchModelsData()) as Record<string, Provider>
}

export async function refresh() {
Expand Down
1 change: 1 addition & 0 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@tailwindcss/vite": "catalog:",
"@tsconfig/node22": "catalog:",
"@types/bun": "catalog:",
"@types/dompurify": "catalog:",
"@types/katex": "0.16.7",
"@types/luxon": "catalog:",
"tailwindcss": "catalog:",
Expand Down