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

































Friday, March 24, 2023

#958 - Invoking ChatGPT from OIC

 


I had to try this out, first step was to create an account - 








Once in, I can try it out - Who was Mikhail Bakunin anyway?















Now how can I do something like this via the api?

Next step - get an api key - 



I already have one - but you get the idea - 



Copy the key for later use.

On to the api docs - 



On to Postman, to check out which models are available - 



I set Authorization at the Collection level - 




This is the one I will use - gpt-3.5-turbo.



This is the api I will call - I'm going to ask for book suggestions for a particular subject area eg. politics.

This brings us to roles - as they will be used in the request body. 

We have the following - system - describes the assistant. I will set this to - You are Niall. you are a well read person with great book suggestions. When answering try to be funny.

Then we have user, the user is going to be asking something.  

Here is the Postman request body - 

{
    "model""gpt-3.5-turbo",
    "messages": [
        {
            "role""system",
            "content""You are Niall. You are a well read person with great book suggestions. When answering try to be funny"
        },
        {
            "role""user",
            "content""I'm looking for books on Politics. What can you suggest?"
        }
    ]
}

Let's execute the request in Postman - 



The full content - "Well, if you're looking for a good laugh, you could always try reading the political news these days. But if you want something more informative, I highly recommend \"The Dictator's Handbook\" by Bruce Bueno de Mesquita and Alastair Smith. It's a great book that breaks down the motivations of political leaders and helps explain why they do the things they do. Plus, it's a lot less depressing than watching cable news all day."

Well I did ask it to be funny!

Now to implementing this in OIC - just a couple of steps - 

Step 1 - Create the connection 



Step 2 - Create a Lookup Table 

Just to make it flexible - 


Step 3 - Create the Integration 
























The Invoke is configured as follows - 


I use the request and response payloads from Postman - I then attend to the mapping - 



Activate and test - 
























The usual suspects - Tolstoy, Dostoyevsky and Gogol. no mention of Ivan Goncharov and his classic, Oblomov, or even Alexander Herzen; but that's it, you should have asked me and not ChatGPT.

My next post will cover more sober business applications of such.
 


 


Wednesday, March 22, 2023

#957 Enabling Visual Builder in OIC


Visual Builder is available by default, when you provision an OIC gen 2 instance. However, in OIC3, one needs to explicitly enable it. Here are the simple steps to do so - 

1. Create your OIC3 instance, unless you already have one. Then follow the screenshots - 









e.g. allow group domain_admins to manage visualbuilder-instance in compartment oic-dev-comp












Tuesday, March 14, 2023

#955 OIC B2B - Anatomy of a simple X12 P850 doc

This post is more of a note for myself, but it may also interest some of you out there. In this case, I am receiving purchase orders from my trading partner Commiskey_Inc. My OIC B2B Host configuration is as follows - 


The Trading Partner and document configuration - 















I regularly do OIC demos including B2B, using a very simple X12 P850 document - 

ISA*00*          *00*          *ZZ*Commiskey_IID  *ZZ*MyCompany_IID     *230314*1204*U*00401*000000027*0*P*:~
GS*PO*Commiskey_IID*MyCompany_IID*20230314*1204*1027*X*004010~
ST*850*1027~
BEG*00*NE*8310138**20230314~
CUR*2L*USD*0001~
PO1*HOTD TShirt*30*EA*30~
PO1*HOTD Mug*1*EA*10~
PO1*HOTD Cap*5*EA*15~
CTT*3*985~
SE*8*1027~
GE*1*1027~
IEA*1*000000027~
 

Naturally, the B2B demo goes like a dream, but what do these fields mean?

ISA - Interchange Control Header - identifies the interchange - 

ISA01 - Authorization Information Qualifier - '00' means no authorization info present i.e. next field is empty.
ISA03 - Security Information Qualifier - '00' = No Security Information Present.
Net, net, ISA01 to ISA04 are hardly ever used.

ISA05 - Interchange ID Qualifier - is a 2 char code, in my case ZZ.
ISA06 - Interchange Sender ID - this is my trading partner EDI Interchange ID, in my case, Commiskey_IID.
ISA07 - Interchange ID Qualifier, is a 2 char code, in my case ZZ.
ISA08 - Receiver Id, This identifies your partner's sender ID in outgoing messages. In my case this is MyCompany_IID.
ISA09 - Interchange Date - format is YYMMDD. My date is 23rd March 2023 so the value is 230314.
ISA10 - Interchange Time - format is HHMM, in my case, 1204.
ISA11 - Identifier - a single character code value "U" meaning "U.S. EDI Community of ASC X12, TDCC, and UCS".
ISA12 -  the EDI standard published version number. In my case this is set to 00401. 
ISA13 - This is a 9 digit control number used for tracking purposes. This number must match IEA-02 (Interchange Envelope Trailer). In my case, both are set to 000000027.
ISA14 - Acknowledgement Request Indicator, usually set to 0.
ISA15 - Data sent can be for Test (T), Production (P) or Information (I). We're doing this for real so I set this to 'P'.
ISA16 - is the delimiter used to separate compent data elements, within a composite structure. I set this to ':', but, as you can see, it is not used in this simple PO850 doc. 

