refactor: migrate src/provider/provider.ts from Bun.file() to Filesystem module (#14132)
This commit is contained in:
@@ -16,6 +16,7 @@ import { Flag } from "../flag/flag"
|
|||||||
import { iife } from "@/util/iife"
|
import { iife } from "@/util/iife"
|
||||||
import { Global } from "../global"
|
import { Global } from "../global"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
|
import { Filesystem } from "../util/filesystem"
|
||||||
|
|
||||||
// Direct imports for bundled providers
|
// Direct imports for bundled providers
|
||||||
import { createAmazonBedrock, type AmazonBedrockProviderSettings } from "@ai-sdk/amazon-bedrock"
|
import { createAmazonBedrock, type AmazonBedrockProviderSettings } from "@ai-sdk/amazon-bedrock"
|
||||||
@@ -1291,8 +1292,9 @@ export namespace Provider {
|
|||||||
if (cfg.model) return parseModel(cfg.model)
|
if (cfg.model) return parseModel(cfg.model)
|
||||||
|
|
||||||
const providers = await list()
|
const providers = await list()
|
||||||
const recent = (await Bun.file(path.join(Global.Path.state, "model.json"))
|
const recent = (await Filesystem.readJson<{ recent?: { providerID: string; modelID: string }[] }>(
|
||||||
.json()
|
path.join(Global.Path.state, "model.json"),
|
||||||
|
)
|
||||||
.then((x) => (Array.isArray(x.recent) ? x.recent : []))
|
.then((x) => (Array.isArray(x.recent) ? x.recent : []))
|
||||||
.catch(() => [])) as { providerID: string; modelID: string }[]
|
.catch(() => [])) as { providerID: string; modelID: string }[]
|
||||||
for (const entry of recent) {
|
for (const entry of recent) {
|
||||||
|
|||||||
Reference in New Issue
Block a user