Transcription
Hello everyone. This is Professor Patterns, and in this video, we're going to be learning about something that's known as action functions.
First, I'm going to show you exactly what they are, why they're useful, and also why you should be using them as well. So, here's an example. Suppose I ask a large language model to explain what a p-value in statistics means. It gives me a pretty large, detailed explanation, but a lot of the times, I just want a summary. So, what I could do is I could go in here and I could type, well, summarize it for me.
But if I notice that, well, I'm I'm over and over again asking the large language model to keep continuously summarizing, instead of that, I can just create my own custom action button. So here is a button called summarize. What it does is that it looks at the current text and then based on the text, it summarizes it. So it says, summary, bullet style, three to five sentences. It gives me a summary here as well as the key points. So, it compressed it by 66.7%. And we went from 402 words to now just 134.
Something else that I could do as well is, well, I read this and I still don't understand it. Well, I have this other uh button that I've created. It's called explain like I'm five. So, if I click this, what it does here is that it makes it simple for a 5-year-old. So, again, if I scroll down over here, we can see that it creates a simple explanation. A p-value is like a magic number that helps you find out if something special really happened or if it was just by chance.
Now, if you go over to the open web UI documentation page, that's docs.openwebui.com. I'm also going to share a link here in the description, but you can see here that within the functions page, we have three types of functions. We have pipe, filter, and action. So, the one that we're actually looking at today is action functions. But if you also wanted to take a look at pipe as well as filter functions, I did also create separate videos on those. I'm going to link those in the description below.
So, basically, the action function allows you to write custom buttons to the message toolbar for end users to interact with. So that's the overall idea. We can even have action buttons like here, for example, as you can see in the demo, there's an action button for creating graphs. And once we click that, we can see it creates a bunch of different graphs over here. We can also find a bunch of community-written action functions. So, if you go to openwebui.com um on the functions page, you can just search or click see all, and from here, we can see a bunch of different functions that are actually created by the community. So we have some visualize data action function, live search, uh, this is a pipe function, we have a mixture of agents, action.
So, why don't we try one of these right? So, let's see the add to memories action button. So, if you click on this, it says, add the assistant message to user's memory. Now, you can get any function just by clicking on get and then import to open web UI. You might just want to change this to wherever your open web UI is running. So, for me, it's running on localhost 3001. Then you can import this to web UI. And in my case, I I think I already have this function here. So, I don't need to go do anything else. I can simply hit save. Uh, if I go over here to my functions, I can see the add to memories action button. Now, obviously, I do want to make sure it's enabled. And even when I enable this globally, I don't have any valves that I have to configure. So that's perfect.
Let's go back over here and then let's say something like, um, I am a data scientist. So, over here, we get a response. That's fantastic. Uh, great, uh, Gemma, basically telling me that, good for you. So, over here, I have this add to memories action button. So, what happens if I click this? It says, add to memory and memory saved. Now, if I go over here to my admin panel, or actually into my settings and then select my personalization and then memory, I can click manage and we see over here that this chat is now a part of the memory. So, over here, I can enable the memory and I can go back over here, and any conversation that I now have in the future, the language model is actually going to be able to remember prior conversations. So, I can say something like, what is my occupation? And we can see over here, it remembers that your my occupation is a data scientist. So, this basically helps keep track of all the different conversations that I had. If I see something that could potentially be pretty important, I might just say, look, add this to the memories because I just want you to remember this information later on in the future.
Okay, so by this point, you're probably wondering, well, how do I create my own action function? Well, it's actually quite simple. First, what I'm going to do is determine what I want my action function to do. I'm going to open up a new conversation with Anthropic Claude. And here, I'm going to start by saying, look, I have attached two action functions and how to create them. So, let's do that. First, I'm going to go over to my admin panel, functions, and I have the explain like I'm five function, and I'm also going to link this here in the chat so you can also take a look. And let's paste that over here. And then let's take the other one, which is the summarize, and I'm also going to add that over here. So, the last thing I also need to do is give it the entire documentation of action functions and paste that here as well. The thing that would happen, uh, just going to say documentation and blah.
Okay. So, I said, attach the documentations, please take a look, and then use that to create an action function. So, the goal of this function is to convert an AI-generated piece of text to make it sound more human. I asked it to determine, well, what makes a piece of text more human than AI? So, read through a bunch of stuff that people posted online and then use that information to create an action function where I can click a button and then the AI uh will humanize the text and make it sound less AI. So, a little bit of a vague requirement, but the overall idea here is that, well, if I write an email that's ChatGPT written, I don't want it to show that it was ChatGPT written. So, what makes something uh really easily understandable, like, oh yeah, that's definitely ChatGPT. And then let's convert that.
So, right now, what it's doing is that it's actually searching through a couple of different pages on like AI-generated versus human text. And it actually looked through almost 30 pages of results. So, that's awesome. Okay. Okay, based on my result, I have a comprehensive understanding of what makes text sound more human versus AI-generated. So, now it's actually working on creating this action function. So, it is pulling this icon URL. And this is what I noticed. It does take a second here for this to populate because it's a huge thing. If you want, you could even have like a custom one that you could provide it over here. And pretty much, it can just do that. So, let's see what it's doing. Make LM request. So, it makes a request to the LM provider. Uh, let's keep scrolling down. So, for custom um applications, assuming OpenAI compatible API. Okay, great. Um, let's take a look at the base instructions. So, transform this AI-generated text to sound more human. Delete phrases like certainly, here is, furthermore, in conclusion, in summary, moreover, interesting addition. Okay. Remove overly formal transitions, unnecessary connecting words. So, the mdash that a lot of people have been talking about, and also add human characteristics. Okay. Kind of vague, but let's see what it actually creates. Mix short, punchy sentences with longer, flowing ones. Vary the sentence starters. Don't always follow the same patterns. Okay, so there's a bunch of different things over here that's asking the model to do. And there we go. The function is complete.
So, let's go back over here and let's create this function. So, I'm going to click on this plus icon. New function. Let's paste this. And it's about 400 lines of code that is written. No idea if this works or not. But some, usually I would actually go through this and understand, well, what kind of it's trying to do. But for now, I'm just going to go full vibe code. So, let's say, um, human text converter. So, function description, converts AI text to sound more human. And then let's hit save and confirm. So, it says, only alpha-numeric characters are allowed and the ID. So, of course, human-text-converter. I think that should work now. So, let's hit save. Confirm. And there we go. Function created successfully.
So, I need to first enable this. And if I click on valves, there are a couple of different things that I might need to customize. So, the API base URL. That's awesome. That's great. That's the OpenAI one. LM provider. Let's keep it at OpenAI. Um, API key. So, I definitely need to provide this. And then the model name. I'm going to leave it at GPT4 mini. Everything else can stay the same. The only thing I need to do is just add the API key. So, I'm going to do that and then cut it out of this video.
Okay, perfect. Everything is added in. I can click on more and just make sure global is enabled and all of the other valves have been configured. So, now I can go over here. I can just say something like, write me two sentences to post on Reddit. So, what it's going to do is that it creates these two sentences. Now, initially, there are two sentences. I see that there's immediately an M dash, right? If I read this, um, emerging AI tools into their workflow dash any tips on u experiences or tips or experiences there or hyphen, uh, tips or experiences share automatically. I look at this, it's like, yep, this is definitely AI written.
Now, if I click on this button, human text converter, this is supposed to allegedly convert this into a human text. Let's see if this actually works. If I click this, it says, making it conversational. So, actually, it did it in the same line. So, that's not great. We we can just change that though. So, comma, as a data scientist trying to keep up with all the crazy changes happening these days, I'm really curious. How do you guys use new AI tools in your work? Got any cool tips or stories to share? Okay, that looks a little bit more Reddit like. I just dove into this really complicated data set and wow, it hit me how important data storytelling is for making sense of everything. How do you make all your data presentations more interesting and engaging? Okay, so these definitely sound a little bit more human than these. These are more AI-written texts, but at the end of the day, it's more subjective. I still think that this is more of like AI pretending to be human than it actually is human, but I don't even know what's real anymore.
Um, if you found this video interesting, uh, please like, comment, and subscribe. And, uh, you know, your support means a lot to me. Um, and I will see you in the next one. Thanks for watching. Goodbye.