jekalmin / extended_openai_conversation

Home Assistant custom component of conversation agent. It uses OpenAI to control your devices.
834 stars 108 forks source link

[#140] Make local image accessible in `query_image` service #154

Closed jekalmin closed 4 months ago

jekalmin commented 4 months ago

Issue

Objective

Example

LowKey88 commented 4 months ago

Tested, but the messages seem called the id,etc, intead of content.

Here my yaml :

  • service: extended_openai_conversation.query_image data: images: url: /xx/xx/xxx/xxx.jpg max_tokens: 300 config_entry: xx prompt: >- Very briefly describe what you see in this image from camera. Your message needs to be short to fit in a phone notification. Don't describe stationary objects. model: gpt-4-vision-preview response_variable: ai_description
  • service: telegram_bot.send_message data_template: message: "AI description: {{ ai_description }}" enabled: true
  • service: tts.cloud_say target: entity_id: media_player.studio_google_nest data: message: "{{ ai_description }}" cache: true enabled: true

Output on Telegram

AI description: {'id': 'chatcmpl-xxx', 'choices': {'finish_reason': 'stop', 'index': 0, 'message': {'content': 'No people or moving objects in view; only room interior visible.', 'role': 'assistant', 'function_call': None, 'tool_calls': None}}, 'created': 1708535671, 'model': 'gpt-4-1106-vision-preview', 'object': 'chat.completion', 'systemfingerprint': None, 'usage': {'completiontokens': 13, 'prompttokens': 463, 'totaltokens': 476}}

jekalmin commented 4 months ago

messages seem called the id,etc, intead of content

Could you elaborate more? You need to use {{ ai_description.choices[0].message.content }} to get response message.

LowKey88 commented 4 months ago

messages seem called the id,etc, intead of content

Could you elaborate more? You need to use {{ ai_description.choices[0].message.content }} to get response message.

Awesome, thanks for the code. I've made the updates and used it as suggested. It now outputs only the response message.

Excellent! :)