Refresh provider models from the public Pi catalog (#555)

* feat(provider): refresh models from the public Pi catalog

* fix(provider): simplify provider card actions
This commit is contained in:
Yiling-J
2026-11-30 10:59:51 +08:00
committed by GitHub
parent d315253450
commit e3fe5792b9
34 changed files with 1618 additions and 4414 deletions
+17 -13
View File
@@ -5,7 +5,7 @@ import { providerService } from '@shumai/core/src/provider/provider'
import {
createModelRequestSchema,
createProviderRequestSchema,
syncApplyRequestSchema,
importProviderModelsRequestSchema,
updateModelRequestSchema,
updateProviderRequestSchema,
AuditAction,
@@ -31,8 +31,8 @@ const route = new Hono<{ Variables: { user: User } }>()
return c.json(providers)
})
.post('/teams/:teamId/providers/sync-check', async (c) => {
const teamId = c.req.param('teamId')
.post('/teams/:teamId/providers/:providerId/models/refresh', async (c) => {
const { teamId, providerId } = c.req.param()
const user = c.get('user')
await authzService.hasPermission({
@@ -42,15 +42,16 @@ const route = new Hono<{ Variables: { user: User } }>()
id: teamId,
})
const result = await providerService.checkUpdates(teamId)
const result = await providerService.refreshModels(teamId, providerId)
c.header('Cache-Control', 'no-store')
return c.json(result)
})
.post(
'/teams/:teamId/providers/sync-apply',
zValidator('json', syncApplyRequestSchema),
'/teams/:teamId/providers/:providerId/models/import',
zValidator('json', importProviderModelsRequestSchema),
async (c) => {
const teamId = c.req.param('teamId')
const { teamId, providerId } = c.req.param()
const user = c.get('user')
const body = c.req.valid('json')
@@ -61,12 +62,15 @@ const route = new Hono<{ Variables: { user: User } }>()
id: teamId,
})
const result = await providerService.applySync(teamId, body)
await auditLogService.logAction({
action: AuditAction.provider_update,
teamId,
userId: user?.id,
})
const result = await providerService.importModels(teamId, providerId, body)
if (result.addedModels > 0) {
await auditLogService.logAction({
action: AuditAction.provider_update,
teamId,
userId: user?.id,
itemId: providerId,
})
}
return c.json(result)
},
)