#assist using different logic based on first "keyword"

1 messages ยท Page 1 of 1 (latest)

lost nest
#

Hi.
I just tested Ollama 3.2 in HA.
Is it possible to have differents behaviour depending on the first "word", if recognized.
In fact i would like to "talk" to differents LLM.
I mean, i would like to start all my orders with a "target".
Something like:

  • "Universalis who is james bond" => use conversation agent "LLAMA3.2_universalis" without first word ( "universalis" ๐Ÿ˜‰ ). no extra fancy stuff. No HA actions to be performed. Plain straight question/answer.
  • "Nabu turn off all lights in the kitchen and in the living room" => Use coversation agent "LLAMA3.2" like now without first word. HA action expected.
  • "HA turn on hue light in the kitchen" => use conversatio agent "Home assistant". We expect correct orders ( ?? )
    Thank you.

PS: ... and in order to debug/follow, answers sould start with "Reply from {{ target }}: \n"

rich steeple
#

You can't do it straightforward, but you can do it via intent scripts. Basically your script will have trigger sentence "universalis <command>", and then in script action call conversation.process with that command and output result to speech. Same for nabu.

lost nest
#

Ahhh ๐Ÿ˜‰ Thanks for your help . I will search ๐Ÿ˜‰ ... I'm pretty sure something interesting can be done.
We could even swicth "online" to challange/test/compare ๐Ÿ˜‰

vale finch
#

Iโ€™m doing something similar for music playback. I have a specific llm setup for music playback with a context that describes how to use my search and play scripts.
Any time I start a sentence with โ€˜playโ€™ that automation will trigger. I then do conversation.process with the trigger sentence as llm input. It accesses my scripts and starts playback and I output the response.
Itโ€™s nice because it keeps all that fairly large chunk of music stuff out of my main llm context.

lost nest
#

It is detecting if my sentence start with nabu, but i can't go any further.


talk_with_nabu:
  action:
    - action: conversation.process
      data:
        agent_id: conversation.llama3_2
        text: "hi"
      response_variable: result                     # get action respons
  speech: 
    text: >-
      "yeah baby yeah "

I have hardcoded everything to not have any variables, and it is not working.
I don't find.
As soon as this piece of code is present, if i start any sentence with "nabu", i receive "Unexpected error during intent recognition"

#

conversation.process works fine in "developper->tools.

honest mirage
#

would need to see what it is reporting as the exact error

lost nest
#

In configuration.yaml i have:

conversation:      !include ./configurations/conversation.yaml
intent_script:     !include ./configurations/intent_script.yaml

and files are:

# file: /homeassistant/configurations/conversation.yaml
intents:
  talk_with_nabu:  
    - "nabu {zzcommand}"
    
  talk_with_universalis:
    - "universalis {zzcommand}"

and

# file: /homeassistant/configurations/intent_script.yaml

  talk_with_universalis:
    sequence:
      - service: conversation.process
        data:
          text: "{{zzcommand"
          agent_id: conversation.llama3_2_universalis
        response_variable: _function_result


  talk_with_nabu:
      action:
        - action: conversation.process
          data:
            agent_id: conversation.llama3_2_nabu
            text: "{{zzcommand}}"
          response_variable: result_01
        - stop: ""
          response_variable: result_02
      response_variable: result_03
      speech: 
        text: "yeah baby yeah {{ action_response }} "    
#

...and i just found something: hassil.errors.MissingListError: Missing slot list {zzcommand}

honest mirage
#

your talk with universalis is malformed

#

missing closing }}

#

also in your conversation Yaml you need to add:

lists:
  zzcommand:
    wildcard: true
#

for each of your intents

#

sorry not to each intent, think it has to be added to the conversation.yaml, at the same level of intents

#

my configs are structured a bit differently than yours so not sure if I have the right location ๐Ÿ˜„

lost nest
#

I can't fix syntax errors ... always complaining about something.... I'll move everything to "configuration.yaml" .... just to make sure

#

well . That will be for another day. I started at 3am. it's 4.30 PM.... Enough for today.

#

conversation:
  intents:
    talk_with_nabu: 
      data:
        - sentences:
           - "nabu {zzcommand}"
  lists:
    zzcommand: 
      wildcard: true
      
intent_script:
  talk_with_nabu:
      action:
        - action: conversation.process
          data:
            agent_id: conversation.llama3_2_nabu
            text: "{{zzcommand}}"
          response_variable: result_01
        - stop: ""
          response_variable: result_02
      response_variable: result_03
      speech: 
        text: "yeah baby yeah {{ action_response }} "
     ```
=>

Invalid config for 'conversation' at configuration.yaml, line 40: value should be a string 'conversation->intents->talk_with_nabu->0', got None
Invalid config for 'conversation' at configuration.yaml, line 44: 'lists' is an invalid option for 'conversation', check: conversation->lists

honest mirage
#

Think your sentence stuff might be in the wrong place. Might want to look over the HA docs again and make sure everything is where it should be ๐Ÿ™‚

rich steeple
#

Yes, it is in wrong place. Sentences files aren't included into configuration.yaml - instead they should be placed in custom_sentences/en directory.

lost nest
#

I had also this in mind... ๐Ÿ˜‰ i'll try ๐Ÿ˜‰ ... I'm pretty sure it's the right way to do it. ๐Ÿ˜‰

lost nest
#

i'm getting closer. I just need to figure how to retreive the "action_response" in speech ...

honest mirage
#

Response variable needs to remain the same value i think