make genai provider required and add special case for UI

prevent validation errors from appearing on initial creation of genai provider by setting the first option in the select dropdown as default
This commit is contained in:
Josh Hawkins 2026-05-07 08:47:57 -05:00
parent 6ca60dd23e
commit ce87b9100a
2 changed files with 25 additions and 3 deletions

View File

@ -41,8 +41,7 @@ class GenAIConfig(FrigateBaseModel):
title="Model",
description="The model to use from the provider for generating descriptions or summaries.",
)
provider: GenAIProviderEnum | None = Field(
default=None,
provider: GenAIProviderEnum = Field(
title="Provider",
description="The GenAI provider to use (for example: ollama, gemini, openai).",
)

View File

@ -15,7 +15,7 @@ import { JsonObject, JsonValue } from "@/types/configForm";
* Sections that require special handling at the global level.
* Add new section paths here as needed.
*/
const SPECIAL_CASE_SECTIONS = ["motion", "detectors"] as const;
const SPECIAL_CASE_SECTIONS = ["motion", "detectors", "genai"] as const;
/**
* Check if a section requires special case handling.
@ -53,6 +53,29 @@ export function modifySchemaForSection(
return schemaWithoutDefault;
}
if (sectionPath === "genai") {
const additional = schema.additionalProperties;
if (
additional &&
typeof additional === "object" &&
!Array.isArray(additional)
) {
const props = (additional as RJSFSchema).properties;
if (props && typeof props.provider === "object") {
return {
...schema,
additionalProperties: {
...additional,
properties: {
...props,
provider: { ...(props.provider as object), default: "openai" },
},
},
};
}
}
}
return schema;
}