mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-23 22:07:07 +03:00
Miscellaneous Fixes (#25027)
* Fix GenAI structured response not handling optional fields correctly * allow export thumbnails for camera-restricted roles Export thumbnails under /clips/export/ weren't classified by media auth, so roles with a camera allow-list got a 403 on every thumbnail. The thumbnail now resolves to its export's camera through a thumb_path lookup, and the camera access check applies as usual. * load i18n locales from the base url The locale load path was relative, so any URL with a trailing slash or more than one segment (like /admin/) fetched locales from under that path, got index.html back from the nginx fallback, and broke every UI string. Locales now load from the same base url as the API, which also covers HA ingress and FRIGATE_BASE_PATH. * make storage retained-segment test able to fail The old test put the retained segments after 59 older unretained ones, so cleanup freed its hourly target and stopped before it ever reached them. It passed even with the retention check removed. Retained segments now come first, and cleanup needs every unretained segment after them, so it has to skip the retained ones to finish. --------- Co-authored-by: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com>
This commit is contained in:
co-authored by
Josh Hawkins
parent
4b1ae76baa
commit
d85527ffd2
@@ -7,11 +7,47 @@ from frigate.genai.prompts import (
|
||||
REVIEW_DESCRIPTION_FIELD_GUIDELINES,
|
||||
REVIEW_RESPONSE_STYLES,
|
||||
build_review_description_prompt,
|
||||
build_review_description_response_format,
|
||||
build_review_summary_prompt,
|
||||
get_review_field_guidelines,
|
||||
)
|
||||
|
||||
|
||||
class TestReviewDescriptionResponseFormat(unittest.TestCase):
|
||||
def _schema(self, concerns: list[str]) -> dict:
|
||||
response_format = build_review_description_response_format(concerns)
|
||||
self.assertTrue(response_format["json_schema"]["strict"])
|
||||
return response_format["json_schema"]["schema"]
|
||||
|
||||
def test_every_property_is_required_for_strict_mode(self):
|
||||
for concerns in ([], ["a person loitering near the gate"]):
|
||||
with self.subTest(concerns=concerns):
|
||||
schema = self._schema(concerns)
|
||||
self.assertEqual(set(schema["properties"]), set(schema["required"]))
|
||||
|
||||
def test_time_is_never_requested(self):
|
||||
schema = self._schema(["a person loitering near the gate"])
|
||||
self.assertNotIn("time", schema["properties"])
|
||||
self.assertNotIn("time", schema["required"])
|
||||
|
||||
def test_concerns_omitted_when_not_configured(self):
|
||||
schema = self._schema([])
|
||||
self.assertNotIn("other_concerns", schema["properties"])
|
||||
self.assertNotIn("other_concerns", schema["required"])
|
||||
|
||||
def test_concerns_requested_as_plain_list_when_configured(self):
|
||||
schema = self._schema(["a person loitering near the gate"])
|
||||
concerns = schema["properties"]["other_concerns"]
|
||||
self.assertEqual(concerns["type"], "array")
|
||||
self.assertEqual(concerns["items"], {"type": "string"})
|
||||
self.assertNotIn("anyOf", concerns)
|
||||
self.assertNotIn("default", concerns)
|
||||
|
||||
def test_schema_is_not_shared_between_calls(self):
|
||||
self._schema(["a person loitering near the gate"])
|
||||
self.assertNotIn("other_concerns", self._schema([])["properties"])
|
||||
|
||||
|
||||
class TestReviewResponseStyle(unittest.TestCase):
|
||||
def _build_prompt(self, response_style: str = "default") -> str:
|
||||
review_data = {
|
||||
|
||||
Reference in New Issue
Block a user