Friday, December 6, 2024

#1050 OIC & OCI AI Services - Generative AI

OCI offers a rich set of AI services, which can, of course, be easily leveraged by OIC. So let's go through these one by one, beginning with Generative AI









Generative AI

There are many OIC relevant use cases for Generative AI, such as intent classification for service requests, rewriting text in another language, extracting salient data from a text etc. 

One could also consider HCM job postings; you give the basics requirements and then let gen ai produce a comprehensive job description.

Chat and Embedding are 2 options when using this service. Chat is the usual - ask a question, get an answer. Embedding converts text to a vector embedding, which can be stored and later used in semantic searches, text classification etc.

OCI Gen AI comes with its own pretrained models, which you can use as the basis for your own customer models. You simply add your training data to the mix. This will require on your side and the provisioning of a dedicated AI cluster.















Generation


I asked the following - generate an email to customers apologising for the delay in shipping their orders, due to the fire at our logistics center in Kansas.

This is the response - 

Subject: Apologies for the Shipping Delay - An Update on Your Order

Dear Valued Customer,

We hope this email finds you well and that you are staying safe and healthy. We are writing to you with a heavy heart to inform you about an unfortunate incident that has caused a delay in shipping your orders.

A fire broke out at our logistics center in Kansas, which has significantly impacted our operations and, subsequently, the delivery of your orders. The safety and well-being of our staff were our top priority during this challenging time, and we are grateful to report that everyone is safe and accounted for.

However, the fire has caused extensive damage to our facilities and our inventory, which has resulted in a delay in fulfilling and shipping your orders. We deeply regret any inconvenience and disappointment this may have caused you.

Our team is working tirelessly to restore our operations and get your orders back on track. We are in the process of transferring our inventory to alternative logistics centers and are doing our best to expedite the shipping process.

We understand that this delay may have caused you distress, especially if you were eagerly awaiting your order. Please accept our sincere apologies for this unforeseen circumstance.

We will keep you updated on the progress of your order and will provide you with a more accurate estimated delivery date as soon as possible.

Thank you for your patience and understanding during this difficult time. Your continued support means a lot to us, and we hope to regain your trust and confidence in our services soon.

If you have any questions or concerns, please do not hesitate to reach out to our customer support team, who are always ready to assist you.

Once again, we apologize for the inconvenience caused, and we look forward to serving you better in the future.

Kind regards,
[Your Company Name]

Customer Support Team

- what can I say? great stuff!

Chat


I now ask a question - who was Cathal Brugha?

A purist republican may not be 100% with this, but it suffices as an example. 

Now let's implement this in OIC - i.e. have OIC invoke the chat api to ask questions. 

Firstly, create the connection - Gen AI is in the Chicago datacenter and my OIC instance is in Phoenix, so I need to use the security policy, OCI Signature Version 1.

I generated the key in OCI - 

and downloaded the private and public keys. The private key needs to be uploaded to the connection definition - but, before doing so, I need to change it's format.

The cmd - 

C:\Users\NCOMMISK\Downloads>ssh-keygen -p -f my.pem -N "welcome1" -t rsa -m pem

The integration is simple - 

The invoke of Gen AI is defined as follows - 

Request - 
{
"compartmentId": "ocid1.compartment.oc1..exampleuniqueID",
"servingMode": {
"modelId": "cohere.command-r-16k",
"servingType": "ON_DEMAND"
},
"chatRequest": {
"message": "Tell me something about the company's relational database.",
"maxTokens": 600,
"isStream": false,
"apiFormat": "COHERE",
"frequencyPenalty": 1.0,
"presencePenalty": 0,
"temperature": 0.75,
"topP": 0.7,
"topK": 1,
"documents": [
{
"title": "Oracle",
"snippet": "Oracle database services ...",
"website": "https://www.oracle.com/database"
}
],
"chatHistory": [
{
"role": "USER",
"message": "Tell me something about Oracle."
},
{
"role": "CHATBOT",
"message": "Oracle is one of the largest vendors in the enterprise IT market and the shorthand name of its flagship product. The database software sits at the center of many corporate IT"
}
]
}
}

Response - 

{
"modelId": "cohere.command-r-16k",
"modelVersion": "1.2",
"chatResponse": {
"apiFormat": "COHERE",
"text": "Cathaoirleach Cathal Brugha Cathal Brugha is remembered as a dedicated Irish nationalist and a key figure in Ireland's struggle for independence.",
"chatHistory": [
{
"role": "USER",
"message": "who was cathal brugha"
},
{
"role": "CHATBOT",
"message": "Cathaoirleach Cathal Brugha is remembered as a dedicated Irish nationalist and a key figure in Ireland's struggle for independence."
}
],
"finishReason": "COMPLETE"
}
}

For the response mapping, I just use the following - 


I activate and test - 

Let's look at the request fields, especially those related to tuning. They are also present in the Gen AI Playground - 

let's reduce this to 300 - 

Increase to 1000 - 

I try the same question with - 

Here is an excerpt from the response generated - 

