mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-11-28 16:27:07 +03:00
fix genai and classification error paths (#25077)
- Catch all httpx errors in the Ollama plugin so a dropped connection no longer ends the embeddings thread - Strip only a trailing /v1 from the llama.cpp base_url - Cap the timestamp top-up loop in state example generation, which looped forever on zero-length review items - Run state example generation in a thread under the example collection lock - Stage example frames in a system temp dir so a leftover dataset/temp folder can't become a training class - Report face training success only after the image is written, and return 404 when the event has no face attributes or snapshot - Move VLM watch setup inside the runner's try block, build the runner before claiming the watch slot, bound max_duration_minutes, and reject non-string labels and zones from the chat tool
This commit is contained in:
+27
-17
@@ -28,6 +28,8 @@ _MAX_INTERVAL = 300
|
||||
# Minimum seconds between VLM iterations when woken by detections (no zone filter)
|
||||
_DETECTION_COOLDOWN_WITHOUT_ZONE = 10
|
||||
|
||||
MAX_WATCH_MINUTES = 1440
|
||||
|
||||
# Max user/assistant turn pairs to keep in conversation history
|
||||
_MAX_HISTORY = 10
|
||||
|
||||
@@ -75,15 +77,17 @@ class VLMWatchRunner(threading.Thread):
|
||||
self.conversation: list[dict[str, Any]] = []
|
||||
|
||||
def run(self) -> None:
|
||||
self.job.status = JobStatusTypesEnum.running
|
||||
self.job.start_time = time.time()
|
||||
self._broadcast_status()
|
||||
self.conversation = [{"role": "system", "content": self._build_system_prompt()}]
|
||||
|
||||
# monotonic so a wall clock step can't end the job early or let it overrun
|
||||
max_end_time = time.monotonic() + self.job.max_duration_minutes * 60
|
||||
|
||||
try:
|
||||
self.job.status = JobStatusTypesEnum.running
|
||||
self.job.start_time = time.time()
|
||||
self._broadcast_status()
|
||||
self.conversation = [
|
||||
{"role": "system", "content": self._build_system_prompt()}
|
||||
]
|
||||
|
||||
# monotonic so a wall clock step can't end the job early or let it overrun
|
||||
max_end_time = time.monotonic() + self.job.max_duration_minutes * 60
|
||||
|
||||
while not self.cancel_event.is_set():
|
||||
if time.monotonic() > max_end_time:
|
||||
logger.debug(
|
||||
@@ -204,7 +208,13 @@ class VLMWatchRunner(threading.Thread):
|
||||
)
|
||||
reasoning = str(parsed.get("reasoning", ""))
|
||||
notification_message = str(parsed.get("notification_message", ""))
|
||||
except (json.JSONDecodeError, ValueError, TypeError) as e:
|
||||
except (
|
||||
json.JSONDecodeError,
|
||||
ValueError,
|
||||
TypeError,
|
||||
AttributeError,
|
||||
OverflowError,
|
||||
) as e:
|
||||
logger.warning(
|
||||
"VLM watch job %s: failed to parse VLM response: %s", self.job.id, e
|
||||
)
|
||||
@@ -403,17 +413,17 @@ def start_vlm_watch_job(
|
||||
username=username,
|
||||
)
|
||||
cancel_ev = threading.Event()
|
||||
runner = VLMWatchRunner(
|
||||
job=job,
|
||||
config=config,
|
||||
cancel_event=cancel_ev,
|
||||
frame_processor=frame_processor,
|
||||
genai_manager=genai_manager,
|
||||
dispatcher=dispatcher,
|
||||
)
|
||||
_current_job = job
|
||||
_cancel_event = cancel_ev
|
||||
|
||||
runner = VLMWatchRunner(
|
||||
job=job,
|
||||
config=config,
|
||||
cancel_event=cancel_ev,
|
||||
frame_processor=frame_processor,
|
||||
genai_manager=genai_manager,
|
||||
dispatcher=dispatcher,
|
||||
)
|
||||
runner.start()
|
||||
|
||||
logger.debug(
|
||||
|
||||
Reference in New Issue
Block a user