Example repo for using AI with Ruby. Uses pgvector for PostgreSQL vector storage and the neighbor gem for vector similarity search.
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
ruby semantic_search.rb
ruby document_similarity.rb
ruby rag.rb
ruby image_similarity.rb