<b>I get these types of</b> <b>comments all the time. </b> <b>Why are you only using</b> <b>OpenAI in your tutorials? </b> <b>The reason is actually quite simple.
</b> <b>For a very long time,</b> <b>OpenAI was pretty much the only provider</b> <b>that supported tool</b> <b>use or function calling. </b> <b>So if you wanted to create an agent</b> <b>that was able to call</b> <b>custom tools and functions,</b> <b>you were very much</b> <b>limited using the GPT-4 models</b> <b>or the OpenAI Assistance API. </b> <b>This is therefore why</b> <b>I tailored my tutorials</b> <b>around OpenAI.
</b> <b>Things have changed recently</b> <b>and there are more and more models</b> <b>supporting tool use. </b> <b>So this is why</b> <b>Flow-wise decided to deprecate</b> <b>the current tool use and function agents. </b> <b>And instead, they've decided to implement</b> <b>a single tool use agent,</b> <b>which will work with any model</b> <b>that supports function calling.
</b> <b>As per their post on X,</b> <b>this includes Mistral,</b> <b>Gemini, Claude, Grok,</b> <b>and obviously OpenAI. </b> <b>So in this video,</b> <b>I will show you how you</b> <b>can create a tool agent</b> <b>using the Claude 3 models,</b> <b>but feel free to swap</b> <b>this out for any other model</b> <b>that supports function calling,</b> <b>like the ones mentioned earlier. </b> <b>This agent will be</b> <b>able to perform retrieval</b> <b>from a knowledge base,</b> <b>like a Word document or a PDF doc,</b> <b>and it's also able to call tools.
</b> <b>So what you'll need to follow along</b> <b>is an anthropic API key. </b> <b>To get your API key,</b> <b>go to anthropic. com,</b> <b>click on API,</b> <b>click on Get Started Now,</b> <b>sign into your account.
</b> <b>And the nice thing about anthropic</b> <b>is that they do give</b> <b>you some free credits. </b> <b>And this is unfortunately something</b> <b>that OpenAI stopped doing. </b> <b>And that also seems to be</b> <b>why you guys want to move away</b> <b>from OpenAI as part of</b> <b>your learning process.
</b> <b>So after signing in,</b> <b>you should receive your free credits. </b> <b>To generate the API key,</b> <b>go to Get API Keys,</b> <b>then click on Create Key,</b> <b>give your key a name,</b> <b>like YouTube Tutorial,</b> <b>and create your key. </b> <b>Copy this key,</b> <b>then back in Flow-wise,</b> <b>go to Credentials,</b> <b>click on Add Credential,</b> <b>click on Anthropic API,</b> <b>give your credential a name,</b> <b>like Tool Agent Key or whatever you want,</b> <b>and paste in your API key.
</b> <b>Please ensure to use your own</b> <b>as I will delete my key after this video. </b> <b>Click on Add. </b> <b>Now let's create this flow.
</b> <b>Go to Chat Flows,</b> <b>then click on Add New. </b> <b>Let's save this. </b> <b>Let's give it a name.
</b> <b>I'll call mine Claude Tool Agent,</b> <b>and let's click on Save. </b> <b>As with any flow,</b> <b>we need either a chain or an agent. </b> <b>And in this example,</b> <b>we will add a Tool Agent.
</b> <b>So let's click on Add Notes,</b> <b>then under Agents,</b> <b>scroll all the way down to Tool Agent. </b> <b>Let's add this to the canvas. </b> <b>Great.
</b> <b>Now this note takes in a list of tools</b> <b>as well as a memory node. </b> <b>Memory is simply for keeping track</b> <b>of the conversation history. </b> <b>And we also have to supply a chat model</b> <b>that supports</b> <b>function calling or tool use.
</b> <b>Let's start by adding the chat model. </b> <b>Let's click on Add Notes,</b> <b>then we can close Agents. </b> <b>Let's go to Chat Models.
</b> <b>And because we want to</b> <b>add a Claude 3 model,</b> <b>we need to add this Chat</b> <b>Anthropic node to the canvas. </b> <b>Let's attach our chat model to the agent,</b> <b>like so,</b> <b>and under Credentials,</b> <b>let's select the Tool Agent Credential</b> <b>that we just created. </b> <b>And under Model Name,</b> <b>we have a list of a few models,</b> <b>Iku, Opus, and Sonnet.
</b> <b>You can see the</b> <b>differences between these models</b> <b>in the Anthropic documentation. </b> <b>Iku is a really cheap model</b> <b>that is fast and surprisingly accurate. </b> <b>And on the right-hand side,</b> <b>we have the most</b> <b>powerful model called Opus.
</b> <b>And Sonnet sits in the middle</b> <b>and is a good middle</b> <b>ground between performance,</b> <b>cost, and reasoning abilities. </b> <b>And if you look at how these models</b> <b>compared to the GPT and Gemini models,</b> <b>they pretty much</b> <b>outperform these other models</b> <b>in every other metric. </b> <b>So enough of that, let's</b> <b>continue with our flow.
</b> <b>Under Model Name, let's select Opus,</b> <b>which is the most powerful model. </b> <b>Let's change the</b> <b>temperature to something like 0. 2.
</b> <b>You will also notice this</b> <b>Allow Images Uploads toggle,</b> <b>and this is available</b> <b>because these Claude</b> <b>models are also multimodal</b> <b>and they have vision capabilities. </b> <b>This means that if you enable this toggle</b> <b>and save the chat flow,</b> <b>you will be able to</b> <b>upload images in the chat</b> <b>and ask questions about that image. </b> <b>But we will not use</b> <b>this in this tutorial,</b> <b>but I just thought</b> <b>it's a very cool feature</b> <b>to share with you.
</b> <b>Let's also go ahead</b> <b>and add the memory node. </b> <b>So let's go to Add Nodes,</b> <b>let's go to Memory,</b> <b>and let's simply add</b> <b>the buffer memory node. </b> <b>And let's connect this</b> <b>memory node to our agent.
</b> <b>Great, now for the tools. </b> <b>In this demo, I'm going to add three</b> <b>tools to this agent,</b> <b>but feel free to add as</b> <b>many tools as you want. </b> <b>In fact, if you go to</b> <b>Add Nodes and Tools,</b> <b>you can see a whole</b> <b>list of available tools,</b> <b>and you also have this custom tool</b> <b>that will allow you to write custom code</b> <b>for all you developers out there.
</b> <b>And with this custom tool,</b> <b>you can get the agent to perform</b> <b>pretty much anything you want. </b> <b>If you would like to learn more</b> <b>about things like the</b> <b>custom tool or the chain tool,</b> <b>then check out these</b> <b>other videos on my channel. </b> <b>Let's keep things simple for this demo.
</b> <b>Let's add a calculator to the canvas. </b> <b>I'll simply add some of these tools</b> <b>to the right-hand side of this agent,</b> <b>and we can attach a tool to the agent</b> <b>by clicking on the output from this tool</b> <b>and adding it to the</b> <b>tool input on the agent. </b> <b>Our tools work is when we</b> <b>ask the agent a question,</b> <b>the agent will see if</b> <b>there are any tools available</b> <b>that it can use to</b> <b>potentially answer our question.
</b> <b>So if we ask it a math question,</b> <b>it will see that we've</b> <b>supplied a calculator tool,</b> <b>and it will attempt to use that tool to</b> <b>answer the question. </b> <b>We can test that out</b> <b>now by saving the flow,</b> <b>and in the chat, let's first check</b> <b>if this is actually working. </b> <b>Let's simply write, hello,</b> <b>and we do get a response</b> <b>back from the Anthropic API,</b> <b>which means this is working.
</b> <b>Now let's ask a math question,</b> <b>like what is 500 times 10,000,</b> <b>just as a stupid little example. </b> <b>We get this response back,</b> <b>but what you will also notice is this</b> <b>little button up here</b> <b>showing us that the</b> <b>calculator tool was used,</b> <b>and if we click on this,</b> <b>this will show the inputs into the tool</b> <b>as well as the tool output. </b> <b>This can be very useful.
</b> <b>Let's also add the ability for the agent</b> <b>to search for information online,</b> <b>effectively perform a</b> <b>sort of a Google search. </b> <b>Let's go to add nodes, then within tools,</b> <b>let's add the SERP API node, like so,</b> <b>and then let's attach this</b> <b>node to the tools as well. </b> <b>For this node to work, we</b> <b>need to provide credentials.
</b> <b>So let's click on create new,</b> <b>let's give it a name</b> <b>like Claude tool agent,</b> <b>or whatever you want,</b> <b>and for the SERP API key,</b> <b>we can get the key from SERPAPI. com. </b> <b>Simply register or</b> <b>sign into your account,</b> <b>and don't worry though,</b> <b>there are no costs involved</b> <b>as we will be using the free tier.
</b> <b>From your dashboard,</b> <b>simply copy this API key</b> <b>and then paste it</b> <b>into Flow-wise, like so,</b> <b>and let's click on add. </b> <b>Let's save this chat flow,</b> <b>and our agent should now be able to</b> <b>search the internet. </b> <b>So let's ask a question</b> <b>like, what is Langsmouth?
</b> <b>This took a few seconds to execute,</b> <b>but we did get our response back</b> <b>and we can see that the</b> <b>search tool was indeed used</b> <b>with the input of Langsmouth,</b> <b>and we can also see the</b> <b>tool output over here. </b> <b>Now let's also add the</b> <b>ability for the agent</b> <b>to answer questions</b> <b>from a knowledge base. </b> <b>To demonstrate this,</b> <b>I've created this fictitious Q&A document</b> <b>for a restaurant</b> <b>called the Oak and Barrel,</b> <b>and this is a very simple document</b> <b>that contains some general information</b> <b>about this business.
</b> <b>So let's see how we can</b> <b>attach this knowledge base</b> <b>to our agent. </b> <b>Now I've already covered</b> <b>RAG chatbots in other videos,</b> <b>so please be sure to</b> <b>check out those videos as well</b> <b>if you get lost during this process. </b> <b>But what I want to do instead is focus</b> <b>on a very specific tool</b> <b>that will allow us to attach</b> <b>our vector store to the agent,</b> <b>and that is called the Retriever tool.
</b> <b>So let's add this to the canvas,</b> <b>and let's attach our</b> <b>tool to the agent, like so. </b> <b>We will set up all the</b> <b>RAG nodes in a second,</b> <b>but what this tool needs</b> <b>is a name and a description. </b> <b>For the name, I'm going to call it</b> <b>Restaurant Information,</b> <b>and the description is very important</b> <b>as this will be used by the agent</b> <b>to determine when this</b> <b>tool needs to be called.
</b> <b>In theory, you could</b> <b>have multiple retrievers</b> <b>from different data sources,</b> <b>and the description will tell the agent</b> <b>when these tools need to be called. </b> <b>Let's enter something like,</b> <b>use this tool when asked questions</b> <b>about the restaurant, food items,</b> <b>specials, and contact information. </b> <b>We can also enable</b> <b>return source documents</b> <b>to see where the model</b> <b>retrieved this information from.
</b> <b>Now we need to attach a Retriever,</b> <b>which is effectively our vector store. </b> <b>It's going to add nodes. </b> <b>Let's scroll down all</b> <b>the way to the bottom</b> <b>to vector stores, and let's add the</b> <b>in-memory vector store.
</b> <b>Feel free to use Pinecone</b> <b>or any other vector store that you want. </b> <b>It's attached this to the Retriever tool,</b> <b>and now the vector store</b> <b>requires an embeddings function</b> <b>as well as a document uploader. </b> <b>Let's start with the document.
</b> <b>Let's go to add nodes. </b> <b>Let's go to document loaders,</b> <b>and I'm going to use</b> <b>this docx file uploader</b> <b>because my knowledge</b> <b>base is a Word document. </b> <b>Let's attach this.
</b> <b>Let's select that file,</b> <b>and let's also add a text</b> <b>splitter to chunk the data. </b> <b>So let's go to text splitters. </b> <b>Let's add the recursive</b> <b>character text splitter,</b> <b>and let's attach our text splitter</b> <b>to the document uploader.
</b> <b>Let's change the chunk size</b> <b>to 200 with an overlap of 20. </b> <b>And lastly, let's add</b> <b>the embeddings function. </b> <b>This is something that a lot of you</b> <b>have been asking about as well,</b> <b>is which embeddings function to use.
</b> <b>You can use pretty much</b> <b>any embeddings function</b> <b>or model that you want. </b> <b>Just be sure to use</b> <b>the correct dimensions. </b> <b>And in fact, you can</b> <b>even use the open AI model</b> <b>if you want, but that is not</b> <b>what people do in this video.
</b> <b>Instead, if we have a look at the</b> <b>anthropic documentation,</b> <b>and if we scroll down, we</b> <b>can see this section that says</b> <b>that anthropic does not</b> <b>offer its own embedding model,</b> <b>but they do recommend</b> <b>that we use voyage AI</b> <b>for the embeddings function. </b> <b>And that is what we'll use in this video. </b> <b>So in our flow, let's go to add nodes,</b> <b>then let's go to embeddings.
</b> <b>Within embeddings, let's add</b> <b>the voyage AI embeddings node. </b> <b>And let's attach it to the vector store. </b> <b>Now, I know what some</b> <b>of you might be thinking.
</b> <b>You might be wondering</b> <b>what the dimensions would be</b> <b>if you had to use a persistent vector</b> <b>store like Pinecone. </b> <b>And I will show you that in a minute,</b> <b>but let's first get this</b> <b>simple example working. </b> <b>The voyage AI embeddings</b> <b>node requires credentials.
</b> <b>So let's click on this dropdown. </b> <b>Let's click on create new. </b> <b>Let's give our credential a</b> <b>name like Claude tool agent.
</b> <b>And now we have to</b> <b>populate this voyage API key. </b> <b>We can get the key by</b> <b>going to voyageai. com,</b> <b>then sign in, then from this dashboard,</b> <b>click on create new API key.
</b> <b>I will call mine Claude tool agent</b> <b>and click on create API key. </b> <b>Go ahead and copy this key,</b> <b>then paste it into flow</b> <b>wise and click on add. </b> <b>And then lastly, let's</b> <b>change the model name</b> <b>from voyage two to a voyage large two.
</b> <b>Let's save this chat flow. </b> <b>And that is actually all we have to do</b> <b>to chat with documents using our agent. </b> <b>You can simply swap</b> <b>out the document loader</b> <b>for any other file type</b> <b>and then simply absurd the</b> <b>data into your vector store.
</b> <b>In fact, let's absurd this</b> <b>data now by clicking on absurd. </b> <b>Let's click on absurd. </b> <b>So this is now chunked the data</b> <b>and added 29 records to the vector store.
</b> <b>Let's go ahead and</b> <b>test this out in the chat</b> <b>by asking what are the current specials? </b> <b>And looking at our FAQ document,</b> <b>we would expect the</b> <b>answer to be 50% off all stakes</b> <b>and happy hour between four and 6 p. m.
</b> <b>And looking at our chat, that</b> <b>is exactly what we received. </b> <b>We can also see that the</b> <b>restaurant information tool</b> <b>was called as well as the input</b> <b>and the output from our retriever. </b> <b>Now let's say you used</b> <b>a different vector store</b> <b>like pine cone.
</b> <b>Typically the embedding model will</b> <b>determine the dimensions</b> <b>that you have to enter</b> <b>when creating a vector store. </b> <b>As an example, if I log into pine cone</b> <b>and create a new index,</b> <b>you typically have to enter the</b> <b>dimensions for this index. </b> <b>And with open AI, it</b> <b>was something like 1536.
</b> <b>Now, because we're using the voyage AI</b> <b>embeddings function,</b> <b>what would the</b> <b>dimensions be based on the model</b> <b>that we selected here? </b> <b>Well, the answer is I simply went back</b> <b>to the anthropic documentation</b> <b>and I'm referring to the</b> <b>documentation that suggested</b> <b>that we use voyage in the first place. </b> <b>And in this</b> <b>documentation, if you scroll down,</b> <b>there is the section</b> <b>called available voyage models.
</b> <b>Here we can see the</b> <b>voyage large two model,</b> <b>which we used in this demo</b> <b>and this embedding</b> <b>dimension should be 1536. </b> <b>Or if you used any of the smaller models,</b> <b>you can simply use</b> <b>1024 as the dimensions. </b> <b>So we can simply copy this value</b> <b>and then use that to</b> <b>create our vector index.
</b> <b>I hope you enjoyed this video</b> <b>and I would like to</b> <b>know what other models</b> <b>you would like me to</b> <b>cover in future videos. </b> <b>Please hit the like</b> <b>button, subscribe to my channel</b> <b>and also have a look at this other video</b> <b>where we create a rag</b> <b>chatbot using open AI.