Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
stylenone

What is the AI Studio?

Status
colourBlue
titleSince 11 - BETA

...

Info

BETA

Note that the AI Studio components including all ai.* commands are in BETA. This means definitions, interfaces and structures documentation is not final and could change without further notice.

Configure AI Backend (secret)

Before you can start, an AI backend needs to be configured. Depending on your license, by default PIPEFORCE comes with it’s own built-in AI backend which is located in Germany. The secret name of this is openai-default-secret.

If you do not specify otherwise, this AI backend secret is used by default.

But you can switch this default backend or use multiple AI backends in parallel. To do so, you have to configure the credentials and settings for those AI backends as secrets of type secret-text and place a JSON into the secret value which has a structure like this:

...

  • base_url: The base url of the API (requried).

  • model: The AI model to be used (required).

  • api_token: The security token to be used.

  • max_token: The max token to be send (defaults to 800)

  • custom_headers: Key-value pairs to be passed along as HTTP headers on any request.

Connect to OpenAI (ChatGPT)

In case you would like to connect to the OpenAI services for example, you could use these settings in your secret:

Code Block
languagejson
{
  "base_url": "https://api.openai.com/v1",
  "model": "gpt-3.5-turbo",
  "api_token": "your_token",
  "max_token": 800
} 

Send a prompt to the AI - [ai.prompt.send]

One of most generic and simplest use cases is to send a prompt (= a request) to the AI and use the response data in your pipeline. For this you can use the ai.prompt.send command. Here is an example to return some data from the AI:

Code Block
languageyaml
pipeline:
  - ai.prompt.send:
      prompt: |
        Return the names of the 10 biggest cities in the world as JSON array.

This will result in an entry like this in the body:

Code Block
languagejson
[
    "Tokyo",
    "Delhi",
    "Shanghai",
    "Sao Paulo",
    "Mumbai",
    "Beijing",
    "Mexico City",
    "Osaka",
    "Cairo",
    "Dhaka"
]

Adding context data (user data)

You can also apply the prompt on a given context data which is the input data:

Code Block
languageyaml
pipeline:
  - ai.prompt.send:
      input: |
        [
          "Tokyo",
          "Delhi",
          "Shanghai",
          "Sao Paulo",
          "Mumbai",
          "Beijing",
          "Mexico City",
          "Osaka",
          "Cairo",
          "Dhaka"
        ]
      prompt: |
        Order the given list alphabetically.

The result in the body is then:

Code Block
languagejson
[
    "Beijing",
    "Cairo",
    "Delhi",
    "Dhaka",
    "Mexico City",
    "Mumbai",
    "Osaka",
    "Sao Paulo",
    "Shanghai",
    "Tokyo"
]

See another example which converts a given input:

Code Block
languageyaml
pipeline:
  - ai.prompt.send:
      input: |
        <person>
          <firstName>Max</firstName>
          <lastName>Smith</lastName>
          <age>36</age>
        </person>
      prompt: "Convert to JSON"

And the result from the AI in the body will be this:

Code Block
languagejson
{
    "person": {
        "firstName": "Max",
        "lastName": "Smith",
        "age": 36
    }
}

And once more you could apply data privacy filters for example:

Code Block
languageyaml
pipeline:
  - ai.prompt.send:
      input: |
        {
          "person": {
            "firstName": "Max",
            "lastName": "Smith",
            "age": 36
          }
        }
      prompt: |
          Remove all personal data because of privacy and 
          replace by randomized names and add prefix p_

As a result, a changed JSON comes back:

Code Block
languagejson
{
    "person": {
        "firstName": "p_Alex",
        "lastName": "p_Johnson",
        "age": 48
    }
}

Send multiple messages

In case you need to send multiple messages, you can use the messages parameter like this:

Code Block
languageyaml
pipeline:
  - ai.prompt.send:
      messages:
        - role: system
          content: Tell me a joke based on given user input.
        - role: user
          content: I'm a 28 year old man living in New York.

The result could be like this in the body:

Code Block
Why did the New York man bring a ladder to his job interview? 
Because he wanted to climb the corporate ladder!

If messages and prompt is given, the prompt will be automatically added as message of role system at the very end.

Text-to-Command - [ai.command.detect]

This powerful feature of the AI Studio takes a non-structured text such as an email, a chat message or a PDF document for example, analyses it using AI and then automatically detects and executes the according PIPEFORCE command including its parameters which must be executed in order to take action and fulfill the use request. user’s request.

This can be seen as an ultimative tool to bridge between humans and machines since any generated non-structured text in written and spoken form can start nearly any computer task you can imagine.

Drawio
mVer2
zoom1
simple0
inComment0
custContentId3209920520
pageId3209068546
lbox1
diagramDisplayNameUntitled Diagram-1733754941173.drawio
contentVer1
revision1
baseUrlhttps://logabit.atlassian.net/wiki
diagramNameUntitled Diagram-1733754941173.drawio
pCenter0
width1559.93
links
tbstyle
height517

