Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Gregg committed Jan 15, 2025
1 parent 8838581 commit 8383c5b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/frigate_event_processor/frigate_event_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ def generate_location_string(self, event):

def generate_notification(self, event):
""" Returns a JSON string representing the alert notification for this event """
if event is None:
logger.warning("generate_notification called with no event")
return None

logger.debug("Event %s: Generating notification for event", event.id)

detection = self.generate_detection_string(event)
Expand Down
3 changes: 2 additions & 1 deletion src/frigate_event_processor/mqtt_event_receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ def connect_and_loop(self):
elif command.lower().startswith("n "):
event = self.processor.get_ongoing_event(command[2:])
message = self.processor.generate_notification(event)
logger.info("Response %s", message)
output = json.dumps(message.to_dict(), indent=2)
logger.info("Notification:\n%s", output)
elif command.lower().startswith("t "):
event = self.processor.get_ongoing_event(command[2:])
url = self.processor.get_snapshot_url(event)
Expand Down
3 changes: 1 addition & 2 deletions src/frigate_event_processor/ollama_vision_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def process_event(self, detection, location, snapshot_url, event):

logger.info("Event %s: processing with AI model: %s", event.id, self.config.ai_model)

image_data = super()._prepare_prompt(detection, location)
image_data = super()._fetch_image_base64(snapshot_url)
if image_data is None:
return None

Expand All @@ -41,7 +41,6 @@ def process_event(self, detection, location, snapshot_url, event):

try:
response = httpx.post(self.config.service_url, json=request)
response = self.model.generate_content(request)
logger.debug("API response: %s", response)
return response.json().get('response')
except Exception as exc:
Expand Down
2 changes: 1 addition & 1 deletion src/frigate_event_processor/vision_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _prepare_prompt(self, detection, location):
@staticmethod
def get_vision_engine(config: AIConfig) -> 'BaseVisionProcessor':
"""Returns a vision processor based on the engine."""
if config.engine == 'olama':
if config.engine == 'ollama':
logger.info("Using Olama Vision processor.")
from .ollama_vision_processor import OlamaVision
return OlamaVision(config)
Expand Down

0 comments on commit 8383c5b

Please sign in to comment.