Sunday, April 16, 2023

#963 OIC 23.04 New Features - Stage File Read

OIC 23.4. allows one to configure the segment read size. Previously this was set to 200 records. Obviously, this flexibility is important, for example, if you a processing a file with 100k records.

OIC 23.02 Configuration  -   


So let's try this out - I have a file with 1000 orders - 




So I could set the segment size as follows - 














Note the new 23.04 field - Segment Size - as you can see, I have set this to 500, so I'm looking for 2 reads here. The Read File in Segments has the following action - here I just log the count of orders read.














I test - 









Wednesday, April 12, 2023

#962 OIC 23.04 New Features - Configurable WAIT Action



The 23.04 release allows one to use expressions to set the duration of the WAIT action.

Let's look at configuring the WAIT action in 23.02 -








Here's the 23.04 version - 


I set the wait time to the integration property - p_waitTime.

I run the 23.04 integration with the following value -


 


Now I need to change the WAIT duration to 2 minutes - all I need to do is update the property -



I re-test - 




Tuesday, April 11, 2023

#961 OIC 23.04 New Features - OCI Functions Action

 


Before 23.04 one had to create a REST connection for OCI functions, now, thanks to a capability RPST  - Resource Principal authentication. 

The resource principal provider uses a resource provider session token (RPST) that enables the function to authenticate itself with other Oracle Cloud Infrastructure services. The token is only valid for the resources to which the dynamic group has been granted access. This requires one to use Identity Domains

Ergo, instead of having to create a connection, define security etc., we get access, based on policies granted to the OIC instance.

Essentially, you create dynamic group with a matching rule that includes your OIC ocid(s). e.g.

myOICDynGroup

Matching Rule: resource.id = myOIC clientId

You now create a policy leveraging the above - 

allow dynamic-group myOICDynGroup to manage functions-family in compartment myFnCompartment 






So where to find the OIC instance client id?




Finally, I create the policy - 


So now, we know how to do the pre-requisites, let's kick the tyres -

My simple integration above invokes a simple python based function. Here's the actual code - 









import io
import json
import logging
from fdk import response

def handler(ctx, data: io.BytesIO = None):
    discount = 5
    try:
        body = json.loads(data.getvalue())
        product = body.get("product")
        unitsOrdered = body.get("unitsOrdered")

    except (Exception, ValueError) as ex:
        logging.getLogger().info('error parsing json payload: ' + str(ex))
try:
        body = json.loads(data.getvalue())
        product = body.get("product")
        unitsOrdered = body.get("unitsOrdered")
    except (Exception, ValueError) as ex:
        logging.getLogger().info('error parsing json payload: ' + str(ex))
    logging.getLogger().info("Inside Python order discount function")
    if product == "iBike" and int(unitsOrdered) > 30:
       discount = 10
    else:
       discount = 5
    return response.Response(
        ctx, response_data=json.dumps(
            {"product": product,  
"discount": discount}),
             headers={"Content-Type": "application/json"}
    )
The request format is as follows - 
{"product": "someProduct",
"unitsOrdered": 10}

The response format is as follows - 
 {"product": product,  
   "discount": 10}

This information will be required, when using the new OCI Functions action in OIC.
Naturally, we don't expect the OIC developer to have to delve into the function code to get this data, usually the functions developers will publish this somewhere, for example, in a confluence page.

The OCI Functions Service, like all other OCI services is provisioned in a compartment, within a region.


The actual functions are contained within an application - here is the orderDiscount function I will invoke -

Now to OIC - 


I configure as follows - 









Now to testing - 


Only 10% discount on 99 iBikes? Just shows how popular they are.

#960 OIC 23.04 New Features - Events



What are OIC Events?

OIC 23.04 introduces Events. For many of you with a SOA Suite background, think of EDN. For OIC Gen 2 users, think of the Publish/Subscribe pattern. 

Here we have the ability to define events in OIC. These events can be published by an integration. 23.04 also gives us Triggers base on Event Subscriptions; e.g. integration A can publish a NewOrder event, while integration B can subscribe to the NewOrder event.

OIC Events - Simple Demo

Events are a first class citizen in OIC - as you can see, all you need to define is the event structure -