Here are some examples where this feature could be helpful:

  • Classify and auto-route customer emailsAutomatically forward emails with a summary to the responsible internal team
    Scan any email sent to a given inbox such as info@mycompany.tld for example, find out the intention of the sender, then forward the email to the internal team such as support, sales, … which can handle the request. The AI can find out the type of request, whether it is a support request, an order request, a question regarding an invoice or any other type just by writing an advice to the AI and without any programming. It can also detect and extract all required data such as customerId, invoiceNumber and more from the sender’s email. Furthermore, it can also create a short summary about what the core intent of the sender is to make it easier for the internal team to process the request.

  • Automatically validate and start an internal workflow by email
    Scan any email sent to a given inbox such as invoice@mycompany.tld for example and if this email matches to an existing workflow, extract all variables required for this workflow from the email, start the workflow and pass these variables along with it. For example to start an accounts payable workflow based on an given payable invoice. The AI can validate whether all required data exist and is valid in order to start the workflow.

  • Automatically call endpoints of other systems by email
    Scan any email sent to a given inbox such as info@mycompany.abc .tld for example and if this email is related to a service, offered by a third party system which provides an remote API, call this remote API (for example REST) and pass along parameters extracted from the email. For example create a new ticket on an external ticket system.

Using the command ai.command.detect

In order to integrate Text-to-Command functionality into your automation pipelines, you can use the command ai.command.detect. It will

  1. take a text, for example like an email as input,

  2. will apply the given AI instructions on this text and

  3. finally will select a command to be executed and optionally executes it.

Here is a first example how this could look like in an automation pipeline:

Code Block
languageyaml
body: |
  From: customer@somedomain.tld
  Subject: I have a problem with your product
  Hello,
  I have a big problem with your product and need support.
  My customer id is 123456.
  Cheers, Valued Customer
  
pipeline:
  - ai.command.detect:
      runDetectedCommand: false
      advice:
        intentCandidates:
          - intentId: "forwardToSupport"
            instruction: "Use this intent in case the sender needs product support."
            targetCommand: "mail.send"
            params:
              to:
                value: "support@internal.tld"
              from:
                instruction: "The email address of the sender."
              subject:
                instruction: "Use the subject of the sender's email."
              message:
                instruction: "Use the message of the sender's email."
          - intentId: "forwardToInfo"
            instruction: >
              Use this intent in case the sender's intent could not be detected.
            targetCommand: "mail.send"
            params:
              to:
                value: "info@internal.tld"
              from:
                instruction: "The email address of the sender."
              subject:
                instruction: "Use the subject of the sender's email."
              message:
                instruction: "Use the message of the sender's email."

As you can see in this example, there are two command intents configured:

  • One intent will forward the customer email to the support team (=forwardToSupport) and

  • the other one to the info team in case it is related to any other topic (= forwardToInfo).

Each intent has an instruction in order to instruct the AI about the criteria to select this intent. In case such an intent is selected by AI, there is the targetCommand field defining the name of the command which must be called. In this example this is the mail.send command.

The parameter runDetectedCommand defines whether the command should directly be executed (true) or the intent JSON should be simply returned for further processing (false).

Intent Parameters

The params section on each intent lists the parameters required to call the command. For the mail.send command these are for example the parameters to, from, subject and message. The values of these parameters can be fixed, templated or can be detected by the AI.

All parameter attributes are explained below.

name (optional)

The name of the parameter. Under this name it will be passed to the command.

This attribute is optional. If not set, the params id will be used.

required (optional)

Defines whether this parameter is required. In case it is required and its value is finally missing or cannot be detected by AI, an error is thrown and further execution stops.

The default value is false.

type (optional)

The data type of the parameter such as string, boolean, integer, number.

If different from string and parameter is detected by AI, the AI also tries to convert to this format.

The default value is string.

value (optional)

The value of an intent parameter defines the value to be passed to the command.

This can be a fixed value (literal) or a template. By default the Mustache template syntax can be used which starts with {{ and ends with }}. The variables advice and intent are passed as model context to the template. This way you can access for example settings and values of other parameters after they have been resolved by the AI in order to formulate the final parameter for a command.

See this example to construct a message out of advice parameters using a template:

Code Block
languageyaml
...
targetCommand: "mail.send"
...
params:
  message:
    value: "The customerId is: {{advice.params.customerId}}"
  ...

Here is a more advanced example to pass auto-detected parameters into the command worklow.start as workflow variables using the parameter variables:

Code Block
languageyaml
...
targetCommand: "workflow.start"
...
params:
  variables:
    value:
      customerId: "{{advice.params.customerId}}"
      customerName: "{{advice.params.customerName}}"
  ...

instruction (optional)

For each parameter, an attribute instruction instead of a value can be set. Not both!

In this case the AI will auto-detect the parameter value by reading and applying this instruction on the input and setting the result on the value field automatically.

See this example where the subject parameter for the mail.send command will be auto-detected by AI:

Code Block
languageyaml
...
targetCommand: "mail.send"
...
params:
  subject:
    instruction: "Use the subject from initial sender email"
  ...