Thursday, May 22, 2025

#1070 - OIC invoking OCI AI Language Service

Looks interesting, so let's try it out. OCI AI Language Service provides a lot of cool functionality, including - 

  • Translation
  • PII Detection
  • PII Masking
  • Sentiment Analysis
First port of call is the AI Language docs

I get the endpoint and then create the connection in OIC - here I go to the API doc.



Now to OIC - 
Check out the post from my esteemed colleague, Harris Q. for details on the new security policy - OCI Service Invocation.
Let's start off with Translation.

Translation



The integration is simple - 

I define an "output" variable in the AssignVars action. This is then used in the final response map.
So let's test this...

The text doesn't have the same ring in German. "I can't go on, I must go on" is from Samuel Beckett's novel "The Unnamable". As we say in Ireland - a great auld read!

Now to PII.

PII Detection and Masking



As you can see, the OCI AI Language service can be used to identify such.
Here is my integration, augmented with the PII check - 

The invoke is configured as follows - 
As you can see, the response contains an array, documents, which, in turn, contains an array, entities. I parse these and assign to an output variable.

Let's test it...

The Response - {
  "response" : "The following PII fields were found:   -  PII Field/Value CREDIT_DEBIT_NUMBER/123456781234  -  PII Field/Value SSN_OR_TAXPAYER/1234-1234-1234"
}

Let's mask them - 

let's look at the response, before seeing how I configured this - 
The invoke configuration is as follows -

Request Payload - 

Request Payload - 
{ "documents" : [ { "languageCode" : "en", "key" : "1", "text" : "My credit card number is 123456781234 and my SSN is 1234-1234-1234 and I live in Bavaria" } ], "masking" : { "ALL" : { "mode" : "MASK", "isUnmaskedFromEnd" : true, "leaveCharactersUnmasked" : 4 } } }

Response Payload - 

{
  "documents": [{
    "key": "1",
    "entities": [{
      "id": "1",
      "offset": 25,
      "length": 12,
      "type": "CREDIT_DEBIT_NUMBER",
      "text": "123456781234",
      "score": 0.9921220541000366,
      "isCustom": false
    }, {
      "id": "2",
      "offset": 49,
      "length": 14,
      "type": "SSN_OR_TAXPAYER",
      "text": "1234-1234-1234",
      "score": 0.9399408102035522,
      "isCustom": false
    }],
    "languageCode": "en",
    "maskedText": "My credit card number is ********1234 and my SSN **********1234. I live in Bavaria and Germany"
  }],
  "errors": ["1", "1"]
}

Check out this page for info on PII and api payload examples.

Now let's move on to Sentiment Analysis.

Sentiment Analysis



Just in case the screenshot is too small - the request text is - 

"Your service is abysmal. I waited 3 weeks for delivery promised within 24 hours. However, the iBike you delivered is awesome"

The response is - 

{
  "response" : "Analysis basis: ASPECT - service / Negative - iBike / Positive"
}
Sentiment analysis can be done on 2 levels, either sentence based or aspect based. 2 aspects were identified in my input text -
  • the service the customer experienced - negative
  • the product, iBike, the customer received - positive
Net, net - service was crap, I had to wait 3 weeks for delivery, but when it arrived, Wow, that iBike is awesome.

The OCI Language invoke for this was configured as follows - 


As you can see, I then did some response parsing to get the result into the format I wanted.

Summa Summarum

OCI AI Language Service is another useful tool you can leverage in your process automations, and, as I hope you have seen, it's a breeze with OIC.






























 















 

No comments: