How to Set Up SnowBrain: Your Personal Data Analyst

Nov 9, 2020 | Data Science

SnowBrain is an open-source prototype designed to transform the way you interact with databases by making SQL queries conversational. It utilizes modern technologies such as Snowflake, OpenAI, and FastAPI to provide a seamless experience in data analysis. This guide will walk you through the process of getting SnowBrain running on your local machine.

Understanding the Tech Stack

Before diving into the installation steps, let’s quickly break down the tech stack that powers SnowBrain:

  • Snowflake: For data storage and cloud management.
  • Next.js: Serving a robust frontend and backend.
  • Supabase: The database solution for persisting chat messages.
  • Tailwind CSS: For sleek styling of the application.
  • Pinecone: The vector database that enhances search capabilities.
  • OpenAI: Utilized for advanced language processing.
  • Langchain: Acts as a wrapper for the language model.
  • Cloudinary: Manages image data efficiently.
  • Clerk.dev: Handles secure user authentication.
  • Upstash Redis: Manages rate limiting for API requests.
  • FastAPI: A high-performance web framework for building APIs.
  • Modal Labs: Hosts the backend FastAPI.
  • Vercel: For easy deployment of your application.
  • Umami: Provides web analytics for tracking user engagement.

Installation Steps

Ready to set up SnowBrain? Follow these steps carefully to get your personal data analyst working:

  1. Update Environment Variables
    Make sure to update the environment variables as necessary. Refer to the provided example:
    bash
        .env.example
  2. Auto Fetch All Schema DDL
    Run the following command:
    bash
        python3 embed/snowflake_ddl_fetcher.py
    Ensure you’ve installed the required dependencies:
    bash
        pip3 install -r embed/requirements.txt
  3. Convert DDL Documents to Vector and Upload to Pinecone
    Use the following command:
    bash
        python3 embed/embed.py
  4. Install Dependencies for the Code Plugin
    Navigate to the code-plugin directory and install necessary dependencies using Poetry:
    bash
        cd code-plugin
        poetry install
  5. Deploy FastAPI to Modal Labs
    Deploy your FastAPI application with:
    bash
        modal deploy main.py
    Make sure to add a secrets file in Modal Labs and store your endpoint in environment variables:
    bash
        MODAL_API_ENDPOINT=
        MODAL_AUTH_TOKEN=random_secret
  6. Install Packages
    Run the following command to install packages:
    bash
        bun install
  7. Run Locally
    Test your setup with:
    bash
        bun run dev
    Then test the build:
    bash
        bun run build
  8. Deploy to Vercel
    When you’re ready, deploy the project to Vercel. Note that Vercel build is automatically blocked on certain folders and files. Consider adding a build block command in the Vercel dashboard.

Example Queries

SnowBrain is designed to simplify SQL querying. Here are a few examples you can try:

  • Total revenue per product category: Show me the total revenue for each product category.
  • Top customers by sales: Who are the top 10 customers by sales?
  • Average order value per region: What is the average order value for each region?
  • Order volume: How many orders were placed last week?
  • Product price listing: Display the list of products with their prices.

Troubleshooting Tips

If you encounter issues during installation or running SnowBrain, consider these troubleshooting tips:

  • Ensure all environment variables are correctly set.
  • Check that all dependencies are installed properly using the relevant package managers.
  • If the API doesn’t respond, verify your Modal Labs configuration.
  • Refer to your terminal output for error messages, which often provide clues for resolutions.
  • For any persistent issues, check the official issues page on GitHub for help.
  • For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

Now that you have SnowBrain set up, you can start enjoying a new way of querying and analyzing your data! This innovative tool not only makes data exploration easier but also enhances your ability to interact with your dataset through a conversational interface.

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox