• Stars
    star
    152
  • Rank 244,685 (Top 5 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 1 year ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

LLM powered agent that analyses SQL databases.

Friendly LLM agent that dashboards like an analyst

This works on any SQL database! You might need to play with the prompts in the chains folder to get it working best for your use case. The world is your oyster!

I wrote a guide about how it works on my company blog.

llm-analyst.in.action.mp4

Setup

Make sure to install the dependencies:

# npm
npm install

This uses Relevance AI to deploy and run the LLM chains. Then install the Relevance AI SDK, authenticate and deploy the chains. Docs for Relevance AI.

npm install @relevanceai/chain -g
relevance login
relevance deploy

relevance deploy will deploy the chains in this repo into hosted APIs that the frontend chain client can run. Note, you will have to add your LLM (such as Open AI) key into Relevance - you can run relevance keys to bring up the page to do this.

Also add your Relevance region and project to the demo-config.ts file to power the frontend chain client.

export const REGION = '';
export const PROJECT = '';

Finally, set up an SQL database (I used a Planetscale database for free) and add a .env file with:

DATABASE_HOST=
DATABASE_USERNAME=
DATABASE_PASSWORD=
DATABASE_URL=

Then run npm run upload to populate your database with sample data! It inserts 2000 documents at a time, so you can run it more than once if you want more data.

Development Server

Start the development server on http://localhost:3000

npm run dev