I Built an AI Financial Advisor in 10 Minutes using LangChain with Chain of Thought & ReAct

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone this is Richard Walker from lucidite  in today's video we're going to be looking deeper   into Financial AGI the ability to pose general  questions and have our AI figure out a plan and   break down the question into a series of subtasks  and then have the AI execute each of these   subtasks and get the right answer back to the  user I'm going to be talking about the power of   building custom tools for your Lang chain agents  I'll explain the benefits then walk through how to   actually add the tools and finally demo building  a cool Financial assistant using these custom   tools at the end of the video I'll explain how  lucidates YouTube members at specific levels of   membership can get access to the source code for  this application to make it their own and develop   it in any way they see fit buckle up because  this is going to be jam-packed with awesome   information first why would you even want to build  custom tools well the main benefits are increased   flexibility control and specialization with the  modular open source nature of Lang chain you can   customize it extensively for your specific needs  don't like something about an existing tool tweak   it have an idea for a totally new capability  build it you have the flexibility to shape your   AI agents however you want you also get more  control over your AI agent's behavior when you   add custom tools instead of being limited by  default constraints you decide how it should   operate based on your custom tools want it  to interact in a certain way build tools to   enable that additionally by training on your own  data sets and configuring tailored tools you can   specialize your agent for different domains like  Finance as in this example the sky is the limit   on specialization when you build your own tool  all right so now let's look at how to actually   add tools the main way is by creating a class  that subclasses Lang chains base tool you'll   Implement an under run method that contains the  logic for that tool input arguments and outputs   Can Be Strings but you can also Define schemas  for more complex structured data another option   is using the at tool decorator just decorate any  function with it and Lang chain converts it into   a tool for you The Decorator even sets the name  and description from the function okay time for   a demo let's use some custom tools to build  a financial assistant the bot will leverage   tools for getting stock price data analyzing  stock fundamentals retrieving news articles and   making stock recommendations for the stock data  tool we'll use the Y Finance Library we subclass   tool take in a ticker symbol and return  historical prices we'll do a similar   thing for the stock info tool this time we'll  return fundamentals rather than stock prices   the news tool will call the news API to get  recent articles for a company in the same way as   we developed the stop tool we'll create a separate  python class that subclasses the Lang chain base   tool and adds the functionality to retrieve news  rather than stock data in its under run method   the AI uses whichever large language model you  have specified in your chain to perform a couple   of foundational steps using prompt engineering  these are plan and execute and Chain of Thought   by using these two prompt engineering steps  in conjunction it can develop a strategy   to utilize the tools that you've provided to  better answer the question it has been asked   it firstly uses the Chain of Thought prompt to  break down the question into a series of steps   these steps then become part of the plan and  execute prompt the AI uses the description of   the tools provided to determine which one is best  suited for each step it matches the best tool to   the question posed in each step using a large  language model it then carries out each step   and Aggregates the final answer for the question  posed which it then returns to the user interface   Let's test it out as before we'll have the app on  the screen as well as my IDE in the console of the   integrated development environment you can see  the steps that the AI is taking as it decomposes   the question using Chain of Thought and then uses  plan and execute to use the tools at its disposal   we'll start with a simple question to test out  the news tool can you summarize the latest news   for Microsoft firstly in the application interface  the app outputs the question and the llm settings   that have been sourced from the sidebar in  this case the June 13th version of gpt4 with   a temperature of 20 the next thing to note in  the console is the result of the initial Chain   of Thought prompt the AI has decided that this  can be broken down into the following steps one   identify the company msft which is the ticker  symbol for Microsoft Corporation 2. search for   the latest news articles three read the articles  to understand the key points four summarize the   Articles five given these steps return the summary  to the user interestingly the first thing that the   AI decides to do is use the stock tool it uses  this to confirm that the ticker msft refer goes   to Microsoft Corporation it then uses the news  tool and retrieves a bunch of recent news about   Microsoft it uses this to summarize the key points  from the Articles this summary is then written   to the user in the application GUI well so far so  good now let's get a lot more sophisticated after   all we've built something that could not just  access news but also access up to the minute stock   information too let's make our query more complex  and as well as asking for a news summary also ask   for some financial information too we'll provide  our investment appetite and some information about   our current portfolio and we'll also request  the stock price the key fundamentals and a news   summary a lot of useful information for the AI  to process to generate its Chain of Thought steps   as you would expect the cot prompt results in  a different set of steps to be passed to the   plan and execute prompt it begins with a plan to  find out the current stock price followed by some   fundamental analysis it lists some specific  fundamentals and ratios to help with the buy   or sell decision logically based on the question  its next step is to conduct a news review it then   proposes combining the results of Prior steps  to come up with an overall investment outlook   for this stock it then uses some specific  information about the user's risk appetite   and portfolio composition to turn this generic  Outlook into a specific recommendation the final   step is to provide a response to the user via  the GUI the result of all of this is a positive   if qualified recommendation to continue to  acquire the stock as with much investment   advice this is appropriately caveated with an  encouragement for the user to perform necessary   due diligence and additional research before  committing to a purchase it does not consider   recommending disposing of the Nvidia position in  the user's portfolio so we're now building some   very complex decision-making tools to be able to  respond cogently to complex and nuanced questions   from an investor the AI is able to reason about  the problem and logically decompose this problem   into a sequence of steps using cot prompting  these steps then form a basis for a plan and   execute strategy where the AI will further reason  about the best tool to use at each step the choice   of tool is based on the tool description and  the action or question posed at each step so   to do all of this we've made a lot of use of  lots of components of Lang chain specifically   its methodology for adding custom tools that can  be accessed by Lang chain agents we've used this   Custom Tool approach alongside out of the box  tools provided by in the last video we looked   adding a stock tool for this video we've added a  news tool using the news API lucidate members at   the vice president level can get access to all the  source code for this application they can then use   it as a basis for their own experimentation and  application development members of the managing   director level can get access to exclusive videos  including a Code walkthrough of this demo app   in the next video we'll tackle The crucial  question of resilience and robustness as   these questions actions and queries are getting  more and more complex so the potential for the   unexpected occurs I've had a few errors myself  with this code where a prompt at each step is   too complex perhaps passing a list of required  fundamentals and ratios to the info tool or   passing a list of stocks to the stock price tool  in the next video we'll look at techniques for   increasing robustness and gracefully dealing  with these conditions if you've enjoyed this   video don't forget to share it with others who  may be interested as well as smashing the like   button and hitting subscribe if you haven't  already hit the notification Bell so that you   never miss another Lucid date video and for those  wishing to take a deeper dive consider joining the   lucidate members program at the vice president  level for access to the code for this demo or   the MD level for exclusive content including  a Code walkthrough see you in the next one foreign
Info
Channel: Lucidate
Views: 1,635
Rating: undefined out of 5
Keywords: langchain, financial assistant, ai assistant, custom tools, finance, investment, stock market, algorithmic trading, robo advisor, ai advisor, finance bot, nlp, conversational ai, prompt engineering, coder tutorial, python programming, ai development, machine learning, deep learning, artificial intelligence, financial analysis, financial modeling, fintech, data science, coding tutorial, python, youtube tutorial, video tutorial, api tutorial, bots, chatbot, langchain tutorial
Id: UUs6bzLoB1M
Channel Id: undefined
Length: 11min 0sec (660 seconds)
Published: Mon Jul 24 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.