mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-09-24 18:26:51 +03:00
CI / AMD64 Build (push) Canceled after 0s
CI / AMD64 Smoke Test (push) Canceled after 0s
CI / ARM Build (push) Canceled after 0s
CI / Jetson Jetpack 6 (push) Canceled after 0s
CI / AMD64 Extra Build (push) Canceled after 0s
CI / ARM Extra Build (push) Canceled after 0s
CI / Synaptics Build (push) Canceled after 0s
CI / Assemble and push default build (push) Canceled after 0s
* check for a valid frame before using its shape With the camera offline, no preview frame, and `camera-error.jpg` missing, `latest_frame` read `frame.shape` before its `frame is None` check, so it raised `AttributeError` and answered 500 with a traceback instead of the intended "Unable to get valid frame". The check now runs first. * fix the has_clip self-heal for events with no recordings `vod_event` looked for a `(body, 404)` tuple, but `vod_ts` returns a `JSONResponse`, so the check never matched and an old event whose recordings are gone kept offering a clip that can't play. It now checks the response status code. * return 403 for a snapshot or thumbnail on another camera The broad `except Exception` handlers in `event_snapshot` and `event_thumbnail` caught the `HTTPException` from `require_camera_access`, so a restricted user asking for another camera's snapshot got a 404 instead of a 403, and for an object still being tracked the snapshot was rendered before the check ran. Both endpoints now look up the event and check access in their own block, the way the other endpoints do, so a denial propagates. * find DST transitions to the second `get_dst_transitions` probed the offset once every 24 hours from the start time and reported a change at the first probe after it, up to a day late, so events, review items and recordings near a transition were grouped into days with the old offset. A transition after the last daily probe wasn't found at all. The end of the range is probed too now, and a probe that sees the offset change bisects the interval to the second of the transition. * don't run page shortcuts for keys a dialog already handled Radix dismisses a dialog on Escape from a capture-phase keydown listener and calls `preventDefault()` without stopping propagation, so `useKeyboardListener` still ran the page's Escape shortcut: cancelling the delete dialog in the face library or a classification model also cleared the whole selection. Keys another shortcut hook handled still get through, since their listener order changes with every render. * fix train image filtering for a class with a dash The backend writes a class with a `-` as `_` in train file names, since it splits those names on `-`, while a dataset folder keeps the dash. Filtering the Train grid by `half-open` compared it with `half_open` and hid every attempt. Both sides are normalized the same way now. * don't edit a chat message while a reply streams The edit button stayed active while a reply streamed. `submitConversation` returns early while loading, but the message bubble still closed its editor, so the edit was silently lost. The edit button is hidden while a reply streams, and an editor that's already open keeps its draft with send disabled until the reply ends. * fix restart failing under non-root restart_frigate() called psutil.Process(1).terminate() to signal s6-svscan, but s6-svscan runs as root while frigate runs as uid 1000, so the call raised AccessDenied. That exception escaped every caller: the UI restart button dropped its websocket client, MQTT restart and Save & Restart just logged and did nothing, and the watchdog crashed its own monitoring thread on a dead detector. This catches AccessDenied and falls through to the existing SIGINT branch, which exits the process for s6 to restart it. * show runtime overrides in the settings form The settings form read a camera section's saved config value, but its dependent warnings (audio transcription requiring audio detection, snapshots requiring detect, etc.) read the live config instead. A runtime toggle from the live view, MQTT, or an active profile can turn a section off without touching yaml, and that override persists across restarts, so the Enable switch showed on while the warning said the feature wasn't enabled. This adds an "Overridden (Live)" badge to any field whose live value differs from what's saved, and swaps the affected warnings to runtime-specific wording when a runtime override is the actual cause instead of the config. * fix mobile overflowing icons in system due to new health pane * fix genai settings keeping a stale model and dropping roles after save Switching a GenAI entry's provider left the previous provider's model selected, so saving wrote a model the new provider doesn't serve. llama.cpp can't find that model in `/v1/models`, so the backend reported every capability as false for the entry, and once the save refetched `genai/models` the roles widget stripped `transcribe` from the form on its own. The section showed unsaved changes right after saving, and saving again would have dropped the role. Switching provider now clears the model, and the roles widget only strips a role for a model or provider picked in the form, since the entry-level capability flags only describe the saved model. A selected role stays visible when the provider can't confirm it, so it can still be switched off. The llama.cpp model list also no longer repeats a model whose alias matches its id, which is what `--alias` produces. * close onvif sessions on shutdown `OnvifController.close()` only stopped its event loop, so the aiohttp sessions each `ONVIFCamera` holds and the `_poll_config_updates` task were left to be garbage collected during interpreter shutdown, when their warnings can no longer be logged. Every restart ended with a run of `Unclosed client session` and `Task was destroyed but it is pending!` logging errors, which only became visible once restart started exiting the process itself under non-root. `close()` now closes each camera's client and cancels the tasks on the loop before stopping it. * fixes * fixes
217 lines
6.9 KiB
TypeScript
217 lines
6.9 KiB
TypeScript
/**
|
|
* Generative AI provider settings tests -- MEDIUM tier.
|
|
*
|
|
* A model name belongs to its provider, so switching provider clears the model
|
|
* field. The roles widget strips a role only for a model or provider picked in
|
|
* the form, never when capability data arrives for the saved entry, which would
|
|
* dirty the section on load and silently drop the role on the next save.
|
|
*/
|
|
|
|
import { readFileSync } from "node:fs";
|
|
import { resolve, dirname } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { test, expect } from "../../fixtures/frigate-test";
|
|
import type { Page } from "@playwright/test";
|
|
import { configFactory } from "../../fixtures/mock-data/config";
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const CONFIG_SCHEMA = JSON.parse(
|
|
readFileSync(
|
|
resolve(__dirname, "../../fixtures/mock-data/config-schema.json"),
|
|
"utf-8",
|
|
),
|
|
);
|
|
|
|
const ENTRY = "audio";
|
|
const SETTINGS_URL = "/settings?page=integrationGenerativeAi";
|
|
const UNSAVED = "You have unsaved changes";
|
|
const MODEL_PLACEHOLDER = "Select or enter a model…";
|
|
|
|
type Entry = {
|
|
provider: string;
|
|
model: string;
|
|
base_url?: string;
|
|
roles: string[];
|
|
};
|
|
|
|
type ProviderInfo = {
|
|
models: string[];
|
|
supports_transcription: boolean;
|
|
model_capabilities?: Record<string, { supports_transcription?: boolean }>;
|
|
};
|
|
|
|
async function installRoutes(page: Page, entry: Entry, info: ProviderInfo) {
|
|
const config = configFactory({ genai: { [ENTRY]: entry } });
|
|
|
|
await page.route("**/api/config/schema.json", (route) =>
|
|
route.fulfill({ json: CONFIG_SCHEMA }),
|
|
);
|
|
await page.route("**/api/config", (route) => {
|
|
if (route.request().method() === "GET") {
|
|
return route.fulfill({ json: config });
|
|
}
|
|
return route.fulfill({ json: { success: true } });
|
|
});
|
|
await page.route("**/api/config/raw_paths", (route) =>
|
|
route.fulfill({ json: { genai: { [ENTRY]: entry } } }),
|
|
);
|
|
await page.route("**/api/genai/models", (route) =>
|
|
route.fulfill({
|
|
json: {
|
|
[ENTRY]: {
|
|
roles: entry.roles,
|
|
supports_toggleable_thinking: false,
|
|
supports_embeddings: true,
|
|
model_capabilities: {},
|
|
...info,
|
|
},
|
|
},
|
|
}),
|
|
);
|
|
}
|
|
|
|
function roleSwitch(page: Page, role: string) {
|
|
return page.locator(`#root_${ENTRY}_roles-${role}`);
|
|
}
|
|
|
|
test.describe("genai provider settings @medium", () => {
|
|
test("a saved role the provider cannot confirm stays and is not dirty", async ({
|
|
frigateApp,
|
|
}) => {
|
|
// The server does not serve the saved model, so the backend reports every
|
|
// capability as false for the entry.
|
|
await installRoutes(
|
|
frigateApp.page,
|
|
{
|
|
provider: "llamacpp",
|
|
model: "stale-model",
|
|
base_url: "http://llama:8080",
|
|
roles: ["transcribe"],
|
|
},
|
|
{ models: ["qwen3-asr"], supports_transcription: false },
|
|
);
|
|
await frigateApp.goto(SETTINGS_URL);
|
|
|
|
await expect(roleSwitch(frigateApp.page, "transcribe")).toBeVisible();
|
|
await expect(roleSwitch(frigateApp.page, "transcribe")).toBeChecked();
|
|
|
|
// Give any stripping effect time to fire, then confirm the section stayed
|
|
// clean.
|
|
await frigateApp.page.waitForTimeout(1000);
|
|
await expect(frigateApp.page.getByText(UNSAVED)).toBeHidden();
|
|
await expect(roleSwitch(frigateApp.page, "transcribe")).toBeChecked();
|
|
});
|
|
|
|
test("switching provider clears the model", async ({ frigateApp }) => {
|
|
await installRoutes(
|
|
frigateApp.page,
|
|
{
|
|
provider: "openai",
|
|
model: "gpt-4o",
|
|
roles: ["descriptions"],
|
|
},
|
|
{ models: ["gpt-4o"], supports_transcription: true },
|
|
);
|
|
await frigateApp.goto(SETTINGS_URL);
|
|
|
|
const model = frigateApp.page.locator(`#root_${ENTRY}_model`);
|
|
await expect(model).toHaveText("gpt-4o");
|
|
|
|
await frigateApp.page.locator(`#root_${ENTRY}_provider`).click();
|
|
await frigateApp.page.getByRole("option", { name: "llamacpp" }).click();
|
|
|
|
await expect(model).toHaveText(MODEL_PLACEHOLDER);
|
|
await expect(frigateApp.page.getByText(UNSAVED)).toBeVisible();
|
|
});
|
|
|
|
test("switching back to the saved provider drops the other provider's model", async ({
|
|
frigateApp,
|
|
}) => {
|
|
await installRoutes(
|
|
frigateApp.page,
|
|
{
|
|
provider: "openai",
|
|
model: "gpt-4o",
|
|
roles: ["descriptions"],
|
|
},
|
|
{ models: ["gpt-4o", "qwen3"], supports_transcription: true },
|
|
);
|
|
await frigateApp.goto(SETTINGS_URL);
|
|
|
|
const model = frigateApp.page.locator(`#root_${ENTRY}_model`);
|
|
const provider = frigateApp.page.locator(`#root_${ENTRY}_provider`);
|
|
await expect(model).toHaveText("gpt-4o");
|
|
|
|
await provider.click();
|
|
await frigateApp.page.getByRole("option", { name: "llamacpp" }).click();
|
|
await model.click();
|
|
await frigateApp.page.getByRole("option", { name: "qwen3" }).click();
|
|
await expect(model).toHaveText("qwen3");
|
|
|
|
// the model picked for llamacpp must not carry over to openai, and the
|
|
// saved one isn't filled back in since the endpoint may have changed
|
|
await provider.click();
|
|
await frigateApp.page
|
|
.getByRole("option", { name: "openai", exact: true })
|
|
.click();
|
|
|
|
await expect(model).toHaveText(MODEL_PLACEHOLDER);
|
|
});
|
|
|
|
test("undo after switching provider brings back the saved model", async ({
|
|
frigateApp,
|
|
}) => {
|
|
await installRoutes(
|
|
frigateApp.page,
|
|
{
|
|
provider: "openai",
|
|
model: "gpt-4o",
|
|
roles: ["descriptions"],
|
|
},
|
|
{ models: ["gpt-4o"], supports_transcription: true },
|
|
);
|
|
await frigateApp.goto(SETTINGS_URL);
|
|
|
|
const model = frigateApp.page.locator(`#root_${ENTRY}_model`);
|
|
await frigateApp.page.locator(`#root_${ENTRY}_provider`).click();
|
|
await frigateApp.page.getByRole("option", { name: "llamacpp" }).click();
|
|
await expect(model).toHaveText(MODEL_PLACEHOLDER);
|
|
|
|
await frigateApp.page.getByRole("button", { name: "Undo" }).click();
|
|
|
|
await expect(model).toHaveText("gpt-4o");
|
|
await expect(frigateApp.page.getByText(UNSAVED)).toBeHidden();
|
|
});
|
|
|
|
test("picking a model that cannot transcribe strips the role", async ({
|
|
frigateApp,
|
|
}) => {
|
|
await installRoutes(
|
|
frigateApp.page,
|
|
{
|
|
provider: "llamacpp",
|
|
model: "qwen3-asr",
|
|
base_url: "http://llama:8080",
|
|
roles: ["transcribe"],
|
|
},
|
|
{
|
|
models: ["qwen3-asr", "text-only"],
|
|
supports_transcription: true,
|
|
model_capabilities: {
|
|
"qwen3-asr": { supports_transcription: true },
|
|
"text-only": { supports_transcription: false },
|
|
},
|
|
},
|
|
);
|
|
await frigateApp.goto(SETTINGS_URL);
|
|
|
|
await expect(roleSwitch(frigateApp.page, "transcribe")).toBeChecked();
|
|
|
|
await frigateApp.page.locator(`#root_${ENTRY}_model`).click();
|
|
await frigateApp.page.getByRole("option", { name: "text-only" }).click();
|
|
|
|
await expect(roleSwitch(frigateApp.page, "transcribe")).toBeHidden();
|
|
await expect(frigateApp.page.getByText(UNSAVED)).toBeVisible();
|
|
});
|
|
});
|