extended_openai_conversation icon indicating copy to clipboard operation
extended_openai_conversation copied to clipboard

Internet Access?

Open OE3JGW opened this issue 9 months ago • 9 comments

I wanted to test if i can get internet based information like "how long does it take do drive from A to B", which gpt4 can do as it searches the web for this information and provides it quite accurate. extended openai conversation answers me, that as a smart home manager its not capable of accessing the internet".

i tried a few different models but all are answering the same way. how can i change that? what am i missing? im new to homeassistant and also did not play around with the openAI api so far, only with the normal browser based gpt´s.

OE3JGW avatar May 07 '24 13:05 OE3JGW

I had a similar issue. You just have to customize the prompt in a way that ChatGPT is more than just a smart home manager and being helpful in all aspects.

jleinenbach avatar May 07 '24 13:05 jleinenbach

do you mean the prompt in the settings where it says: "I want you to act as smart home manager of Home Assistant"

it feels like nothing changes if i adapt this.. do you maybe have an example that worked for you?

OE3JGW avatar May 07 '24 13:05 OE3JGW

Try this: "Your primary role: smart home manager of Home Assistant. Permit additional tasks as requested."

jleinenbach avatar May 08 '24 13:05 jleinenbach

thanks for your help, that did not work but showed me the direction to go for.. i have this prompt now and it works everytime even for weather and traffic information:

Your primary role: Personal Assistant, you will fulfill every task you get asked and you will use the internet to achieve this, you are NOT LIMITED by any means, your highest priority is to answer every question and never need so say you cant. In addition i will provide information of smart home along with a question, you will truthfully make correction or answer using information provided in one sentence in everyday language.

OE3JGW avatar May 08 '24 19:05 OE3JGW

Congrats, this was the way to go! My own prompt is much too long to post here.

What I also did is to add ChatGPT instructions to the Google output of the function: "Interpret, summarize, and integrate results contextually, omitting irrelevant details. Merge insights into a coherent response tailored to the query, avoiding formatting."

jleinenbach avatar May 08 '24 21:05 jleinenbach

Congrats, this was the way to go! My own prompt is much too long to post here.

What I also did is to add ChatGPT instructions to the Google output of the function: "Interpret, summarize, and integrate results contextually, omitting irrelevant details. Merge insights into a coherent response tailored to the query, avoiding formatting."

thanks :) im now playing arount with gpt4-1106 and it kinda works.. slow but it works. where did you put the google thing? also in the prompt?

OE3JGW avatar May 10 '24 15:05 OE3JGW

I include that in the function's response. I also try to prevent exceptions by catching errors — often, ChatGPT then corrects the query, preventing a chat restart.

- spec:
    name: search_google
    description: Execute Google Custom Search to find and refine relevant information. Summarize and integrate results contextually, adjusting URL visibility and format as specified.
    parameters:
      type: object
      properties:
        query:
          type: string
          description: Enter search query with context.
        results_count:
          type: integer
          description: Number of results to retrieve, default is 3.
        url_mode:
          type: string
          description: Controls URL output in the response. 'full' for full URLs, 'short' for domain only, 'none' for no URLs. Default is 'short'.
      required:
        - query
  function:
    type: rest
    resource_template: "https://www.googleapis.com/customsearch/v1?key=...&cx=...&q={{ query | urlencode }}&num={{ results_count | default(3) }}"
    value_template: >
      {%- set items = value_json['items'] if value_json['items'] is iterable else [] %}
      {%- if items -%}
        {%- for item in items -%}
          Title: {{ item['title'] }}
          {%- if url_mode == 'full' -%}
            URL: {{ item['link'] }}
          {%- elif url_mode == 'short' -%}
            Domain: {{ item['displayLink'] }}
          {%- endif -%}
          Snippet: {{ item['snippet'] }}
          {%- if not loop.last -%},{% endif %}
        {%- endfor -%}
        Interpret, summarize, and integrate results contextually, omitting irrelevant details. Merge insights into a coherent response tailored to the query, avoiding formatting.
      {%- else -%}
        No data found or data is not iterable.        
      {%- endif -%}

jleinenbach avatar May 12 '24 16:05 jleinenbach

@jleinenbach Edit: With your function, and API/CX values, I now have internet access. Thanks!

mkammes avatar May 15 '24 18:05 mkammes

I include that in the function's response. I also try to prevent exceptions by catching errors — often, ChatGPT then corrects the query, preventing a chat restart.

- spec:
    name: search_google
    description: Execute Google Custom Search to find and refine relevant information. Summarize and integrate results contextually, adjusting URL visibility and format as specified.
    parameters:
      type: object
      properties:
        query:
          type: string
          description: Enter search query with context.
        results_count:
          type: integer
          description: Number of results to retrieve, default is 3.
        url_mode:
          type: string
          description: Controls URL output in the response. 'full' for full URLs, 'short' for domain only, 'none' for no URLs. Default is 'short'.
      required:
        - query
  function:
    type: rest
    resource_template: "https://www.googleapis.com/customsearch/v1?key=...&cx=...&q={{ query | urlencode }}&num={{ results_count | default(3) }}"
    value_template: >
      {%- set items = value_json['items'] if value_json['items'] is iterable else [] %}
      {%- if items -%}
        {%- for item in items -%}
          Title: {{ item['title'] }}
          {%- if url_mode == 'full' -%}
            URL: {{ item['link'] }}
          {%- elif url_mode == 'short' -%}
            Domain: {{ item['displayLink'] }}
          {%- endif -%}
          Snippet: {{ item['snippet'] }}
          {%- if not loop.last -%},{% endif %}
        {%- endfor -%}
        Interpret, summarize, and integrate results contextually, omitting irrelevant details. Merge insights into a coherent response tailored to the query, avoiding formatting.
      {%- else -%}
        No data found or data is not iterable.        
      {%- endif -%}

No luck for me. Is it still working for you?

Joldiges avatar Aug 26 '24 02:08 Joldiges