Ai_task.generate_data and local image file to analyze

Hi all

I’m trying to analyze a local image with ai_task.generate_data but I’m not able to do it

I have a jpg file in /config/www/llm/vialetto_snap.jpg and I would like to use it as source to be analyzed.

The automation is this

alias: ollama new telegram
description: ""
triggers:
  - entity_id: input_boolean.attiva_llm
    from: "off"
    to: "on"
    trigger: state
    enabled: true
  - trigger: event
    event_type: folder_watcher
    event_data:
      file: /config/www/llm/vialetto_snap.jpg
    enabled: false
conditions: []
actions:
  - data:
      entity_id: ai_task.ollama_ai_task_llava_7b
      task_name: AI camera vialetto - media camera
      instructions: >
        Analizza la snapshot della telecamera e descrivi quello che vedi
        concentrandoti su persona, animale, auto o moto.
        Non descrivere l'ambiente, tipo l'asfalto, il muretto, le piante e così
        via.
      attachments:
        media_content_id: "{{ media_local_uri }}"
        media_content_type: image/jpeg
        metadata:
          title: Vialetto
          thumbnail: "{{ media_local_uri }}"
          media_class: image
    response_variable: ai_response_a
    action: ai_task.generate_data
  - delay: "00:00:01"
  - variables:
      analysis_text: |-
        {% if ai_response_a is defined and ai_response_a.data | default('') %}
          {{ ai_response_a.data }}
        {% elif ai_response_b is defined and ai_response_b.data | default('') %}
          {{ ai_response_b.data }}
        {% else %}
          Nessuna analisi disponibile
        {% endif %}
  - data:
      title: Vialetto - analisi
      message: "{{ analysis_text }}"
    action: persistent_notification.create
  - data:
      config_entry_id: XXXXXXXXXXX
      file: "{{ snapshot_file }}"
      caption: "{{ analysis_text }}"
      parse_mode: plain_text
    action: telegram_bot.send_photo
mode: single
variables:
  filename: vialetto_snap.jpg
  snapshot_file: /config/www/llm/{{ filename }}
  media_local_uri: media-source://media_source/local/llm/{{ filename }}

The error I’m getting is
Error: Unknown source directory.

What am I doing wrong?

Thanks

I answer myself.
I had to define media_dirs: in configurations.yaml withe the folder where my jpg snapshot is located
Then I used the visual editor and I chose the “My media” and from there I chose the media_dirs just created and then the file I need

This is translated in YAML as below

  attachments:
    media_content_id: media-source://media_source/frigate_snap/vialetto_snap.jpg
    media_content_type: image/jpeg
    metadata:
      title: vialetto_snap.jpg
      thumbnail: null
      media_class: image
      children_media_class: null
      navigateIds:
        - {}
        - media_content_type: app
          media_content_id: media-source://media_source
        - media_content_type: ""
          media_content_id: media-source://media_source/frigate_snap/.

Not very easy to understand for “just” a file input