Advertisement
-Miura-

Get ChatGPT Response

Sep 26th, 2024
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.49 KB | None | 0 0
  1. alias: Get ChatGPT Response
  2. fields:
  3.   prompt:
  4.     selector:
  5.       text: null
  6.     name: Prompt
  7.     required: true
  8.   language:
  9.     selector:
  10.       select:
  11.         options:
  12.          - nl
  13.     name: Language
  14.     required: true
  15.     default: nl
  16.   instruction:
  17.     selector:
  18.       text: {}
  19.     name: Instruction
  20.     required: false
  21.     default: >-
  22.       You are a voice assistant for Home Assistant. Answer in plain text. Keep
  23.       it simple and to the point.
  24.   model:
  25.     selector:
  26.       select:
  27.         options:
  28.          - chatgpt_3_5_turbo
  29.           - chatgpt_4o
  30.           - gpt_4o_mini
  31.     name: Model
  32.     required: true
  33.     default: chatgpt_3_5_turbo
  34. sequence:
  35.   - variables:
  36.       agent_id: "{{ 'conversation.' + model }}"
  37.       instruction_language: |-
  38.         {% if language == 'nl' %}
  39.           {{ instruction + ' Answer in Dutch.' }}
  40.         {% endif %}
  41.   - metadata: {}
  42.     data:
  43.       value: "{{ instruction_language }}"
  44.     target:
  45.       entity_id: input_text.chat_gpt_instruction
  46.     action: input_text.set_value
  47.   - data:
  48.       agent_id: "{{ agent_id }}"
  49.       language: "{{ language }}"
  50.       text: "{{ prompt }}"
  51.     response_variable: agent
  52.     action: conversation.process
  53.   - variables:
  54.       success: |
  55.        {{ agent.response.response_type == 'action_done' }}
  56.       message: >
  57.         {{ {'success': success, 'message': agent.response.speech.plain.speech}
  58.         }}
  59.   - stop: returning message
  60.     response_variable: message
  61. description: ""
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement