Skip to content

pifleo/rails-openai-embedding-with-pgvector

Repository files navigation

How to build an AI chatbot with Ruby on Rails and ChatGPT

How to build an AI that can answer questions about your website.

This tutorial walks through a simple example of crawling a website (in this example, the Rubyroidlabs website), turning the crawled pages into embeddings using the Embeddings API, and then creating a basic search functionality that allows a user to ask questions about the embedded information. This is intended to be a starting point for more sophisticated applications that make use of custom knowledge bases.

Inspired from this blog post: https://medium.com/@rubyroidlabs/how-to-build-an-ai-chatbot-with-ruby-on-rails-and-chatgpt-9a48f292c37c

Table of Contents

  • Introduction

  • Setup

    • Initialize Ruby on Rails project with PostgreSQL
    • Setup PGVector
    • Setup OpenAI
    • Build a simple chat with Hotwired
  • Prototype

    • Chat API
    • Deal-breaker
  • Embeddings

    • Data Chunks
    • Vector
    • How to find the most relevant chunks
  • Summary

About

Ruby On Rails demo project of OpenAI embedding with PostgreSQL Vector

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published