cleanup(llm-pi-ai): share the model-entry field schemas between models and modelOverrides
The duplication gate caught the two schema literals diverging only by the id field; the shared dict is now the single home, with the id added where it lives (the entry) and omitted where the dict key carries it.
This commit is contained in:
@@ -175,8 +175,8 @@ const reasoningEfforts = z.dict(
|
|||||||
z.union(THINKING_LEVELS),
|
z.union(THINKING_LEVELS),
|
||||||
) as unknown as z<PiAiReasoningEfforts>
|
) as unknown as z<PiAiReasoningEfforts>
|
||||||
|
|
||||||
const modelProfile: z<PiAiModelProfile> = z.object({
|
/** The fields a `models` entry and a `modelOverrides` value share; only the id's home differs. */
|
||||||
id: z.string().required(),
|
const modelFields = {
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
contextWindow: z.number().step(1).min(1),
|
contextWindow: z.number().step(1).min(1),
|
||||||
maxTokens: z.number().step(1).min(1),
|
maxTokens: z.number().step(1).min(1),
|
||||||
@@ -185,16 +185,15 @@ const modelProfile: z<PiAiModelProfile> = z.object({
|
|||||||
// installed catalog's capability", while `false` disables reasoning.
|
// installed catalog's capability", while `false` disables reasoning.
|
||||||
reasoningEfforts: z.union([z.const(false), reasoningEfforts]),
|
reasoningEfforts: z.union([z.const(false), reasoningEfforts]),
|
||||||
compat: compatProfile,
|
compat: compatProfile,
|
||||||
|
}
|
||||||
|
|
||||||
|
const modelProfile: z<PiAiModelProfile> = z.object({
|
||||||
|
id: z.string().required(),
|
||||||
|
...modelFields,
|
||||||
})
|
})
|
||||||
|
|
||||||
/** A {@link modelProfile} whose id lives in the `modelOverrides` dict key. */
|
/** A {@link modelProfile} whose id lives in the `modelOverrides` dict key. */
|
||||||
const modelOverride: z<PiAiModelOverride> = z.object({
|
const modelOverride: z<PiAiModelOverride> = z.object(modelFields)
|
||||||
name: z.string(),
|
|
||||||
contextWindow: z.number().step(1).min(1),
|
|
||||||
maxTokens: z.number().step(1).min(1),
|
|
||||||
reasoningEfforts: z.union([z.const(false), reasoningEfforts]),
|
|
||||||
compat: compatProfile,
|
|
||||||
})
|
|
||||||
|
|
||||||
const profile = z.object({
|
const profile = z.object({
|
||||||
apiKeyEnv: z.string().role('credential-ref'),
|
apiKeyEnv: z.string().role('credential-ref'),
|
||||||
|
|||||||
Reference in New Issue
Block a user