File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import consola from "consola"
2+ import { Hono } from "hono"
3+ import { FetchError } from "ofetch"
4+
5+ import { getModels } from "~/services/copilot/get-models/service"
6+
7+ export const modelRoutes = new Hono ( )
8+
9+ modelRoutes . get ( "/models" , async ( c ) => {
10+ try {
11+ const models = await getModels ( )
12+ return c . json ( models )
13+ } catch ( error ) {
14+ if ( error instanceof FetchError ) {
15+ consola . error ( `Request failed: ${ error . message } ` , error . response ?. _data )
16+ }
17+ throw error
18+ }
19+ } )
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { cors } from "hono/cors"
33import { logger } from "hono/logger"
44
55import { chatCompletionsRoutes } from "./routes/chat-completions/route"
6+ import { modelRoutes } from "./routes/models/route"
67
78export const server = new Hono ( )
89
@@ -11,3 +12,4 @@ server.use(cors())
1112
1213server . get ( "/" , ( c ) => c . text ( "Server running" ) )
1314server . route ( "/" , chatCompletionsRoutes )
15+ server . route ( "/" , modelRoutes )
You can’t perform that action at this time.
0 commit comments