From 0faea140e2a6c980525c52d3a27199ae75d37773 Mon Sep 17 00:00:00 2001 From: Tim Laing Date: Thu, 1 Aug 2024 15:50:55 +0000 Subject: [PATCH] Add generate content service for OpenAI to match Google AI --- .../openai_conversation.markdown | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/source/_integrations/openai_conversation.markdown b/source/_integrations/openai_conversation.markdown index 95b5ff82af4..1b54129c5ca 100644 --- a/source/_integrations/openai_conversation.markdown +++ b/source/_integrations/openai_conversation.markdown @@ -158,3 +158,50 @@ template: ``` {% endraw %} + +### Service `openai_conversation.generate_content` + +Allows you to ask OpenAI to generate an content based on a prompt. This service +populates [Response Data](/docs/scripts/service-calls#use-templates-to-handle-response-data) +with the response from OpenAI. + +| Service data attribute | Optional | Description | Example | +| ---------------------- | -------- | ------------------------------------------------------- | ---------------- | +| `config_entry` | no | Integration entry ID to use. | | +| `prompt` | no | The text to turn into an image. | Picture of a dog | +| `image_filename` | yes | List of file names for images to include in the prompt. | /tmp/image.jpg | + +{% raw %} +```yaml +service: openai.generate_content +data: + config_entry: abce6b8696a15e107b4bd843de722249 + prompt: >- + Very briefly describe what you see in this image from my doorbell camera. + Your message needs to be short to fit in a phone notification. Don't + describe stationary objects or buildings. + image_filename: + - /tmp/doorbell_snapshot.jpg +response_variable: generated_content +``` +{% endraw %} + +The response data field `text` will contain the generated content. + +Another example with multiple images: + +{% raw %} +```yaml +service: openai.generate_content +data: + prompt: >- + Briefly describe what happened in the following sequence of images + from my driveway camera. + image_filename: + - /tmp/driveway_snapshot1.jpg + - /tmp/driveway_snapshot2.jpg + - /tmp/driveway_snapshot3.jpg + - /tmp/driveway_snapshot4.jpg +response_variable: generated_content +``` +{% endraw %} \ No newline at end of file