mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-01 23:02:26 +00:00
feat: Make the models.dev domain configurable for offline environments (#9258)
This commit is contained in:
@@ -22,6 +22,10 @@ export namespace Global {
|
||||
cache,
|
||||
config,
|
||||
state,
|
||||
// Allow overriding models.dev URL for offline deployments
|
||||
get modelsDevUrl() {
|
||||
return process.env.OPENCODE_MODELS_URL || "https://models.dev"
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { Global } from "../global"
|
||||
|
||||
export async function data() {
|
||||
const path = Bun.env.MODELS_DEV_API_JSON
|
||||
if (path) {
|
||||
@@ -6,6 +8,7 @@ export async function data() {
|
||||
return await file.text()
|
||||
}
|
||||
}
|
||||
const json = await fetch("https://models.dev/api.json").then((x) => x.text())
|
||||
const url = Global.Path.modelsDevUrl
|
||||
const json = await fetch(`${url}/api.json`).then((x) => x.text())
|
||||
return json
|
||||
}
|
||||
|
||||
@@ -85,7 +85,8 @@ export namespace ModelsDev {
|
||||
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())
|
||||
const url = Global.Path.modelsDevUrl
|
||||
const json = await fetch(`${url}/api.json`).then((x) => x.text())
|
||||
return JSON.parse(json) as Record<string, Provider>
|
||||
}
|
||||
|
||||
@@ -95,7 +96,8 @@ export namespace ModelsDev {
|
||||
log.info("refreshing", {
|
||||
file,
|
||||
})
|
||||
const result = await fetch("https://models.dev/api.json", {
|
||||
const url = Global.Path.modelsDevUrl
|
||||
const result = await fetch(`${url}/api.json`, {
|
||||
headers: {
|
||||
"User-Agent": Installation.USER_AGENT,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user