GS - Functional Group Header - 

GS01 - Functional Identifier Code, PO for Purchase Order.
GS02 - Application Sender’s Code, sames as ISA06, so, in my example, Commiskey_IID. 
GS03 - Receiver's Id, should be the same as ISA08, so, in my example, MyCompany_IID.
GS04 - Transaction Date - format CCYYMMDD, in my case, 20230314.
GS05 - Time in HHMM format.
GS06 - Group control Number - not to be confused with ISA13.
GS07 - EDI standards Agency, 'X' stands for X12.
GS08 - EDI Version - in my case, 004010.

ST segment - Transaction Set Header - first field is the Transaction Set Identifier Code, in my case 850 for purchase order. The second field is the Transaction Set Control Number -  the control number that must be unique within the transaction set, in my case, 1027.  

BEG segment - 

BEG01 - First field, with the value '00' is the X12 TRANSACTION SET PURPOSE.
Valid values include - 
  • 00 Original
  • 01 Cancellation
  • 06 Confirmation
  • 07 Duplicate
Full list available here

BEG02 - Purchase Order Type Code, with the value 'NE'.
Valid values include - 
  • NE New Order
  • NS New Store
  • SA Standalone PO
  • BK Blanket PO

Full list available here

BEG03 - Purchase Order Nr, with the value '8310138'. This field can be up to 22 chars.

BEG04 - optional

BEG05 - PurchaseOrderDate, with the value 20230314 (YYYYMMDD)

CUR - the Currency Segment -

CUR01 - Code identifying an organizational entity, a physical location, property or an individual, in my case '2L' which translates to Corporation.
Full list available here  

CUR02 - Currency Code, in my case 'USD',  
CUR03 - Exchange Rate, in my case 1:1.

PO1 - Purchase Order Item details - the first field is the assigned identification, in my case, 'Bearing'.
The next field is the quantity ordered, in my case, 30. The following field is Unit of Basis for Measurement Code for the quantity, e.g single item or case of items. So my first line is for 30 Hare of the Dog T-Shirts, each costing $30.

CTT - Transaction Totals - first field is he number of line items, in my case 3. The second field is the total order value, in my case - (30 * 30) + (1 * 10) + (5 * 15) = 985 

SE - Transaction Set Trailer - indicates end of transaction set and contains a count of the transmitted segments (incl. ST and SE), in my case, 8. The second field is a unique Transaction Set Control Number (min 4 digits), in my case 1027.

GE - Functional Group trailer - First field contains the number of transaction sets included in the message, in my case, 1. Field 2 is Group Control Number, assigned by the sender. 

IEA - Interchange Control Trailer - first field in the number of included functional included groups, in my case, 1. The second field, Interchange Control Number is a mandatory 9 digit number, in my case, 000000027.       

A very helpful resource for me, when compiling this blog, was the EDI Academy Blog. Check it out here.


  

Monday, March 6, 2023

#956 OIC 23.02.2 update - Welcome Visual Builder


Another major step on the way to OIC Gen2 parity - OIC now includes Visual Builder - 



In this post I will detail the creation of a simple VB app that invokes an OIC integration, so let's check out which integrations I have on this instance. 















Let's invoke AA-PostgreSQL-Demo from VB. This creates a row in my Orders table. first step is to create a service connection in VB to OIC Integration. We have OOTB access to our activated integrations, as you can see - 





As already mentioned, the PostgreSQL integration creates an order in my PostgreSQL DB. 

So I begin by creating a simple VB app to manage my orders. I create an Orders Business Object, then I generate a CRUD UI for my Orders. Note that Visual Builder allows me to create native mobile and web apps and this very easily. When we say low code, we mean LOW! 


The final step is to amend the page workflow to invoke the integration. I will add this to the create page - Save - action chain.  



I will add the Integration invoke in the success path, after Fire Notification.






I set the body as follows - 






Let's test it - 











I check Integration Tracking -


I then check out the orders table - DB - 





Enabling VB in your OIC instance is very easy, only a couple of steps - 

1. Create a policy to allow OIC admin to manage Visual Builder -
allow group <admin_group> to manage visualbuilder-instance in compartment  <compartmentId>

2. Click the Enable link for Visual Builder on the Integration Instance Information tab.


Summa Summarum

This is the penultimate step on the way to OIC Gen 2 parity as OIC now comprises - 

  • Integration
  • File Server
  • B2B
  • Insight
  • Visual Builder

But it's not just parity - OIC includes many compelling new features, not available in OIC Gen2. So get kicking...