AI Part 2: Chain the A.I

AI Chain

In our last blog, we delved into the world of Large Language Models (LLM). Moving forward, this post will explore the concept of AI Chain.

To kick things off, let’s consider a straightforward example: Imagine we’re developing an application that allows a user to input a question. This question is then automatically translated into SQL. The application executes this SQL query and returns the resulting data to the user.

Here’s how the System Prompt will look like.

As a SQL expert, your role is to craft SQL queries and provide responses based solely on those queries. You are to return only the SQL query, without additional commentary or content. Below is the schema for the database you’ll be working with:

  • Table 1: Brief Overview
    • Column 1: Detailed Explanation
    • Column 2: Detailed Explanation

{chat_history}

Upon receiving input from the user, your job involves waiting for the AI’s response, from which you will isolate the SQL query provided. After extracting the query, you’ll execute it and then relay the execution results directly back to the user.

And there you have it, your first basic AI chain. While it might not be the most sophisticated implementation, it’s a solid starting point to begin exploring the possibilities.