AutoGen + LangChian + SQLite + Schema Function = Super SQL Chabot

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
over the past year I have built many AI chatbots most of them built on autogen and Lang chain so in this video I am going to be teaching you everything that I know about building a super AI chatbot using autogen Lang chain SQ light and function schema so that you can have the same sort of success as AI engineering by utilizing this amazing new technology you will be able to copy and paste my code and get started with building these super ey chat Bots for your business and your personal use as quick as possible but the best part about what I'm about to show you is that this method is going to give you complete flexibility and customization over how your app works and how the sqlite and function schema are processed definitely stay tuned throughout the end of this video If you guys haven't followed me I highly recommend that you do so so you can stay up to date with the latest AI news lastly make sure you guys subscribe turn the notification Bell like this video and check out previous videos because there is a lot of content that you will definitely benefit from so that thought let's get right back into the video for those who may not be as familiar with technical details let me provide a bit of background to make things easier to understand what is SQ light SQ light is one of the most popular databases for embedded software development essentially it is a library written in C that offers a relational database management system SQ light is an open-source serverless flexible crossplatform that doesn't require configuration and can manage low to medium traffic levels sqlite is a Preferred Choice among database administrators and software developers alike due to its Simplicity and efficiency what is the function calling schema the function calling schema in the context of gp4 apis allows a user to describe functions and have the model intelligently choose to Output a Json object containing arguments to call one or many functions the schema includes the description and parameters of the available functions allowing the model to execute arbitrary function calls and even potentially Aid in attacking the functions let's start coding we need to build a system that can run SQL commands directly from autogen to do this the process involves several steps first we'll examine the available tables then create and run an SQL query and finally present the results in a format like text graphs or tables although this process involves multiple steps and can seem complex we're going to use the Lang chain mechanism to make handling SQL from autogen much easier to make things easier we've set up a way to use SQL through something we're calling function calling this is possible using the agent tool kit in Lang chain as for the database I chose sqlite since it's simple to set up however if it's compatible with Lang chain you're also free to use other databases like myql or post gql let's start installing the requirements assuming you have created a new python project and set up a virtual environment run the command let's import the required dependencies first let's create the database that will be used by the agent I'll make something simple for now create a book's table author's table and Publishers table we go and use SQ database specifically to create and populate a bookstore database it defines two functions create table and insert data for create tables and inserting data respectively the script then establishes a connection to a database file named bookstore. DB and uses the defined functions to create three tables books authors and Publishers each with relevant Fields after creating these tables it inserts sample data into them these tables are related to each other books references authors and Publishers through author ID and publisher ID the script ensures all changes are saved to the database with con. comit and then closes the cursor then we will load the database using the Lang chain mechanism by using the SQL database toolkit provided by Lang chain you can execute SQL in natural language let's create a function calling schema to call the created toolkit as follows convert the toolkit parameters using the generate LM config function and save them to the tool schema also the tool run calls Lang Chain's toolkit and register ERS it in the function map let's set up the list to autogen we create the config list as follows config list is a list containing configuration settings for the model you intend to use timeout set to 1 20 this represents a timeout value in seconds with this configuration we are ready to use AI agents with autogen let's create an agent as usual when multiple conversations are in progress the open AI agent returns terminate when the task is finished and the user proxy stops working also register the function map created earlier once the agents are set up the script starts a conversation between the user and the chatbot this is done by calling the initiate chat method on the user proxy object the initiate chat method requires two parameters the scl chatbot instance which acts as the chatbot and a text message that outlines the task to be discussed then I will give it a question of how many books are in the database the result looks like like this let's wrap it up by applying function calling like this we can effectively utilize Lang Chain's capabilities in my recent experiment I used this method to manage SQL considering that databases are common in many settings but writing queries can be challenging for many especially those who aren't Engineers I believe this kind of feature would be really helpful I will leave all these links in the description below so that you can easily access them it's a great read and it'll give you a lot more understanding as to how they basically accomplished this so with that thought I genuinely hope you found it informative and valuable if you did please give it a thumbs up and consider subscribing for more content like this don't forget to click the notification Bell so you never miss an update from us if you have any questions or thoughts drop them in the comments below I always love hearing from you until next time stay curious and keep learning
Info
Channel: Gao Dalie (高達烈)
Views: 2,783
Rating: undefined out of 5
Keywords:
Id: YB9M5tNAZVs
Channel Id: undefined
Length: 6min 27sec (387 seconds)
Published: Wed Jan 03 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.