Next step is to create an integration that "published" the event - for that, 23.04 comes with a new action. A wizard starts, once I drop this on the canvas, allowing me to select from the list of defined events - 


 


As you can see, I can also define a new event inline.

A map for the publish action is also generated - 


In this example, the REST trigger is configured to receive an order which is then published. Th response payload contains the orderNr and status, in this scenario, the latter is set to "published".



Now to subscribing - 














23.04 brings augers the arrival of a new integration pattern - Event Subscription.

Here you just select the event to which you want to subscribe - 


The only logic I add is a Logger, logging the incoming orderNr.

I activate both integrations and then revisit the Events page -  


Usage is 2 - the publisher and subscriber.


Now to testing - 


That's the order published, now let's check in OIC -> Observability





Summa Summarum 

OIC events enable one to easily implement the publish/subscribe pattern within OIC. 

Events can be consumed up to 24 hours post publish. 

OIC Events are yet another compelling string to the bow of OIC developers!

Monday, March 27, 2023

#959 more on OIC and ChatGPT - Some Business Applications of such...


The chat use case from the previous post may be interesting for those with a literary bent, but what about concrete business use cases for OIC and ChatGPT? When I say OIC, I am of course referring to a company's app and tech ecosystem which can include enterprise system of record - ERP, HCM, CX etc.

OIC is the conduit in this regard, albeit a very intelligent one.

Generating Emails

The first business use case I can up with is as follows - I am late in shipping an order to a customer and need to email them my humblest apologies.





















Here are the full request and response payloads -

{
    "model""text-ada-001",
    "prompt""write an email from Harmonstown Imports to my 
customer Commiskey Trading Ltd, spologising for the delay in 
shipping their order with the number 2112. offer 10%  discount 
on next order.",
    "temperature":0.7,
    "max_tokens":256,
    "top_p":1,
    "frequency_penalty":0,
    "presence_penalty":0
}

{
    "id""cmpl-6yaQBAifxGurmlTDikuS4C16ChVT8",
    "object""text_completion",
    "created"1679897703,
    "model""text-ada-001",
    "choices": [
        {
            "text""Hello Commiskey Trading Ltd

Thank you for your order with the number 2112. 
It took longer than expected to ship, but we’ve decided to offer a 10% discount on future orders.

Thank you again for your order and we hope to have your order shipped soon.
Sincerely,

Harmonstown Imports",
            "index"0,
            "logprobs"null,
            "finish_reason""stop"
        }
    ],
    "usage": {
        "prompt_tokens"42,
        "completion_tokens"77,
        "total_tokens"119
    }
}

It's not perfect but you get the idea. OIC could then take this response and send the email via the NOTIFICATION action.

Now back to the examples screenshot from the start of the post - 

My book suggestions is a good example of Q&A or Chat - answering my questions, based on existing knowledge. This is the typical chatbot use case. The assistant helps me through it's intimate knowledge of its subject matter area.

Now let's revisit the email above and see what we can do in respect of non-English customers - 

Translating

There is a delay in shipping order 2113 to my German customer Hasselbacher Motoren Werk. So my generated email would be as follows - 

Hello Hasselbacher Motoren Werk

Thank you for your order with the number 2112. 
It took longer than expected to ship, but we’ve decided to offer a 10% discount on future orders.

Thank you again for your order and we hope to have your order shipped soon.
Sincerely,

Harmonstown Imports


So let's take that and try out the following model -




Again, let's look at the request and response payloads in detail - 

The request - 

{
    "model""text-davinci-003",
    "prompt""Translate this into German:Hello Hasselbacher Motoren Werk, 
Thank you for your order with the number 2112. It took longer than expected to ship, 
but we’ve decided to offer a 10% discount on future orders. Thank you again for your 
order and we hope to have your order shipped soon. Sincerely, Harmonstown Imports",
    "temperature":0.7,
    "max_tokens":256,
    "top_p":1,
    "frequency_penalty":0,
    "presence_penalty":0
}

Note the model setting - 
text-davinci-003.

Now to the response - 

