File size: 663 Bytes
50852f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { getConfig } from '../../configs/config.js'

/**

 * 处理 GET /v1/models 请求

 * 返回所有可用模型列表

 */
export async function handleModels(req, res) {
  try {
    const config = getConfig()
    const models = config.models.map(model => ({
      id: model.id,
      object: 'model',
      created: Date.now(),
      owned_by: model.type,
      permission: [],
      root: model.id,
      parent: null
    }))

    res.json({
      object: 'list',
      data: models
    })
  } catch (error) {
    console.error('GET /v1/models 错误:', error)
    res.status(500).json({ error: 'Internal server error' })
  }
}