| 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' }) | |
| } | |
| } | |