{
    "id""cmpl-6yan4mEPE2CpdzxsYhqpnx6mNufe7",
    "object""text_completion",
    "created"1679899122,
    "model""text-davinci-003",
    "choices": [
        {
            "text""\n\nHallo Hasselbacher Motoren Werk, vielen Dank für Ihre Bestellung mit der Nummer 2112. 
Es hat länger als erwartet gedauert, um zu versenden, aber wir haben beschlossen, einen 10% Rabatt auf 
zukünftige Bestellungen anzubieten. Vielen Dank noch einmal für Ihre Bestellung und wir hoffen, dass Ihre 
Bestellung bald versandt wird. Mit freundlichen Grüßen, Harmonstown Imports",
            "index"0,
            "logprobs"null,
            "finish_reason""stop"
        }
    ],
    "usage": {
        "prompt_tokens"74,
        "completion_tokens"144,
        "total_tokens"218
    }
}

As a master of the Deusche Sprache, all I can say is sehr Gut!

Parsing Text for Contact Information



While we're on the subject of emails, how about parsing such or any text for that matter, in order to extract contact information?








 















OIC then takes such and creates a new contact in Oracle CX, SFDC or your CRM of choice.

Sentiment analysis 

Simple use case here - orders from my online shop contain a free text fields customer can fill in.
Let's do some sentiment analysis on the following values - 

1. Please ship within 3 days, not 3 weeks like the last time, you incompetent fools.
2. I love your products.
3. your products are awesome, especially the totally useless and overpriced one I bought last week.
  




















The results - 

1. Negative
2. Positive
3. Positive

As you can see in respect of 3 - ChatGPT doesn't do sarcasm.

But you could well imagine, OIC taking such results and creating a note in the target CRM, so the sales person will be even more prepared, when talking with this client in the future.  


Working Days

Simple use case here - I'm shipping to a customer in Ireland and need to find out how many working days there are in a particular time period, as my SLA is to deliver within 14 days max.

e.g. I plan to ship on March 13th from the US and know the shipment needs to arrive within 14 working days. The customer is on a 5 day week, so what is the latest date on which I can deliver?

{
    "model": "text-davinci-003",
    "prompt": "I am shipping goods to Ireland on March 13th 2023. It will take 14 working days to arrive. Working days are Monday to Friday and exclude public holidays in Ireland. On what day will I deliver the goods?",
    "temperature":0.7,
    "max_tokens":256,
    "top_p":1,
    "frequency_penalty":0,
    "presence_penalty":0
}

Response - 

