Skip to content

eagerworks/ruby_ai_intro

Repository files navigation

Ruby + AI example

Example repo for using AI with Ruby. Uses pgvector for PostgreSQL vector storage and the neighbor gem for vector similarity search.

Setup

Install pgvector for PostgreSQL vector similarity search.

Create the database

createdb rails_ai_test

If you are using another database, set the DATABASE_NAME environment variable.

Export OpenAI API key as OPENAI_API_KEY.

export OPENAI_API_KEY=<your-openai-api-key>

Export Jina AI API key for image embeddings as JINA_AI_API_KEY.

export JINA_AI_API_KEY=<your-jina-ai-api-key>

Install dependencies

bundle install

Run the scripts

Text

ruby semantic_search.rb
ruby document_similarity.rb
ruby rag.rb

Images

ruby image_similarity.rb

About

Example code for using AI with Ruby/Rails

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages