Module: OllamaChat::RAGHandling
- Included in:
- Chat
- Defined in:
- lib/ollama_chat/rag_handling.rb
Overview
A module that handles Retrieval-Augmented Generation (RAG) operations for the OllamaChat application.
This module provides functionality for managing collections, clearing and changing collections, listing collections, and renaming collections within the RAG system.
Instance Method Summary collapse
-
#database_collection?(collection) ⇒ OllamaChat::Database::Models::Collection?
Looks up a collection in the database by name.
-
#switch_collection(other_collection = nil) { ... } ⇒ Object
Temporarily switches the RAG collection to the specified collection.
Instance Method Details
#database_collection?(collection) ⇒ OllamaChat::Database::Models::Collection?
Looks up a collection in the database by name.
31 32 33 |
# File 'lib/ollama_chat/rag_handling.rb', line 31 def database_collection?(collection) models::Collection[name: collection.to_s] end |
#switch_collection(other_collection = nil) { ... } ⇒ Object
Temporarily switches the RAG collection to the specified collection.
The current collection is stored and restored after the block is executed, ensuring the state remains consistent regardless of whether the block completes successfully or raises an error.
18 19 20 21 22 23 24 |
# File 'lib/ollama_chat/rag_handling.rb', line 18 def switch_collection(other_collection = nil) other_collection ||= collection old_collection, @documents.collection = collection, other_collection yield other_collection ensure @documents.collection = old_collection end |