LangGraph: Build Your Own AI Financial Agent Application (Beginners)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
this is amazing now we are going to create a financial agent application which is capable of checking the stock price getting the latest news getting the detailed financial report and getting a historic price of a company we are going to do this using Lang grath mainly focusing on beginners in this first we are going to create tools then we are going to assign those tool to an agent then we are going to create a graph which coordinates the work between agent and tools finally we we going to add an user interface using radio that's exactly what we're going to see today let's get [Music] started hi everyone I'm really excited to show you about financial Agent app using langro I'm going to take you through step by step on how to create this and add a user interface to that but before that I've regularly create videos in regards to Artificial Intelligence on my YouTube channel so do subscribe and click the Bell icon to stay tuned make sure you click the like button so this video can be helpful for many others like you so First Step cond create hyphen and langro python equal 3.11 and then click enter next cond activate langro and then click enter if you have an installed cond in your computer you should be able to download from this website next export your open a AP like this and then click enter next export your polygon API key like this and then click enter polygon is the API service which we are going to use which is capable of getting all the financial information latest news and then stock price about a company you should be able to sign up to polygon for free and then get your your API keys from here so once after enter API key click enter now pip install langro Lang chain Lang chain open Lang chain Hub polygon APA client and then click enter now let's create a file called app.py and let's open it as we've seen before we are going to follow three steps first to create tools next creating agent and third graph that is the pipeline or the workflow so first step defining tools our agents can use so we importing the required package like OS Hub create open ey function agent chat open AI polygon API wrapper then the four polygon tools now we are setting up the prompt template we are using Lang chain Hub so you should be able to see the prompt in this location and here is the prompt in Lang chain Hub so it's just a basic template with a system message human input is input now we are going to Define lar language model that is gbd4 Turbo preview next we are defining the polygon API wrapper to get the list of tools and then we are assigning the tools so four different tools in the list format so this tool is capable of getting the stock price latest news financial report and historic price now step number two is creating defining agent and helper functions importing runnable p through agent finish now we are defining the agent so this is where the agent gets created using this create openai function agent we are passing the large language model the list of tools and the prompt which we already configured in the first step very simple as that next agent equals runable pass through and assign so we are assigning that agent to agent outcome that means the output of the agent is assigned to agent outcome now we're going to define the function to execute tools so execute tools function is same like function calling so if the lar language model think that it requires a tool to perform a task for example if it wants to get the latest stock price the large language model won't have the inform of the latest stock price so it is going to use the tool which we have assigned before so if the user ask a question what's the stock price of Apple to the AI agent then the AI agent will be using the financial tools which we have assigned then the tool or the API is able to get the latest stock price and then the response is sent to the AI agent again at the end we'll get an answer like this so that's exactly happening here so this gets the output from the L language model get the stock price and return the real time stock price value now we're going to define the logic so here we are defining a condition if the agent outcome is Agent finished then it should stop running if the agent outcome is to use the tool then it should continue this is called conditional Edge in langro now the final step is to define the Lang here we are importing end and graph next we are defining the workflow that is the graph next adding the node node is nothing but a AA agent or a tool similarly we going to add tools and the execute tools function next we are setting an entry point where it should start so the first step is that the user is going to ask the agent so that's the entry point next we are adding a conditional logic so this is where we are going to use this should continue function so probably this should come under the Define the langro step so this should continue is the condition which allows the agent to continue with the tools or end the process next we going to create Edge using add edge that means whenever a request come to the tools the output should be sent to agent next we're going to define the chain workflow. compile just compiling the whole graph the final step result equals chain. invoke function so this is the place where we going to ask a question so what has been a B and B's daily closing price between March 7 2024 and March 14th 2024 now output equals agent outcome return values output finally we are printing the output that's it so as a quick overview first we set up the four tools in the second step we created agent and a function to execute the tool the third step defining the Lang graph the condition when an agent should pass the requested tool or exit here we are defining all the workflow adding notes adding entry point and finally we are invoking the chain and asking a question now I'm going to run this code in your terminal python. pi and then click enter so this is going to get the ab and B's daily closing price between the DAT range and here is the answer it used the tool which is a polygon API and got these answers now let's add user interface to this I made a slight modification to create a user interface I just imported gradio then move the result and the output inside a function called Financial agents this is going to get the input process the request and return the output and adding one input and one output inside gr. interface finally interface. launch this will automatically create the user interface for us now I'm going to run this code in your terminal python U.P now I'm going to open this URL and here is the interface so first I'm going to ask what's the latest financial report for NVIDIA and click Summit and here is the output comprehensive income balance sheet highlights income statement highlights cash flow statement highlights similarly I asked can you show me the most recent news from Google and it used the tool or the API and got this answer next I asked track the historical performance of Microsoft and it went through different years and got the historical data then I asked what has been AB bnb's daily closing price between the these dates and it gave me this answer I'm really excited this I'll provide all the code in the description below so you can try and let me know in the comments below how it is I hope you like this video do like share and subscribe and thanks for watching
Info
Channel: Mervin Praison
Views: 9,373
Rating: undefined out of 5
Keywords: langgraph, langgraph tutorial, langchain langgraph, langgraph explained, langgraph demo, langgraph in action, ai agents, langgraph agents, langchain agent, langchain agents, lang graph, graph, lang, langraph, langgraph beginners, langgraph guide, langraph tutorial, langraph guide, langgraph finance agent, langgraph finance, langgraph agent, langgraph finance app, Polygon, langgraph polygon, polygon agent, langchain polygon, polygon app, polygon.io, stock price, company news
Id: C8wvHKPlTls
Channel Id: undefined
Length: 7min 43sec (463 seconds)
Published: Tue Mar 19 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.