mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-04 15:14:10 +00:00
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:
@@ -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)
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user