Skip to content

Made Google Search enable dependent on Assist availability #141712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 3, 2025

Conversation

IvanLH
Copy link
Contributor

@IvanLH IvanLH commented Mar 29, 2025

Proposed change

Changes the Options form to make Google Search enablement show an error if Assist is also set

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@home-assistant
Copy link

Hey there @tronikos, mind taking a look at this pull request as it has been labeled with an integration (google_generative_ai_conversation) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of google_generative_ai_conversation can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign google_generative_ai_conversation Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@balloob balloob added this to the 2025.4.1 milestone Apr 2, 2025
@Andrerm124
Copy link

Apologies if this is not the right place, but is there a specific reason that we can't use Google Search alongside the Assist API?
The ability to have an AI assistant, that can have up to date factual information, along with controlling your smart home feels like the goal, doesn't it?

@balloob
Copy link
Member

balloob commented Apr 3, 2025

It's a limitation from the Google API.

@balloob balloob merged commit 30e50d2 into home-assistant:dev Apr 3, 2025
34 checks passed
@@ -43,6 +43,9 @@
"prompt": "Instruct how the LLM should respond. This can be a template."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a data_description for enable_google_search_tool mentioning the "No control" requirement?

@tronikos
Copy link
Member

tronikos commented Apr 3, 2025

Apologies if this is not the right place, but is there a specific reason that we can't use Google Search alongside the Assist API? The ability to have an AI assistant, that can have up to date factual information, along with controlling your smart home feels like the goal, doesn't it?

A workaround is to create a separate agent with search tool enabled and create the following automation:

alias: "Assist: Ask Google"
description: ""
triggers:
  - command: ask google {req}
    trigger: conversation
conditions: []
actions:
  - action: conversation.process
    metadata: {}
    data:
      text: "{{ trigger.slots.req }}"
      agent_id: conversation.google_generative_ai_search
    response_variable: resp
  - set_conversation_response: "{{ resp.response.speech.plain.speech }}"
mode: single

Then in your regular agent with assist enabled (either Google Generative AI or local agent) say: "ask Google what's today's tech news?"

@Andrerm124
Copy link

@tronikos Amazing, that's a great idea!

@Andrerm124
Copy link

Just altered one of my other scripts to do this.
Might be a neater solution as it allows the LLM to act on the information returned 🙂

sequence:
  - action: conversation.process
    metadata: {}
    data:
      agent_id: conversation.google_generative_ai_2
      text: "{{ query }}"
    response_variable: result
  - variables:
      result:
        response: "{{ result.response.speech.plain.speech }}"
  - stop: ""
    response_variable: result
alias: "Assist: Search Google"
description: >-
  Search Google for specific real time information. Use this script when you
  need to gather information about a topic that may require up to date
  information. 
fields:
  query:
    selector:
      text: null
    name: Query
    description: The query to search Google for
    required: true

Note: I'll likely tweak the script Description to be better suited

@tronikos
Copy link
Member

tronikos commented Apr 3, 2025

@Andrerm124 Nice! Can you add it to the docs?

@swever826
Copy link

Just altered one of my other scripts to do this.
Might be a neater solution as it allows the LLM to act on the information returned 🙂

sequence:
  - action: conversation.process
    metadata: {}
    data:
      agent_id: conversation.google_generative_ai_2
      text: "{{ query }}"
    response_variable: result
  - variables:
      result:
        response: "{{ result.response.speech.plain.speech }}"
  - stop: ""
    response_variable: result
alias: "Assist: Search Google"
description: >-
  Search Google for specific real time information. Use this script when you
  need to gather information about a topic that may require up to date
  information. 
fields:
  query:
    selector:
      text: null
    name: Query
    description: The query to search Google for
    required: true

Note: I'll likely tweak the script Description to be better suited

Thanks for sharing your script!! I also had a script before this was implemented and I used the Google Custom Search API. Glad that's not needed now, since this implementation gives better results.

I just wanted to share that your script description wasn't enough for the LLM to use the script (at least in my HA) so let me share the description I used in my old script and it seems to work great! I wanted for the LLM to search the web only when truly needed and this is what has worked better for me. Let me know if it helps!

description: >-
  Makes a Google search to answer questions that are completely unrelated with
  the smart home and are exclusively about current events or information in
  real-time like the current president, results of last night's game, release
  dates, etc.

frenck pushed a commit that referenced this pull request Apr 4, 2025
* Made Google Search enable dependent on Assist availability

* Show error instead of rendering again

* Cleanup test code
@frenck frenck mentioned this pull request Apr 4, 2025
frenck added a commit that referenced this pull request Apr 4, 2025
* Fix blocking event loop - daikin (#141442)

* fix blocking event loop

* create ssl_context directly

* update manifest

* update manifest.json

* Made Google Search enable dependent on Assist availability (#141712)

* Made Google Search enable dependent on Assist availability

* Show error instead of rendering again

* Cleanup test code

* Fix humidifier platform for Comelit (#141854)

* Fix humidifier platform for Comelit

* apply review comment

* Bump evohome-async to 1.0.5 (#141871)

bump client to 1.0.5

* Replace "to log into" with "to log in to" in `incomfort` (#142060)

* Replace "to log into" with "to log in to" in `incomfort`

Also fix one missing sentence-casing of "gateway".

* Replace duplicate "data_description" strings with references

* Avoid unnecessary reload in apple_tv reauth flow (#142079)

* Add translation for hassio update entity name (#142090)

* Bump pyenphase to 1.25.5 (#142107)

* Hide broken ZBT-1 config entries on the hardware page (#142110)

* Hide bad ZBT-1 config entries on the hardware page

* Set up the bad config entry in the unit test

* Roll into a list comprehension

* Remove constant changes

* Fix condition in unit test

* Bump pysmhi to 1.0.1 (#142111)

* Avoid logging a warning when replacing an ignored config entry (#142114)

Replacing an ignored config entry with one from the user
flow should not generate a warning. We should only warn
if we are replacing a usable config entry.

Followup to adjust the warning added in #130567
cc @epenet

* Slow down polling in Tesla Fleet (#142130)

* Slow down polling

* Fix tests

* Bump tesla-fleet-api to v1.0.17 (#142131)

bump

* Tado bump to 0.18.11 (#142175)

* Bump to version 0.18.11

* Adding hassfest files

* Add preset mode to SmartThings climate (#142180)

* Add preset mode to SmartThings climate

* Add preset mode to SmartThings climate

* Do not create a HA mediaplayer for the builtin Music Assistant player (#142192)

Do not create a HA mediaplayer for the builtin Music player

* Do not fetch disconnected Home Connect appliances (#142200)

* Do not fetch disconnected Home Connect appliances

* Apply suggestions

Co-authored-by: Martin Hjelmare <[email protected]>

* Update docstring

---------

Co-authored-by: Martin Hjelmare <[email protected]>

* Fix fibaro setup (#142201)

* Fix circular mean by always storing and using the weighted one (#142208)

* Fix circular mean by always storing and using the weighted one

* fix

* Fix test

* Bump pySmartThings to 3.0.2 (#142257)

Co-authored-by: Robert Resch <[email protected]>

* Update frontend to 20250404.0 (#142274)

* Bump forecast-solar lib to v4.1.0 (#142280)

Co-authored-by: Jan-Philipp Benecke <[email protected]>

* Bump version to 2025.4.1

* Fix skyconnect tests (#142262)

fix tests

* Fix empty actions (#142292)

* Apply fix

* Add tests for alarm button cover lock

* update light

* add number tests

* test select

* add switch tests

* test vacuum

* update lock test

---------

Co-authored-by: Fredrik Erlandsson <[email protected]>
Co-authored-by: Ivan Lopez Hernandez <[email protected]>
Co-authored-by: Simone Chemelli <[email protected]>
Co-authored-by: David Bonnes <[email protected]>
Co-authored-by: Norbert Rittel <[email protected]>
Co-authored-by: Erik Montnemery <[email protected]>
Co-authored-by: Paul Bottein <[email protected]>
Co-authored-by: Arie Catsman <[email protected]>
Co-authored-by: puddly <[email protected]>
Co-authored-by: G Johansson <[email protected]>
Co-authored-by: J. Nick Koston <[email protected]>
Co-authored-by: Brett Adams <[email protected]>
Co-authored-by: Erwin Douna <[email protected]>
Co-authored-by: Joost Lekkerkerker <[email protected]>
Co-authored-by: Marcel van der Veldt <[email protected]>
Co-authored-by: J. Diego Rodríguez Royo <[email protected]>
Co-authored-by: Martin Hjelmare <[email protected]>
Co-authored-by: rappenze <[email protected]>
Co-authored-by: Robert Resch <[email protected]>
Co-authored-by: Bram Kragten <[email protected]>
Co-authored-by: Klaas Schoute <[email protected]>
Co-authored-by: Jan-Philipp Benecke <[email protected]>
Co-authored-by: Josef Zweck <[email protected]>
Co-authored-by: Petro31 <[email protected]>
@ndom91
Copy link

ndom91 commented Apr 5, 2025

Thanks for sharing your workarounds everyone! I've now had a good experience leaving my default OpenAI conversation with Control, and added antoher Google -> Generative AI conversation integration with its control disabled, but web search enabled and the following script (dont forget to expose the script to voice assistants!)

sequence:
  - action: conversation.process
    metadata: {}
    data:
      agent_id: conversation.google_generative_ai
      text: "{{ query }}"
    response_variable: result
  - variables:
      result:
        response: "{{ result.response.speech.plain.speech }}"
  - stop: ""
    response_variable: result
alias: "Assist: Search Google"
description: >-
  Makes a Google search to answer questions that are completely unrelated with
  the smart home and are exclusively about current events or information in
  real-time like the current president, release dates, etc.
fields:
  query:
    selector:
      text: null
    name: Query
    description: The query to search Google for
    required: true

@github-actions github-actions bot locked and limited conversation to collaborators Apr 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants