Skip to content

Commit 43dc70c

Browse files
committed
fix: Ensure models are cached before serving requests
1 parent f8d1678 commit 43dc70c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/routes/models/route.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Hono } from "hono"
22

33
import { forwardError } from "~/lib/forward-error"
4+
import { cacheModels } from "~/lib/models"
45
import { state } from "~/lib/state"
56

67
export const modelRoutes = new Hono()
@@ -9,10 +10,10 @@ modelRoutes.get("/", async (c) => {
910
try {
1011
if (!state.models) {
1112
// This should be handled by startup logic, but as a fallback.
12-
return c.json({ error: "Models not available" }, 503)
13+
await cacheModels()
1314
}
1415

15-
const models = state.models.data.map((model) => ({
16+
const models = state.models?.data.map((model) => ({
1617
id: model.id,
1718
object: "model",
1819
type: "model",

0 commit comments

Comments
 (0)