mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-08-04 01:48:54 +03:00
Improve handling of non-Jina models
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
// Reads model via LiveFormDataContext so it re-runs even when RJSF's
|
// Reads model via LiveFormDataContext so it re-runs even when RJSF's
|
||||||
// SchemaField memoization would skip this widget.
|
// SchemaField memoization would skip this widget.
|
||||||
import type { WidgetProps } from "@rjsf/utils";
|
import type { WidgetProps } from "@rjsf/utils";
|
||||||
import { useContext, useEffect } from "react";
|
import { useContext } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
@@ -24,19 +24,10 @@ export function SemanticSearchModelSizeWidget(props: WidgetProps) {
|
|||||||
model !== "jinav1" &&
|
model !== "jinav1" &&
|
||||||
model !== "jinav2";
|
model !== "jinav2";
|
||||||
|
|
||||||
// Clear model_size while on a provider (buildOverrides converts to ""
|
// model_size is ignored by the backend while a provider is selected, so the
|
||||||
// which the backend treats as "remove"). Restore the schema default
|
// field is only greyed out here. Rewriting the form data instead would leave
|
||||||
// when returning to a Jina model so the field isn't left empty.
|
// the section permanently dirty: the effective config always reports a
|
||||||
const { value, onChange, schema } = props;
|
// model_size, so the diff could never be cleared by saving.
|
||||||
const schemaDefault = schema?.default as string | undefined;
|
|
||||||
useEffect(() => {
|
|
||||||
if (isProvider && value !== undefined) {
|
|
||||||
onChange(undefined);
|
|
||||||
} else if (!isProvider && value === undefined && schemaDefault) {
|
|
||||||
onChange(schemaDefault);
|
|
||||||
}
|
|
||||||
}, [isProvider, value, onChange, schemaDefault]);
|
|
||||||
|
|
||||||
if (isProvider) {
|
if (isProvider) {
|
||||||
const fieldClassName = getSizedFieldClassName(props.options ?? {}, "sm");
|
const fieldClassName = getSizedFieldClassName(props.options ?? {}, "sm");
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user