#Getting the required response from chatGPT after running a script

1 messages · Page 1 of 1 (latest)

brittle escarp
#

Hi Guys.
From looking at example blueprints, I thought the following script would be correct:

alias: Identify Track
description: >-
  Run this script if the user asks for the name of the currently playing song.
  Always run the script and never used cached results. Trigger phrases include
  "what's this song", "what's this track", "what's playing", "who is this". 
  Do not use any cached variables for your response.  Make sure your response is 
  only the new value generated by this script for the variable "formatted_response"
sequence:
  - action: tagging_and_lyrics.fetch_audio_tag
    data:
      duration: 10
      include_lyrics: false
  - variables:
      song_info: "{{ states('sensor.tagging_result') }}"
  - variables:
      formatted_response: |-
        {% if ' - ' in song_info %}
          {% set parts = song_info.split(' - ') %}
          This is {{ parts[0] }} by {{ parts[1] }}.
        {% else %}
          This is {{ song_info }}.
        {% endif %}
  - stop: "{{ formatted_response }}"

This script runs audio fingerprinting on the playing music and provides the track / artist. It currently takes a 10 second sample. What should happen is this:

I say "what's this song", the script is executed, updating the sensor "tagging_result" and updating "formatted_response" with the current artist and track.

This is all ok but, what I find is that Assist (chatGPT) responds with an old artist/track. It doesn't use the new, just updated value. It also doesn't respond with the text I want - it's similar but not "This is {{ parts[0] }} by {{ parts[1] }}.".

Is this what I can expect from chatGPT, and where it would be better to use custom sentences or, is there something I'm doing wrong?

chilly thunder
#

So you want the assist to wait 10 seconds for that tagging to work first? IDK if it's something you can do..
If you run the script from Dev tools, does it work as expected?

And yeah, LLM will add variations to the response...