https://github.com/hwvs/embedding-prompted-search-ruby
Ruby library for searching documents/books using OpenAI API Embeddings to find relevant text, enabling (GPT-4) LLM-based tasks such as answering questions about authors or their books with context provided by the related embeddings.
https://github.com/hwvs/embedding-prompted-search-ruby
Last synced: 11 months ago
JSON representation
Ruby library for searching documents/books using OpenAI API Embeddings to find relevant text, enabling (GPT-4) LLM-based tasks such as answering questions about authors or their books with context provided by the related embeddings.
- Host: GitHub
- URL: https://github.com/hwvs/embedding-prompted-search-ruby
- Owner: hwvs
- License: mpl-2.0
- Created: 2023-05-08T19:49:22.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-16T22:00:18.000Z (almost 3 years ago)
- Last Synced: 2025-03-24T00:57:25.551Z (about 1 year ago)
- Language: Ruby
- Homepage:
- Size: 64.5 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Embedding-Prompted-Search-Ruby

Ruby library for searching documents/books using OpenAI API (GPT) to find related embeddings, enabling LLM-based tasks such as answering questions about authors or their books with context provided by the related embeddings.
# Todo
- Create a "factory" or "builder" class to do all of the heavy-lifting
- ~Auto-detect which provider to use for a document based off of MIME/extension?~ (done)
- Clean up the class names which might not meet Ruby standards
- **Create more Tests!**
# Usage
```ruby
# TODO: Create a Factory to create everything needed
# 1. Obtain the provider for a specific filetype
document_text_provider = DocumentTextProvider.get_provider_for_file(@filename)
# 2. Instantiate a new document model
sqlite_document_text_model = SQLiteDocumentTextModel.new(DATABASE_PATH, document_text_provider)
# 2.1 Generate the database
sqlite_document_text_model.build()
# 3. Instantiate a new OpenAI provider with a cache provider
@open_ai_cache_provider = SQLiteOpenAICacheProvider.new(DATABASE_PATH)
@open_ai_provider = OpenAIProvider.new(@open_ai_cache_provider)
# 4. Instantiate a new document embeddings model
@document_embeddings_model = SQLiteDocumentEmbeddingsModel.new(DATABASE_PATH, sqlite_document_text_model, @open_ai_provider)
# 5. Instantiate a new document search model
@document_search_model = DocumentSearchModel.new(@document_embeddings_model)
```