#Saving sentences

1 messages · Page 1 of 1 (latest)

queen flame
#

Hi, I know this question might be common, but I'm having trouble finding a way to save sentences defined in automations or intent scripts. Are there any options for saving them as input text or viewing them elsewhere so I can use them further?

quaint lake
#

Not sure I understand the ask. Save the sentence when/where, for what purpose?

#

And do you mean the literal sentence definition, or the spoken sentence by the user?

thorny kelp
#

You can see sentences in debug window for your pipeline.. IDK why you want to save that?

queen flame
#

I just found that way now: "{{ trigger.sentence }}"

#

But, I see it's hard to implement in intent script more than automations

quaint lake
#

Not sure what you would need trigger.sentence for in terms of an automation or intent script, usually what you care about in those are the slots

queen flame
#

That's what I was trying"

# config/sutom_sentences/en/LLMs.yaml
language: "en"
intents:
  General:
    data:
      - sentences:
        - Tell me a poem [jarvis]
        - Tell me a bedtime story [jarvis]
        
  Weather:
    data:
    - sentences:
        - weather
        - weather {days}
        - how is the weather [on]
        - how the weather will be
        - how the weather will be [on] {days}
        - weather [for] {days}
        - will (the weather|it) rain [on] {days}
        - should I bring an umbrella {days}
        - should I bring an umbrella        

lists:
  days:
    - "today"
    - "tomorrow"
    - "after tomorrow"
    - "sunday"
    - "monday"
    - "tuesday"
    - "wednesday"
    - "thursday"
    - "friday"
    - "saturday"
    - ""
# configuration.yaml
intent_script:
  General:
    action: 
      - service: conversation.process
        data_template:
          text: "{{ trigger.sentence }}"  # Assuming `text` is the spoken sentence passed to the intent
          agent_id: conversation.llama3_2_1b
          conversation_id: general
        response_variable: response_text
    speech:
      text: "{{ response_text.response.speech.plain.speech | string }}"
  Weather:
    action: 
      - service: conversation.process
        data_template:
          text: "{{ trigger.sentence }}"
          agent_id: conversation.google_generative_ai
          conversation_id: weather
        response_variable: weather
    speech:
      text: "{{ weather.response.speech.plain.speech | string }}"
quaint lake
#

Hmm not sure if I would trust an AI for weather unless I knew for certain it was asking for real time info relevant to my location. Most of the time that is not the case, the AI will just hallucinate an answer lol

#

Also these are probably things better handled by just a direct conversation agent to the AI instead of intent scripts

#

But I mean the above technically would work I think

queen flame
#

This is an alternative solution I am trying for some sentences to use AI as I can't use a LLM with full control for Assist cause it takes a lot of time which is very slow, but if the Local LLM is set without control it works normally.

#

It works with automations only, but didn't work with the intent script till now!

#

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/conversation/default_agent.py", line 881, in _load_intents
    intents = Intents.from_dict(intents_dict)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/hassil/intents.py", line 309, in from_dict
    if list_dict.get("wildcard", False)
       ^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'get'
quaint lake
#

your list is a bit malformed

#

it should be:

lists:
  days:
    values:
      - "monday"
      - "tuesday"
queen flame
#

OMG! I actually forgot it😅 thanks, will test now👍

#
Logger: homeassistant.helpers.template
Source: helpers/template.py:2748
First occurred: 10:46:02 PM (1 occurrences)
Last logged: 10:46:02 PM

Template variable error: 'trigger' is undefined when rendering '{{ trigger.sentence }}'
quaint lake
#

it's because trigger isn't a slot in intent scripts, that's only in automations.

queen flame
#

then how to define it in the intent scripts?

#

it works in automations: {{ trigger.sentence }}

quaint lake
#

Not sure, I've never had an instance where the entire sentence would be parsed in an intent script :/

#

Might be _intent.rawInput from what I see doing a quick google search

#

either that or possibly intent_input from what debug shows.

queen flame
#

Yes, intent_input right, I just saw it now

#

So, shall I put it instead of {{ trigger.sentence }}? {{ intent_input }}

queen flame
#

I got this now after replacing {{ trigger.sentence }} with intent_input:

Logger: homeassistant.helpers.template
Source: helpers/template.py:2748
First occurred: 12:56:02 AM (2 occurrences)
Last logged: 12:58:01 AM

Template variable error: 'weather' is undefined when rendering '{{ weather.response.speech.plain.speech | string }}'
Template variable error: 'response_text' is undefined when rendering '{{ response_text.response.speech.plain.speech | string }}'
#

It seems now to be something with the response variable

quaint lake
#

Something like this works for me:

action:
  - service: calendar.get_events
    data:
      end_date_time: >-
        {{ as_timestamp(now() + timedelta(days=7)) | timestamp_custom('%Y-%m-%d
        00:00:00', True) }}
    target:
      entity_id: calendar.family
    response_variable: result
  - stop: ""
    response_variable: result

speech:
  text: "{{ action_response }}"
queen flame
#

But, that's something else...I am talking about using conversation process

quaint lake
#

Yeah sub that in

#

This is the general structure for handling a response from a service call

queen flame