GithubHelp home page GithubHelp logo

zakinator123 / ask-airy Goto Github PK

View Code? Open in Web Editor NEW
11.0 4.0 1.0 14.11 MB

An Airtable extension that enables semantic search and Q&A using gpt-3.5

Home Page: https://askairy.com

License: MIT License

JavaScript 0.68% Shell 0.28% TypeScript 99.04%
airtable-block embeddings gpt-3 openai semantic-search

ask-airy's Introduction

Ask Airy

An Airtable AI assistant enabling semantic search and GPT-powered Q&A

Project license Build


See it in Action

How it Works

Ask Airy is an Airtable extension that enables you to intuitively search and query data in Airtable with natural language using GPT-3.5 and embeddings-based semantic search. Let’s say you have a text-heavy database containing, for instance, product/customer reviews. With Ask Airy, you can ask a question like “Find and summarize negative reviews. Create a list of action items for improving the product design to address the feedback. Cite relevant review IDs in your response.” and get a data-backed response back in natural language. Airtable is a “no-code” relational database platform with a UI similar to google sheets. While this extension was built for Airtable, the architecture/logic is applicable to any application with relational/tabular data. At its core, the application works by:

  1. Generating embeddings using OpenAI’s embeddings endpoint for each row in a table and storing them as another column within the table.
  2. When a user enters a query/question, it generates a hypothetical document embedding ( HyDE) to use for a semantic search. (link to code)
  3. Executes a semantic search via cosine similarity ([link to code](link to code))
  4. Stuffs the most relevant records, along with the user’s original query into a GPT-3.5 prompt
  5. Streams the LLM response back to the UI, and shows the user the (potentially) most relevant records for their query.

Takeaways/Lessons:

  • All the prompt engineering for this project is in the OpenAIService.ts An interesting problem was staying under the RPM/TPM rate limits for the OpenAI embeddings endpoint when bulk generating embeddings for the database tables. My rate limiter approach can be found here.
  • I was able to stream the chat completion response to a React component using npm: openai-streams along with a custom React hook I wrote.
  • Given that this project employs context stuffing with gpt-3.5, staying under context window token limits was important. I found that estimating tokens with the “num characters divided by 4” rule of thumb was not reliable, especially when things like URLs were in the input string. While OpenAI provides a tokenizer for counting tokens in python, there is no official JS tokenizer. I ended up using npm: gpt3-tokenizer even though it only provides tokenization using the r50k_base encoding. GPT 3.5+ uses the cl100k_base encoding, but I found that their tokenization outputs were similar enough.

License

This project is licensed under the MIT license.

See LICENSE for more information.

ask-airy's People

Contributors

zakinator123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

tatonka21

ask-airy's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.