File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed
Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change 11import { Hono } from "hono"
22
33import { forwardError } from "~/lib/forward-error"
4- import { getModels } from "~/services/copilot/get-models "
4+ import { state } from "~/lib/state "
55
66export const modelRoutes = new Hono ( )
77
88modelRoutes . get ( "/" , async ( c ) => {
99 try {
10- const models = await getModels ( )
11- return c . json ( models )
10+ if ( ! state . models ) {
11+ // This should be handled by startup logic, but as a fallback.
12+ return c . json ( { error : "Models not available" } , 503 )
13+ }
14+
15+ const models = state . models . data . map ( ( model ) => ( {
16+ id : model . id ,
17+ object : "model" ,
18+ type : "model" ,
19+ created : 0 , // No date available from source
20+ created_at : new Date ( 0 ) . toISOString ( ) , // No date available from source
21+ owned_by : model . vendor ,
22+ display_name : model . name ,
23+ } ) )
24+
25+ return c . json ( {
26+ object : "list" ,
27+ data : models ,
28+ has_more : false ,
29+ } )
1230 } catch ( error ) {
1331 return await forwardError ( c , error )
1432 }
You can’t perform that action at this time.
0 commit comments