logo

NJP

Building a custom generative AI solution using WatsonX (AI Academy)

Import · Jun 21, 2024 · video

welcome into another AI Academy session as note this recording was actually a reording is the live session's audio was not fully captured so just bear that in mind as you go through this recording now on this AI Academy session I will be making forward-looking statements which are basically statements that apply to things that are on the road map and have yet been released so please please please do not make any purchasing decisions based on those statements is they are subject to change now resources out of the aiy you can actually find articles post questions get answers or on our community page which you can get to following that short link there in addition we do have our now Community YouTube which is you are likely watching this Academy session on where we host a wealth of other videos that will help you in being successful um primarily we do have a playlist with all the other um AI Academy sessions so please keep an eye out for that now these Academy sessions they are designed for you so we do try to tailor the content of the session to what we're been hearing from the field so if you get the chance to attend one live and want to us to cover a particular Topic at some point um just just ask us send us an email Post in a Q&A asking for a particular topic to be covered we want to make sure that these are helpful for you in addition as you can tell this is a recorded session we do post them on YouTube on our community um playlist so keep an eye out for others there and then as always if you are joining us live you'll be able to partake in Q&A um get and get answers directly so goals for today I'll spend about 5 minutes just going through the basics on what I'll be building out and then we'll spend the majority of the time within the exercise itself and today our focus is on building a custom generative AI solution using Watson X your present today is myself Eliza orid and I'm an outbound product manager here at service now focusing on gener AI and Analysis products so some foundational content um everything within service now that leverages gener of AI actually goes through our gener of AI controller which you can think of as really the I want to say The Bodyguard of gener gii within your instance now how this works is you know let's say you want to go through and have something be gener generated using J of AI so the first step you go through and you collect data from any Source you want so this can be within a service now workflow it can be from you know a particular database or some records on one of your tables it can be directly from code or even information gathered directly from a user now this data that you want to do some sort of you know generate content from or synthesize or try and analyze it once you've collected that all you then need to tell the llm what you want to do with it which is um what you do with prompts now the we do provide a number of preconfigured and generic prompts uh within service now these primarily are found in the use cases of about out of the box skills so things that come with analysis for CSM oralis for itsm those SKS um we provide out of the bul experiences such as incident summarization resolution note generation and things like that which we've already configured the prompts for you and actually the collection of data from any source so we can just turn it on and it'll Works however in instance of today we were building out the custom solution you're actually able to tailor both the prompt and the data um to that you want to include to make sure that the output of your custom solution is exactly what you want now once you've collected both the prompt and you have your data you then send that outside of your instance to your llm now today we'll be using IBM Watson X llm um which we do have a spoke for just to make configuration that a little bit easier um we also have spok for your open the ey L of alpha um open the ey itself as well um a whole range of ones which will preconfigured to make setup easier for you but of the May release we actually do have a generic llm connector which allows for you to connect to any external llm as long as you know you have your API key you know the endpoint and you are able to write a script that translates um what basically that's able to interpret the format that the llm wants and then when it the returns the response to the instance that you're able to translate it back into what service now expects so little bit High code there but you can look that up um generic L connector um so once you've sent off that data and prompt to the llm we then get a response back basically just the result from what you asked LM to do with that content now when connecting up your service now instance to any external llm you actually have access to four capabilities to just drag and drop within flow designer virtual agent designer um and within scripts so those are listed on the right here which is generate content sentiment analysis summarize and generic prompt now these are just ways for you to expedite the process of creating flows in one not and we'll see that in the demo now as we go through I did just want to flash the slide at you guys to show some examples of where you can actually build out custom use cases and what problems they can help you solve within your workflows today we'll be looking primarily at the middle two so the using G AI to analyze content and also that of personalization of content based upon you know the result from the pr previous set but take a look at this if you're looking to incorporate gen in avert flow then you might just get inspired now what we'll be building today is actually that of a personalized case response so we'll have HR cases being submitted via email that will then trigger a workflow within this workflow we'll be taking the content of those incoming emails and using IBM Watson X the their llm to first of all determine sentiment that they happy are they sad are they upset and based upon that sentiment we actually tailor the email response to them based upon that sentiment and in this use case what I do is actually if you've got a negative sentiment if you're upset angry we'll actually reduce the um expected response time by a couple of days just to make sure that you get your resolution faster because we assume that you know we don't want you to be upset so that's our use case for today and let's get into it so right now with we are within our instance and we're going to go ahead and create a connection to IBM's Watson X llm now this is an external llm so we do first of all need to go to connections and credentials Ates so if I go here so you want to go connection and credential aliases and if you ever configure diamic translation you may already be familiar with this process but basically this table just shows you all the external um kind of spokes we have available for you to connect up and leverage Services provided by um third parties now today we'll be using Watson X so let's click on this record once loaded so you will not see this um down here just as an fi this is because I already preconfigured it but um in order to set up the connection to Watson x what you do is you click create new connection in credential underneath related links and then in here you put in your project ID the credential name a w name and then your API key now you can find all these within IB G um like when you go through and register you know I just use a free trial for this lab actually um but you'll be able to find all that information from IBM itself so populate all these fields the connection URL as well double check that we do provide this one out of the box but it may be different for your use case and then click create and get a token once you've done that you will see a record down here underneath connections and just make sure that active is true it should be set to that for by default but um you know you never know and that's it in terms of actually building out a connection to IBM's what's next llm what we want to do now is set it up so that service now knows which llm to point to when we're using one of those capabilities that I mentioned before such as summarize generic prompt um sentiment analysis this so to do so we actually want to go to something called on xn capabilities now this table name and I'll just copy and paste it in here so you can see it um we don't have a direct link to it within the navigation filter but if you go into there and type one cisor 1core extendor capability. list you'll get here so as mentioned previously um we will just be using santiment analysis and generic prompt today so let's search for those capabilities open up the record and then you want to click on one extend definition configs now this is where you go in and you want to set the default value to true for whichever llm you want to um use use the when kind of triggering this function this capability so today we'll be using IBM wats and X so the default value for that is true now you can only set one of these default values to True at any one time so just bear that in mind um if you want to use sent analysis sometimes by you know Al of alpha sometimes by aure open AI um that isn't available today you can only choose one so sentiment sentiment analysis is said that if we go back and look for generic prompt again same thing go to definition configs and just make sure that IBM Watson is set to true so now when we are building out our flow within flow designer it will know which LM to point to so let's take a look at what that looks like within flow designer into flow designer now one thing to note is because we are doing a workflow um using the HR cases we do want to First actually change our scope to that of human resources core now this is just so we can actually get information from those HR cases so you want to click on the globe and change your app ation slope to Human Resources core as is if you want to follow along now that we've done that we change back to workflow studio and we want to create a new flow now this might be new to some people but if you're using floor designer and have access to analysis for Creator you can actually build with analysis um however today we're just going to build from scratch so I'm going to call this HR case Pros response and we're just going to call it version four so then the name doesn't um conflict with anything now let me make the screen bigger awesome so first up we're going to initiate a trigger now in my case as I mentioned we're going to have an inbalance email from a user that then generates an HR case where we put the contents of the email within the description field so what we'll do is do inbound email and then set the reply record Ty once this loads but just for the sake of testing today what I'm actually going to do set it to record updated and this is just so that we can um trigger it a lot easier from um a case just for testing and we're actually going to only do this for H payroll cases just to be a bit more specific and we just going to run it for every update so disclaimer this is only for testing within this AI Academy session but you can save the trigger to whatever you want and that we'll just trigger the flow so the first step we're going to do is create a flow variable now the slow variable is going to hold the contents of that email that came in from the user so we're going to say email input and this would just be a string type containing text the first action we want to do is actually that of setting the flow variable to be email input from that customer so we'll do flow action set flow variables and we want to assign email input now as I said um we're actually going to have that hop P roll case description field contain that input email from the user just describing what their issue is so we're going to grab the description field and set that email input FL variable to that now in this situation make sure that you grab the plain string text rather than Rich HTML because HTML sometimes makes it fun and then click done the next section is where we actually bring in Janu VII so if you remember we are actually going to reach out and do sentiment analysis and in here what we do is we actually just populate this with the email input flow variable that we just set and what this will do is we've already got the prompt configured for you to say understand sentiment of this um input and we sending this data off to then be process by Watson X to on the sand do they have positive sentiment negative senent awesome now we're going to do an if statement and our if statement is actually going to be if negative sent detected and to figure that out what we do is we actually go on the right here and we want to get the response so that is the result from the LM determining what the sentiment of that email was so we drag and drop response here and we're going to say if it is negative we want to go down this particular path on Happy click done and then in this next step what happens is we will actually go ahead and create that proposed response template for the agent to use to respond to that user to do so we are going to actually just use generic prompt and again underneath spokes gener B controller generic prompt if you don't see these make sure that you're entitled and for analysis and have actually installed the plugins and now within the prompt this is really road to Oyster here you can determine whatever prompt you want to send off to that llm and in our scenario what we're going to do is ask them to create a formal email response addressing the inbound email SS issue promising Swift remediation within one to two working days now as I mentioned if it's if they've got a pretty positive sentiment then you know they're probably happier to wait you know the stand four to five working days but if a negative it might require a bit more attention and then we're going to Define what the tone is we can also add things such as okay the email response should be addressed to the person who actually sent that email so to get that we can go into this case record itself and go find open by and then get their name and drag and drop that field in there now additionally we also want to make sure that we include the email to actually respond to so while we do is say the inbound email to respond to is as follows and you drag and drop that flow variable and here now the reason I put this in for a variable is it's just so much easier if you're working repetitively with a particular variable just to put it in there so you can drag and drop it rather than having to you know dot walk all the way through um to find what you need so that's it that's going to generate us a um email proposed email response for the agent and then based on that what we're going to do is actually populate the HR case with that particular output of the llm now out the box we don't have a very good place to store it so we're actually going to go ahead and create this field so to do so I'll go into the HR agent workspace and then I'll actually go to an HR payroll discrepancy case record and as an admin user I'm able to click on my avatar go down to configure page and then do form layout um so on here you'll want to make sure that you're pressible within the right scope and you can actually go in and create a new field here so we will say propose response it'll be type string because the email will just be in string and I just put down large um you can do extra large if you want to have very for both emails and then you click add now in the interest of time I actually already added it in here and what happens is you want to make sure that it's in the right hand side so if it's not already you see click on the field click on the arrow and then it should appear here but if I go down you can see I already created this field and I put it straight underneath that description field once happy with that you click save and if you go back to the workspace oops and scroll down you should see a proposed response down here now that was a little sneak preview um for you so let's go back to our flow and make sure that we actually populate that field with the response um with our proposed email response so what we do is we want to update a recod so we'll create new action upate recod and the record we want to update is the record that actually triggered this flow so you can drag and drop that the table should order populate and then the fields will actually be our proposed response string field now in the text here we actually want to first we make sure that the agent reading this knows that it was generated by an llm so to do so we want to say okay there we go I just lost the ability to click into there for a second but propose response gen gen or rated by and then what we can do is actually put in the provider of the um llm capability now this you can grab either of them put them in here and this will say whats and X when we um actually populate this field we also want to State please review for accuracy just because llms you know they're not a human they're subject to hallucinations and whatnot so we just want to add that disclaimer then underneath this we will actually bring in the response from generic prompt the previous step which is that proposed email response to that user hit done next step is when there is a basically if anything other than a negative sentiment was detected we want to do the same thing but just increase the number of business days we are giving ourselves to respond so to do so we're actually going to just do an else statement so we can do the recommend action down here again if you're not seen those recommended actions that's actually a component of analysis as well that's available for you which is very very handy as you can see there so here rather than retyping everything out we're actually going to duplicate both of these actions so duplate there change this to be we're just going to give ourselves four to five working days if they have let's say a much more positive sentiment to their incoming email and then you click on the six dot um on the left here and can drag and drop it underneath that L statement and then we do the same for the updating of the case record and drop and in here just because we reference a record from number four we do need to update this to make sure that we're actually getting output from the generic prompt for the kind of the positive senent F so to do so we make sure that we get the response from line number seven and drop that in here and then we also want to make sure that we drop the provider in also and this is make sure that we are getting the currect provider and output from generic prompt on line number seven rather than line number four is this one actually run hit down hit save and that FL will save successfully cool so now that we have defined our workflow we've hit save let's test this out so for some context I have two test records available one H case 008 and 10009 if we scroll down and see the description so again this is from a incoming email um that opened the case automatically you can see here 1 9 is pretty positive you know it's they're pretty happy they're grateful for their assistance and for the excellent work they do every day now if only we could always receive emails like this but you can see here they're not really in a rush to get this resolved so let's see if our flow works well with that scenario so we're going to test 1 9 and click run test now because it is reaching out to ANM and my instance personally it's a development instance so it does run a little bit slow which is why this is taking a little while once we see this message we click on it and massive apologies for the lawn mower outside hopefully it's not too loud and you but we can follow the flo the execution of our flow so the first thing we want to do let's check out number number two to see what the result was from Ivan Watson in determining the sement so going through the details here the utterance is the value that we provided to IBM Watson and that's our email input again you can see it's that very positive email underneath output data we get the action status which is basically what the API returns so in this case Code Zero message success which is what we want that means the API is up and running for that external element M our provider is IBM Lon X and the response is positive so this is output of that sentiment analysis on that utterance if we scroll down here we can see you know was negative sentiment detected no so these STS didn't run so we're going to this else statement we generic prompt it includes our prompt and the data was actually populated in here and then the providor and we can see what the actual outbound response kind of proposed email response was including that of that we might take up to four to five working days to result all this matter now sometimes you do have to play around with the prompts a little bit to get everything working correctly um now llms you know they're non deterministic so you might get different results even with the same prompt for example in testing it was a was able to actually put in the email sender's name but um apparently this time when I tested it out it didn't want to do that so just keep that in mind as you go through that you can't actually do things like automated tests or anything on this because output of llms you know it's as I mentioned it's non determin it changes from time to time but any so that's one way of building out a workflow and just for good measure we'll actually go Ahad head and test a negative S one now one8 if I run this test I'll show you what the email actually looks like so down here you can see he's not very happy he's saying I urge you to investigate this promptly and rectify the eror as soon as possible um you know he's extremely frustrated and disappointed by this error so we want to hope that this triggers the negative s um flow there and he will get that um expedited resolution time so looking at the output of the test run yes indeed we got a negative sentiment [Music] determined the generic prompts option again you know we provided them with inbounded email and then if we scroll down to the output data we actually see the email response and as I mentioned you know it just depends on the llm but was actually able to pull out AEL the caller's name and automatically address email to him in addition we give him one to two working days so this was just a very brief example of one of the things you can do using um generative AI within your service now instance like this like don't limit yourself you know there's a wealth of opportunity for you to come in here and just EXP di your workflows um make lives easier make your agent lives easier or your end users um you know get better results and whatnot just through the use of gener AI um it's really exciting area really exciting time so I hope this is useful thank you

View original source

https://www.youtube.com/watch?v=1P1qWidrh9Q