Skip to content

Latest commit

 

History

History
40 lines (32 loc) · 892 Bytes

README.md

File metadata and controls

40 lines (32 loc) · 892 Bytes

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