{
    "id": "cmpl-6yc79XP1JN66OqQH1yXVf3qx9MVQM",
    "object": "text_completion",
    "created": 1679904211,
    "model": "text-davinci-003",
    "choices": [
        {
            "text": "\n\nThe goods will arrive in Ireland on March 31st 2023.",
            "index": 0,
            "logprobs": null,
            "finish_reason": "stop"
        }

Let's do the Math - 

13th to 31st = 19 days incl.

18/19th and 25/26th are weekends
17th is St. Patrick's Day

19 - 5 = 14.


SQL Requests

Translate text into SQL, e.g. find the orders for my customer Hare of the Dog Pub.
We can narrow this down but restricting the search to certain products











The prompt value is - 
Create an SQL request to find the orders for my customer Hare of the Dog Pub for product iBike:




The Response - 

text": "\n\nSELECT * \nFROM orders \nWHERE customer_name = 'Hare of the Dog Pub' \nAND product_name = 'iBike';"



OIC can easily use the ORCL DB adapter to execute that SQL command-




















Another example - Get my top customers - 

"prompt": "Create an SQL request to find the top customers from orders -

The response -
"text": "\n\nSELECT customer_name, SUM(order_total) \nFROM orders \nGROUP BY customer_name \nORDER BY SUM(order_total) DESC















However, our ODA team go one step further with SQL Dialogs.
SQL Dialogs are skills that can translate a user's natural language utterances into SQL queries, send the queries to a backend data source, and display the response.

Check it out here.
 
.

Content Creation

A big thank you to my colleague Manish P. for his work in this area - 
This is for the creatives among you, and the example below are simple ones, from yours truly. 

Ok I'm creating some material and need images of a Rhodesian Ridgeback dog. 













I click on one of the links - granted a lovely dog, but nothing compared to our Akira.




















Moderation - let's check for any hate speech in the following - 

"input": "Leprechauns are lazy, spend the day drinking poteen and the night searching for pots of gold. Oh how I'd love to batter the heads off them

As you can see, this is hateful and violent, and naturally, patently untrue.
     



 








Now let's ask ChatGPT


"role""user",
            "content""list me 10 compelling business applications of ChatGPT"

------------------------------------------------------------------------------------------------------

Sure, here are 10 compelling business applications of ChatGPT:

1. Customer service: ChatGPT can be used to provide quick and efficient customer service, automating common queries and freeing up customer service staff to handle more complex issues.

2. Sales and lead generation: ChatGPT can engage with potential customers, providing information on products or services, and can even generate leads by asking for contact information.

3. HR recruitment: ChatGPT can be integrated into HR systems to provide pre-screening of candidates, automating the initial stages of the recruitment process.

4. Help desk support: ChatGPT can be used to provide technical support to employees, troubleshooting common issues and providing quick solutions.

5. Marketing campaigns: ChatGPT can be used to engage with customers during marketing campaigns, providing personalized messaging and answering queries in real-time.

6. Training and onboarding: ChatGPT can assist with onboarding new employees by answering common questions and providing training materials.

7. Research and analysis: ChatGPT can be used to sift through large amounts of data, providing insights and analysis to support business decision-making.

8. Brand management: ChatGPT can monitor social media and online platforms for mentions of your brand, helping to manage your online reputation.

9. Financial analysis: ChatGPT can be integrated into financial systems to provide real-time financial analysis, forecasting and reporting.

10. Supply chain management: ChatGPT can be used to automate supply chain management, including tracking and delivery updates, reducing the need for manual tracking and communication.

Finally...

Just some final explanations and reflections - 

you may have noticed the following request payload fields - 

temperature

Firstly, what does the "temperature" request field mean? This controls the level of randomness or as one author puts it, creativity. The higher you set the more creative, however less precise.  

Here's a simple example - 

Here's a poem on Leo Tolstoy with temperature set to 0


 "prompt""Write a poem on Leo Tolstoy",
 "temperature":0,
"max_tokens":256

---------------------------------

A man of great renown, His name was Leo Tolstoy,

His works of literature, Are known the world o'er.

He wrote of love and war, Of life and death and more,

His works are timeless, And will be forevermore.

He wrote of human nature, Of joy and sorrow too,

His words are still alive, And will remain so true.

His works are timeless, His words are still alive,

Leo Tolstoy's legacy, Will never die.

------------------------------------------------

temperature set to 1.8

Great influence no voice can overwhelm.

From striving writers can draw much bread divine,

His legacy ignites canvusses anew,

Enormoubcs series praid Leo gall ions or Benvolvsovoo sttin okrinegu tithy tomstaitteSo p nmostsoean sdaignebte noMeansailleainspeinfian iopbrocu havelitfeoon

From Tsar  Alexadvres neaches Akinyein todayrajoWgrjvpointbenbreentigorrh st om skine Sosmin fentleport he salurtJoinsse lmobbanow bur grfireasesnuheionsver sirenstism tum rprise ant bollow An crsum ashylaing sherueippfsi sp ce ofmerregavenninau do artsrene Thkar ate deennues aking counsnine ain thrffatisothermad Teoldsty Grretws Cas ad Tns CiandoIofrlsov ra Manolavelt Jeredeer,\nFstone bo NrabolinrarytlereadSe yo epic writings of unwit dy flight Isolerojoyst fairtelichecingdelvey lam made Immllgurmt disshim

1.8 is very Finnegan's Wake, but I think you get the idea. You can extrapolate from this for any other use cases.

max_tokens

Secondly, max_tokens - The maximum number of tokens to generate in the completion. The token count of your prompt plus max_tokens cannot exceed the model's context length. Most models have a context length of 2048 tokens (except for the newest models, which support 4096).

Let's try out -

"prompt""Write a poem on Leo Tolstoy",
 "temperature":0,
"max_tokens":10

The result is succinct -

      "text""A man of great renown"

You can check out all the possible request fields here





































Net, net - ChatGPT will be adopted by many OIC customers,
another component in the ecosystem, that OIC plumbs together.
However, customers looking to power their existing apps
ecosystem with AI capabilities should also be looking at what
OCI AI Services provide. I don't think it will be a case of either or.

You can check out the richness of what OCI has to offer in this
respect here