jekalmin / extended_openai_conversation

Home Assistant custom component of conversation agent. It uses OpenAI to control your devices.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unexpected error during intent recognition

HelloMorningStar opened this issue · comments

This could be related to how the function handles the query parameter or interacts with the Google Custom Search API. The problem might be within the parameter parsing, the construction of the request to the Google API, or how the response is being processed. Since the function appears to be correctly set up to send a request to the Google API and format the response, the issue might lie in how the input query is being recognized and passed to the function. It's possible that further investigation into the handling of the query parameter and its integration into the resource template URL might be needed.

- spec:
    name: search_google
    description: Search Google using the Custom Search API.
    parameters:
      type: object
      properties:
        query:
          type: string
          description: The search query.
      required:
      - query
      ......
      

Check the logs, the error will most likely be there

Is there any error logs?
Also, I'm looking forward how full function looks (including spec and function).

When I use the example function, then I get this error, too.

First, follow the following instructions and replace the KEY- and CX-values that are part of the URL:
https://developers.google.com/custom-search/v1/using_rest
https://developers.google.com/custom-search/v1/introduction#identify_your_application_to_google_with_api_key

Second, there is a mistake which comes from the Google documentation. ":omuauf_lfve" needs to be removed from the URL.

Third: For some reasons, it is not possible to iterate the value_json.items. I don't know if something changed and if it worked before, but I used a ChatGPT workaround instead:

- spec:
    name: search_google
    description: Search Google using the Custom Search API. Provide links to the search results only upon request.
    parameters:
      type: object
      properties:
        query:
          type: string
          description: The search query.
      required:
      - query
  function:
    type: rest
    resource_template: "https://www.googleapis.com/customsearch/v1?key=YOUR_API_KEY&cx=YOUR_CUSTOM_GOOGLE_SEARCH_ENGINE_CX_CODE&num=3&q={{ query | urlencode }}"
    value_template: >-
      Process the following JSON string. Each item within it contains a title, a snippet, and an associated URL. Generate a summary from each item's title and snippet. Provide the associated URL upon request only.
      {{value_json}}

This issue should be related:
#201