Turn your CSV file into an AI Agent
AI Agents are amazing. However, once you've got the ability to have OpenAI and ChatGPT invoke functions in your backend, the remaining problem becomes an issue of "bridging" data. In the video below I am demonstrating how you can turn your CSV file into an AI Agent in some 5 minutes without coding.
1. Import your CSV file
First you need a database. In the video above I create a new SQLite database, but you could use any database type that Magic supports.
Once you've got a database, you need to import your CSV file into it. This process will automatically create a new table for you, based upon the filename of your CSV file - So you might want to give your CSV file a sane name before you start the process. This process might also change column names to avoid having non-Latin characters in your DDL. To avoid this, you might want to consider changing column names before you start. Inside of SQL Studio click the "..." button after having selected your database, then choose "Import CSV file."
Notice, if you import the same CSV file multiple times, it will add these as new rows to your table, and not delete or overwrite existing records.
Also realise that you can import multiple CSV files into the same database, since each CSV file will create a new table for you based upon the filename. However, if you want to import into an existing table the table schema needs to match your CSV file, and the filename needs to match your table.
2. Generate a CRUD API
When you're done with the above, you'll need to generate a CRUD API. This is done in the Manage / Endpoint Generator component, and takes some few seconds.
3. Create a Machine Learning Type
The next thing you'll have to do, is to create a machine learning type. This is just a collection of RAG training snippets, in addition to a system instruction and some other settings. As you create it, make sure you choose the "AI Agent" flavour. If you don't have this flavour, you can install the OpenAI plugin to get access to it.
4. Generate AI functions
When you're done with the above, you'll have to generate AI functions wrapping your CRUD API and associate these with your machine learning type. Go to Create / Hyper IDE and expand your modules folder. Find the newly created folder here, hover over it, and click the flash icon. Then select your newly created machine learning type, and click generate.
5. Vectorize your type
Now you're almost done, and all that remains is to create embeddings for your RAG data in your machine learning type. Go to Manage / Machine Learning and click vectorize on your type.
And you are now done. If you don't already have the AI Expert System installed, you can install this from plugins under manage. Below is roughly how it will look like when interacted with.
Wrapping up
Creating an AI Agent from a CSV file have lots of use cases. It allows you to use natural language for data gathering, you can even have it generate charts and graphs, and it allows you to rapidly find data in your CSV file and analyse it using AI.
The process described in this article, probably scales to CSV files with maybe 50,000 to 100,000 records. If you have larger files, you will probably want to use an external PostgreSQL or MySQL database, instead of the internal SQLite database Magic comes with out of the box. However, for most CSV files this is probably more than enough. If you've got larger files, you can contact us for a quote.
And please realise that turning your existing CSV-based AI agent into an AI SaaS company is easy due to our white label options.
Have a Custom AI Solution
At AINIRO we specialise in delivering custom AI solutions and AI chatbots with AI agent features. If you want to talk to us about how we can help you implement your next custom AI solution, you can reach out to us below.