{"id":31794443,"url":"https://github.com/kanutocd/pgai-rails","last_synced_at":"2025-10-10T19:45:44.182Z","repository":{"id":308956847,"uuid":"1034541026","full_name":"kanutocd/pgai-rails","owner":"kanutocd","description":"Ruby on Rails integration for TimescaleDB's pgai PostgreSQL extension","archived":false,"fork":false,"pushed_at":"2025-08-08T21:12:44.000Z","size":50,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-08T23:26:46.279Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kanutocd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-08T14:56:50.000Z","updated_at":"2025-08-08T21:12:48.000Z","dependencies_parsed_at":"2025-08-08T23:26:55.411Z","dependency_job_id":"3aae9f5a-4c96-485c-829d-6afc189259b3","html_url":"https://github.com/kanutocd/pgai-rails","commit_stats":null,"previous_names":["kanutocd/pgai-rails"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/kanutocd/pgai-rails","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanutocd%2Fpgai-rails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanutocd%2Fpgai-rails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanutocd%2Fpgai-rails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanutocd%2Fpgai-rails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kanutocd","download_url":"https://codeload.github.com/kanutocd/pgai-rails/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanutocd%2Fpgai-rails/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005028,"owners_count":26083827,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-10T19:45:42.600Z","updated_at":"2025-10-10T19:45:44.177Z","avatar_url":"https://github.com/kanutocd.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pgai_rails\n\nRails integration for TimescaleDB's pgai PostgreSQL extension.\n\n**⚠️ This gem is in early development and not yet ready for production use.**\n\n## About\n\npgai_rails provides Rails-native integration with TimescaleDB's pgai extension, making AI-powered vectorization and semantic search simple and intuitive in Rails applications.\n\nTransform complex pgai SQL operations into familiar Rails patterns:\n\n```ruby\n# Instead of complex SQL vectorizer setup\nclass Post \u003c ApplicationRecord\n  include PgaiRails::Vectorizable\n  \n  vectorize :content, provider: :ollama, model: 'nomic-embed-text'\nend\n\n# Simple semantic search\nPost.semantic_search(\"machine learning\")\n```\n\n## Supported Providers\n\npgai_rails supports all major embedding providers that pgai supports:\n\n### Direct Providers\n- **Ollama** - Local and hosted Ollama models\n- **OpenAI** - text-embedding-3-small, text-embedding-ada-002, etc.\n- **Voyage AI** - voyage-2, voyage-code-2, etc.\n\n### LiteLLM Providers  \n- **Cohere** - embed-english-v3.0, etc.\n- **Mistral** - mistral-embed, etc.\n- **Azure OpenAI** - Azure-hosted OpenAI models\n- **Hugging Face** - Any embedding model from HF\n- **AWS Bedrock** - Amazon Titan and other Bedrock models\n- **Google Vertex AI** - textembedding-gecko, etc.\n\n## Usage Examples\n\n### Migration DSL\n\n```ruby\n# Create vectorizer for different providers\nclass CreatePostVectorizer \u003c ActiveRecord::Migration[7.1]\n  def up\n    # Ollama (default)\n    create_vectorizer 'posts' do\n      loading_column 'content'\n      embedding :ollama, model: 'nomic-embed-text', dimensions: 768\n      chunking :character, size: 512, overlap: 50\n    end\n\n    # OpenAI\n    create_vectorizer 'articles', name: 'articles_openai' do\n      loading_column 'body'\n      embedding :openai, model: 'text-embedding-3-small', dimensions: 1536\n      chunking :recursive, size: 1000, overlap: 100\n    end\n\n    # Cohere via LiteLLM\n    create_vectorizer 'documents', name: 'docs_cohere' do\n      loading_column 'text'\n      embedding :cohere, \n                model: 'embed-english-v3.0', \n                dimensions: 1024,\n                api_key_name: 'COHERE_API_KEY'\n    end\n  end\n\n  def down\n    drop_vectorizer 'posts_vectorizer'\n    drop_vectorizer 'articles_openai'  \n    drop_vectorizer 'docs_cohere'\n  end\nend\n```\n\n## Installation\n\nAdd to your Gemfile:\n\n```ruby\ngem 'pgai_rails'\n```\n\n## Requirements\n\n- Ruby \u003e= 3.2.0  \n- Rails \u003e= 7.1 (ActiveRecord, ActiveSupport, Railties)\n- PostgreSQL with pgai extension installed\n- TimescaleDB (optional but recommended)\n\n### Configuration\n\n```ruby\n# config/initializers/pgai_rails.rb\nPgaiRails.configure do |config|\n  config.default_provider = :ollama\n  config.ollama_base_url = 'http://localhost:11434'\n  config.default_model = 'nomic-embed-text'\n  config.default_dimensions = 768\n  config.fallback_on_error = true\n\n  # Configure provider-specific settings\n  config.configure_provider :openai, api_key: ENV['OPENAI_API_KEY']\n  config.configure_provider :cohere, api_key: ENV['COHERE_API_KEY']\nend\n```\n\n### Provider-Specific Examples\n\n```ruby\n# Ollama with custom parameters\nembedding :ollama, \n          model: 'nomic-embed-text', \n          dimensions: 768,\n          base_url: 'http://custom-ollama:11434',\n          model_parameters: 'temperature:0.1',\n          keep_alive: '5m'\n\n# OpenAI with automatic dimensions\nembedding :openai, model: 'text-embedding-3-small' # dimensions auto-detected\n\n# Cohere with search optimization  \nembedding :cohere, \n          model: 'embed-english-v3.0',\n          dimensions: 1024,\n          input_type: 'search_document',\n          api_key_name: 'COHERE_API_KEY'\n\n# Azure OpenAI\nembedding :azure_openai,\n          model: 'text-embedding-ada-002',\n          api_key_name: 'AZURE_OPENAI_KEY'\n\n# Hugging Face model\nembedding :huggingface,\n          model: 'microsoft/codebert-base',\n          dimensions: 768\n\n# AWS Bedrock  \nembedding :aws_bedrock,\n          model: 'amazon.titan-embed-text-v1',\n          dimensions: 1536\n```\n\n## Rails Integration\n\npgai_rails provides convenient Rake tasks for Rails applications:\n\n### Generate Initializer\n\n```bash\nrails pgai_rails:init\n```\n\nCreates `config/initializers/pgai_rails.rb` with comprehensive configuration options for all supported providers.\n\n### Check System Status\n\n```bash\nrails pgai_rails:status\n```\n\nDisplays:\n- pgai and pgvector extension availability\n- Current configuration settings\n- Active vectorizers in your database\n\n### List Providers\n\n```bash\nrails pgai_rails:providers\n```\n\nShows all supported embedding providers with usage examples.\n\n### Reset Extension Cache\n\n```bash  \nrails pgai_rails:reset_cache\n```\n\nClears cached extension detection results.\n\n## Status\n\nThis gem is under active development. **Phase 1 (Foundation)** and **Phase 2 (Migration Helpers)** are complete with comprehensive provider support and Rails integration.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pgai_rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/pgai_rails/blob/main/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the PgaiRails project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/pgai_rails/blob/main/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkanutocd%2Fpgai-rails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkanutocd%2Fpgai-rails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkanutocd%2Fpgai-rails/lists"}