Skip to content

Commit 22125d1

Browse files
committed
wip: zen
1 parent 8c120f2 commit 22125d1

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

packages/console/core/src/model.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,27 @@ export namespace ZenData {
5353
weight: z.number().optional(),
5454
disabled: z.boolean().optional(),
5555
storeModel: z.string().optional(),
56-
headers: z.record(z.string(), z.string()).optional(),
57-
bodyModifier: z.record(z.string(), z.string()).optional(),
5856
}),
5957
),
6058
})
6159

6260
const ProviderSchema = z.object({
6361
api: z.string(),
6462
apiKey: z.string(),
65-
format: FormatSchema,
63+
format: FormatSchema.optional(),
6664
headerMappings: z.record(z.string(), z.string()).optional(),
65+
family: z.string().optional(),
66+
})
67+
68+
const ProviderFamilySchema = z.object({
69+
headers: z.record(z.string(), z.string()).optional(),
70+
bodyModifier: z.record(z.string(), z.string()).optional(),
6771
})
6872

6973
const ModelsSchema = z.object({
7074
models: z.record(z.string(), z.union([ModelSchema, z.array(ModelSchema.extend({ formatFilter: FormatSchema }))])),
7175
providers: z.record(z.string(), ProviderSchema),
76+
providerFamilies: z.record(z.string(), ProviderFamilySchema),
7277
})
7378

7479
export const validate = fn(ModelsSchema, (input) => {
@@ -98,7 +103,16 @@ export namespace ZenData {
98103
Resource.ZEN_MODELS19.value +
99104
Resource.ZEN_MODELS20.value,
100105
)
101-
return ModelsSchema.parse(json)
106+
const { models, providers, providerFamilies } = ModelsSchema.parse(json)
107+
return {
108+
models,
109+
providers: Object.fromEntries(
110+
Object.entries(providers).map(([id, provider]) => [
111+
id,
112+
{ ...provider, ...(provider.family ? providerFamilies[provider.family] : {}) },
113+
]),
114+
),
115+
}
102116
})
103117
}
104118

0 commit comments

Comments
 (0)