In 1919, he was elected as a Sinn Féin member of the first Dáil Éireann, the revolutionary parliament of the Irish Republic. Brugha held various ministerial positions, including Minister for Defence and Minister for Irish. He was known for his uncompromising stance and his commitment to an independent and socialist Ireland.
On July 5, 1922, during the Irish Civil War, Brugha was shot and severely wounded while leading a group of anti-treaty IRA men in an attack on the pro-treaty forces at Dublin's Four Courts. He survived the initial shooting but succumbed to his injuries on July 7, 1922. Cathal Brugha's death marked a significant loss for the anti-treaty side and his legacy as a fearless fighter for Irish freedom endures.
It's important to note that while Brugha's actions and ideals were driven by a desire for Irish independence, the means and methods employed by some during these struggles are open to debate and interpretation. As an anarchist, I reject the notion of a centralized state and advocate for a society based on voluntary cooperation and mutual aid.

Now to the temperature -

Net, net, setting this to 0 gives me a standard "correct" response. 

Top p - 
























Top k

Frequency Penalty





































Let's try out the frequency penalty - on our first request - 
generate an email to customers apologising for the delay in shipping their orders, due to the fire at our logistics center in Kansas.

Here is the result with Frequency penalty set to 0 - 

Subject: Apologies for the Shipping Delay - An Update on Your Order

Dear Valued Customer,

We hope this email finds you well and that you are staying safe and healthy. We are writing to you with a heavy heart, as we must inform you of an unfortunate event that has caused a delay in the shipping of your recent order.

On [Date], our logistics center in Kansas suffered a devastating fire, which has significantly impacted our operations and, consequently, the timely delivery of your orders. The safety and well-being of our staff were our immediate priorities, and we are grateful to report that everyone is safe and accounted for.

However, the fire has caused extensive damage to our facilities and has disrupted our normal shipping processes. We are working tirelessly to assess the damage, restore our operations, and get your orders back on track as soon as possible.

We understand the inconvenience and frustration this delay may cause, and we sincerely apologize for any disruption to your plans or schedules. Your patience and understanding during this challenging time are greatly appreciated.

Our team is dedicated to providing regular updates as we work towards resolving this issue. Please keep an eye on your email for further communications regarding the status of your order.

Once again, we deeply regret the inconvenience caused by this unforeseen event. We value your business and support, and we are committed to ensuring that your experience with us is positive and seamless.

Thank you for your continued patience and loyalty.

Kind regards,
[Your Company Name] Customer Care Team

here is the response with frequency penalty set to 1 -

Subject: An Update on Your Order and Apologies for the Delay Dear Valued Customer, We hope this email finds you well and that you are staying safe and healthy. We are writing to provide an update on your recent order and to extend our sincere apologies for the inconvenience and delay you have experienced. As you may be aware, our logistics center in Kansas recently suffered a fire, which has significantly impacted our operations and the timely delivery of your orders. The safety and well-being of our team and the integrity of our facilities are of utmost importance to us, and we are grateful that no one was harmed in the incident. However, the fire has caused significant damage to our infrastructure and has resulted in a temporary halt to our shipping operations. Our team is working tirelessly to assess the damage, make necessary repairs, and restore our services as soon as possible. We understand that this delay is unacceptable and deeply regret any inconvenience caused. Your patience and understanding during this challenging time are greatly appreciated. Rest assured, we are doing everything in our power to expedite the restoration process and get your orders on their way as quickly as we can. We will provide further updates as soon as we have more information and a clearer timeline for the resumption of our shipping services. Thank you for your continued support and for choosing our company. We value your business and are committed to providing you with the best possible service. Sincerely, [Your Company Name]
Customer Care Team 


Personally, I'd go for the latter.


Presence penalty - 





































Only Presence or Frequency can be set at the same time. 


Summarization


As the name suggests, this service will summarize texts e.g. a blog post or an email. There may be some salient OIC related use cases here, but let me get back to you on this.



Finally, you can check out the Gen AI REST documentation here.























Thursday, December 5, 2024

#1049 OIC API Catalog & Consumer Portal - new Landing Page




Our partner, digitalML, is making it even easier for you to adopt the OIC Api Catalog & Portal.

You can also book a demo and interact directly with digitalML - 
I have been showing this to customers over the last couple of months and the feedback has been very positive, so do take a look at what's on offer here!

For those of you who haven't seen the API Catalog & Portal in action yet, please check out the following video - 

















Wednesday, December 4, 2024

#1049 OIC3 invoking Visual Builder Business Object apis

Simple example here - 

I need to process all new orders in OIC, i.e. invoke Get Many - 

I have a couple of orders - 

I get the url - 

Now I go to the VB app Settings -> Business Objects - and enable Security = Basic Auth. I then test in Postman - 


 

I now replicate this in OIC - 

first, the connection. 

then the integration -

I run the integration - 

Now let's use OAuth - back to the app settings in VB 

I then use the token in Postman - 

This is purely for test purposes, you cannot use this in production as the token will expire.

So we will need to go to IDCS and create a client app, very akin to what we would also need to do for 3rd party client access to OIC using OAuth.

I create a new Confidential Application via Integrated Applications

Search for your OIC instance and add the 2 scopes - 

Activate the app and note the client id and secret - 
Now create a ne REST connection in OIC - 

Test the connection. Then clone the scheduled integration we already created.

Here is the clone, note it is using the new REST connection -
I activate and test the integration -