mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-07-16 13:47:07 +02:00
Improve handling of error conditions with ollama and snapshot regeneration (#15527)
This commit is contained in:
parent
d49f958d4d
commit
717493e668
@ -325,10 +325,15 @@ class EmbeddingMaintainer(threading.Thread):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if event.has_snapshot and source == "snapshot":
|
if event.has_snapshot and source == "snapshot":
|
||||||
with open(
|
snapshot_file = os.path.join(CLIPS_DIR, f"{event.camera}-{event.id}.jpg")
|
||||||
os.path.join(CLIPS_DIR, f"{event.camera}-{event.id}.jpg"),
|
|
||||||
"rb",
|
if not os.path.isfile(snapshot_file):
|
||||||
) as image_file:
|
logger.error(
|
||||||
|
f"Cannot regenerate description for {event.id}, snapshot file not found: {snapshot_file}"
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
with open(snapshot_file, "rb") as image_file:
|
||||||
snapshot_image = image_file.read()
|
snapshot_image = image_file.read()
|
||||||
img = cv2.imdecode(
|
img = cv2.imdecode(
|
||||||
np.frombuffer(snapshot_image, dtype=np.int8), cv2.IMREAD_COLOR
|
np.frombuffer(snapshot_image, dtype=np.int8), cv2.IMREAD_COLOR
|
||||||
|
@ -38,6 +38,11 @@ class OllamaClient(GenAIClient):
|
|||||||
|
|
||||||
def _send(self, prompt: str, images: list[bytes]) -> Optional[str]:
|
def _send(self, prompt: str, images: list[bytes]) -> Optional[str]:
|
||||||
"""Submit a request to Ollama"""
|
"""Submit a request to Ollama"""
|
||||||
|
if self.provider is None:
|
||||||
|
logger.warning(
|
||||||
|
"Ollama provider has not been initialized, a description will not be generated. Check your Ollama configuration."
|
||||||
|
)
|
||||||
|
return None
|
||||||
try:
|
try:
|
||||||
result = self.provider.generate(
|
result = self.provider.generate(
|
||||||
self.genai_config.model,
|
self.genai_config.model,
|
||||||
|
Loading…
Reference in New Issue
Block a user