SharinPix Generative AI Analyse/Extract Image Capabilities

This article demonstrates how to use the latest GPT models to integrate AI capabilities with SharinPix Images.

In the following sections, you will learn:

Information:

The AIConnect feature can be used:

  • In your own Lightning Component development
  • In Flows

Note:

To be able to use this feature, you will need an OpenAI API key.

Prerequisite

To insert your OpenAI API key, you need to go to SharinPix Settings.

After saving your OpenAI API key, you are good to go.

SharinPix Playground

The SharinPix Playground is a tab on the SharinPix App, which allows users to test the Al Image capabilities as shown in the diagram below,

On the SharinPix Playground page, we have a SharinPix Album with prompt and result text boxes. The AI feature is called when the "Extract" button is clicked. The "Extract" button runs the Prompt entered against the image being viewed and updates the Result text box with the response.

AIConnect

The SharinPix package provides the Apex class, AIConnect, which includes methods that integrate OpenAI features. This enables us to execute prompts against the ChatGPT model, using images uploaded to SharinPix.

AIConnect Example

extractImageInfo

global static String extractImageInfo(String imageUrl, String prompt)

  • This method can be used to extract information according to the prompt provided from the image using the imageUrl.

String url = 'https://p.sharinpix.com/image.png';
String prompt = 'Provide the licenses plate number found on the image';
String result = sharinpix.AIConnect.extractImageInfo(url, prompt);
System.debug('result: ' + result);

Using AIConnect in Flows

Using AIConnect in a Screen Flow

AIConnectAutomation is an Apex Invocable method that uses the AIConnect class. This enable the use of the AIConnect feature in flows.

This section demonstrates how to extract information from an image using AI in a flow that invokes the AIConnectAutomation.

  • Create a new Screen Flow
  • Add a screen with options to input an Image' URL and the Prompt from the user.
  • After this screen, add a new Apex Action and search for AIConnectAutomation.
  • Enter the Image URL and Prompt API names from the previous screen in their appropriate value slots. 
  • Below is how your screen flow will appear:

Below is how your screen flow will appear:

  • After sending the request, the answer will be displayed as follows:

Using AIConnect in a Record Triggered Flow

  • Create a new Flow on SharinPix Image creation. The Flow will be triggered every time a SharinPix image is created, and then the response from the AIConnectAutomation will be updated in its Description field.
  • Since a Response is expected from the AIConnect call, you need to check the box:
    • “Include a Run Asynchronously path to access an external system after the original transaction for the triggering record is successfully committed“ as shown below.
  • Create a new resource (Constant) for a static prompt as follows.
  • Add an Apex Action and select the Apex class AIConnectAutomation.
  • Image URL: Enter the image's URL.
  • Prompt: Use the resource 'MyStaticPrompt' created earlier for the prompt.
  • Update the SharinPix Image Object with the response from AIConnectAutomation apex action.

Need help to write your GenAI image prompt?

The visual experts are here to help. Just send an email to [email protected] to get some help so we can explain you how we can deliver services through our experts to assist you on that duty!

0 Comments

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.