logo

NJP

GPT-3 Knowledge Helper - How it Works!

Import · Feb 07, 2023 · video

[Music] hey everyone it's Justin thank you for watching and welcome to my house in this video I want to show you how my integration with gpt3 generates draft knowledge articles it was really simple to create and if you've watched the video or if you haven't seen the video I'll include a link to it up above but this is what it did I have a UI action here at the top to generate a AI draft and all you have to do is populate the short description and it'll come back and populate a draft knowledge article in HTML formatting for you to edit and modify as you need for your organization but I want to show you how it actually works this is me committing my stuff to Source control so I wanted to make sure that I could share this after I developed it but let's go over here to my subflow for knowledge helper essentially it's getting a knowledge record as an input so that the UI action is calling the subflow and passing the current record I've got a variable to set the flow variables and this is the text prompt that I'm going to send to gpt3 so first thing is I grab the short description from the knowledge article after I do that I give it some instructions so I create a variable for create a draft knowledge document in HTML format for the following topic colon space end and then I concatenate those two together into a prompt and I return that as my variable so now I've got a formatted text prompt exactly what I want I have a custom action I'll show you that here in a second to generate the draft knowledge article and I'm passing it that text prompt and then once I get that text prompt back I'm going to clean it up and remove any new line characters and I actually got this particular new line stuff from chat gp3 this is the conversation how can I instruct TPT not to include two new line characters and it basically says you can programmatically do it with python I said well is there an equivalent to that in JavaScript and it gave me this trim start you know parentheses and that didn't work in service now so I said hey this doesn't work in service now is there an alternative for servicenow and it gave me this replace and then the regex code to use in service now so I was able to do all of that and it basically copied and pasted this dot replace new line characters and it was able to trim up the response I couldn't find a alternative in the out of the box capabilities and then I update the knowledge record I set the article body to that cleaned up response and that's what you saw in the video or just now when I clicked on that so let's take a look at that action that I did it's really really simple the input for that action is the text prompt right is or the short description that's coming from the knowledge base article so that's just a string value that's mandatory then I'm going to send that rest query over to open Ai and basically say hey here's my prompt here's my tokens temperature and of one I only want one draft article on it so a theory you could generate a couple draft articles and pick from one that you want the thing about these AI models that they kind of generate different results every time you call it then I parse that into an object and that object is what I'm able to use in my subflow if you look over here it is just let me move my head out of the way the response comes back with a array of choices and that's the N of one it's always going to be one but that choices object is what has the text response in it that I'm using to clean up and populate my knowledge article and that's how it works everyone the only other thing that you've missed here is the configuration of a UI action the UI action is on the knowledge record and I've got it working on both the classic view and the workspace view so no matter where you are creating a knowledge document you can click that and it'll call the subflow asynchronously and generate this article I hope you found this video helpful if you did please like Please Subscribe or share with somebody who you think might be interested in doing Integrations with gpd3 or other AI platforms to enhance the capabilities of servicenow and until next time don't forget to always be learning [Music] foreign [Music]

View original source

https://www.youtube.com/watch?v=_dyDEIPUuaw