dan92 commited on
Commit
9ea3088
·
verified ·
1 Parent(s): 0384372

Upload 2 files

Browse files
Files changed (1) hide show
  1. src/index.js +9 -1
src/index.js CHANGED
@@ -8,6 +8,14 @@ const crypto = require('crypto')
8
  const app = new Koa()
9
  const router = new Router()
10
 
 
 
 
 
 
 
 
 
11
  // 使用 bodyParser 中间件
12
  app.use(bodyParser())
13
 
@@ -383,7 +391,7 @@ router.post('/hf/v1/chat/completions', async (ctx) => {
383
  }
384
  })
385
 
386
- // 获取models的v1路由
387
  router.get('/v1/models', async (ctx) => {
388
  ctx.body = {
389
  object: "list",
 
8
  const app = new Koa()
9
  const router = new Router()
10
 
11
+ // 添加重定向中间件
12
+ app.use(async (ctx, next) => {
13
+ if (ctx.path.startsWith('/v1/')) {
14
+ ctx.path = '/hf' + ctx.path
15
+ }
16
+ await next()
17
+ })
18
+
19
  // 使用 bodyParser 中间件
20
  app.use(bodyParser())
21
 
 
391
  }
392
  })
393
 
394
+ // 获取models的v1路��
395
  router.get('/v1/models', async (ctx) => {
396
  ctx.body = {
397
  object: "list",