Writing an intent that passes a string variable to Google Gen AI

I have a Voice Assistant using a local [Ollama] LLM through acon96/home-llm. I would like the LLM to understand “Ask Google blah”; this should cause it pass “blah” to the Google Gen AI integration (which I also have installed) and speak the response.

acon96/home-llm lets the LLM know about all of the Home Assistant intents as tools, so I think what I need to do is write a custom intent which takes a string parameter, passes that string parameter to google_generative_ai_conversation.generate_content as its prompt variable and then passes the string returned by google_generative_ai_conversation.generate_content back to speech as the text variable.

Questions:

  • does this seem right, or is there a simpler way (it doesn’t seem as though it should be this complex)?
  • how does one create a custom intent?
  • how would I call google_generative_ai_conversation.generate_content with prompt as a parameter, rather than hard-coding it?

I’ve read the documentation (e.g. concerning scripts, their syntax and intent_scripts) and posts such as this one which seem similar, but I just can’t figure out how to put it all together.

Answering my own question, intents, and a fair amount of the stuff that a web search returns for this question, is well out of date.

The answer was that this could be a single script, generated mostly in UI mode of the script generator (only setting the prompt variable to be passed to google_generative_ai_conversation.generate_content needed YAML mode) and the final generated script looked like this:

alias: Ask Google
description: ""
triggers:
  - trigger: conversation
    command:
      - "[Please] ask Google {query}"
      - "[Please] [Google] search [for] {query}"
conditions: []
actions:
  - action: google_generative_ai_conversation.generate_content
    metadata: {}
    data:
      prompt: "{{ trigger.details.query.text }}"
    response_variable: generated_response
  - set_conversation_response: "Google said: {{ generated_response.text }}"
mode: single
2 Likes