mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-29 20:34:28 +00:00
feat(provider): refresh models per AI provider
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"dependencies": {
|
||||
"@earendil-works/pi-ai": "1.5.0",
|
||||
"@earendil-works/pi-durable": "1.5.0",
|
||||
"@earendil-works/pi-ai": "1.7.0",
|
||||
"@earendil-works/pi-durable": "1.7.0",
|
||||
"zod": "4.5.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,60 +78,52 @@ export const updateModelRequestSchema = z.object({
|
||||
|
||||
export type UpdateModelRequest = z.infer<typeof updateModelRequestSchema>
|
||||
|
||||
export const providerRefreshUnavailableReasonSchema = z.enum([
|
||||
'missing_credentials',
|
||||
'unsupported_connection',
|
||||
])
|
||||
|
||||
export type ProviderRefreshUnavailableReason = z.infer<
|
||||
typeof providerRefreshUnavailableReasonSchema
|
||||
>
|
||||
|
||||
export const providerResponseSchema = z.object({
|
||||
id: z.string(),
|
||||
teamId: z.string(),
|
||||
name: z.string(),
|
||||
isBuiltin: z.boolean(),
|
||||
config: providerConfigSchema,
|
||||
models: z.array(providerModelSchema).optional(),
|
||||
modelsCount: z.number().optional(),
|
||||
configured: z.boolean(),
|
||||
refreshUnavailableReason: providerRefreshUnavailableReasonSchema.nullable(),
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date(),
|
||||
})
|
||||
|
||||
export type ProviderResponse = z.infer<typeof providerResponseSchema>
|
||||
|
||||
export const syncModelItemSchema = z.object({
|
||||
export const refreshedProviderModelSchema = z.object({
|
||||
modelId: z.string().min(1),
|
||||
name: z.string().default(''),
|
||||
config: providerModelConfigSchema,
|
||||
selectionToken: z.string().min(1).max(100),
|
||||
})
|
||||
|
||||
export type SyncModelItem = z.infer<typeof syncModelItemSchema>
|
||||
export type RefreshedProviderModel = z.infer<typeof refreshedProviderModelSchema>
|
||||
|
||||
export const syncProviderItemSchema = z.object({
|
||||
name: z.string(),
|
||||
isNewProvider: z.boolean(),
|
||||
config: providerConfigSchema,
|
||||
models: z.array(syncModelItemSchema),
|
||||
export const providerModelRefreshResponseSchema = z.discriminatedUnion('status', [
|
||||
z.object({ status: z.literal('ready'), models: z.array(refreshedProviderModelSchema) }),
|
||||
z.object({
|
||||
status: z.literal('unavailable'),
|
||||
reason: providerRefreshUnavailableReasonSchema,
|
||||
}),
|
||||
])
|
||||
|
||||
export type ProviderModelRefreshResponse = z.infer<typeof providerModelRefreshResponseSchema>
|
||||
|
||||
export const importProviderModelsRequestSchema = z.object({
|
||||
models: z.array(refreshedProviderModelSchema).min(1),
|
||||
})
|
||||
|
||||
export type SyncProviderItem = z.infer<typeof syncProviderItemSchema>
|
||||
|
||||
export const syncCheckResponseSchema = z.object({
|
||||
providers: z.array(syncProviderItemSchema),
|
||||
totalNewProviders: z.number(),
|
||||
totalNewModels: z.number(),
|
||||
})
|
||||
|
||||
export type SyncCheckResponse = z.infer<typeof syncCheckResponseSchema>
|
||||
|
||||
export const syncApplyRequestSchema = z.object({
|
||||
providers: z.array(
|
||||
z.object({
|
||||
name: z.string(),
|
||||
isNewProvider: z.boolean(),
|
||||
config: providerConfigSchema,
|
||||
models: z.array(syncModelItemSchema),
|
||||
}),
|
||||
),
|
||||
})
|
||||
|
||||
export type SyncApplyRequest = z.infer<typeof syncApplyRequestSchema>
|
||||
|
||||
export const syncApplyResponseSchema = z.object({
|
||||
addedProviders: z.number(),
|
||||
addedModels: z.number(),
|
||||
})
|
||||
|
||||
export type SyncApplyResponse = z.infer<typeof syncApplyResponseSchema>
|
||||
export type ImportProviderModelsRequest = z.infer<typeof importProviderModelsRequestSchema>
|
||||
|
||||
Reference in New Issue
Block a user