Database
Object Hierarchy:
Description:
public class Database :
VectorBase
Vector database with embedding generation and FAISS storage.
Manages the complete vector database lifecycle: embedding generation, vector storage in FAISS, and similarity search. Integrates with
OLLMchat for embedding generation and automatically manages the FAISS index.
The database requires configuration of model usage types before use: - "ocvector.embed": Embedding model for converting text to vectors
Usage Example
// Register tool config type
OLLMvector.Tool.CodebaseSearchTool.register_config();
OLLMvector.Tool.CodebaseSearchTool.setup_tool_config(config);
// Get dimension first, then create database
var temp_db = new OLLMvector.Database(config, "/path/to/index.faiss", OLLMvector.Database.DISABLE_INDEX);
var dimension = yield temp_db.embed_dimension();
var db = new OLLMvector.Database(config, "/path/to/index.faiss", dimension);
// Add documents (automatically generates embeddings)
yield db.add_documents({"document 1", "document 2"});
// Search
var results = yield db.search("query text", k: 10);
// Save index
db.save_index();
Content:
Constants:
Properties:
Static methods:
Creation methods:
- public Database (Config2 config, string filename, int dimension) throws Error
Constructor.
Methods:
- public async void add_documents (string[] texts) throws Error
- public void add_vectors_batch (FloatArray vectors) throws Error
Adds vectors in batch to the FAISS index.
- public async int embed_dimension () throws Error
Gets the embedding dimension by doing a test embed.
- public float[] reconstruct_vector (int64 vector_id) throws Error
Reconstruct a stored vector by ID (for dump/diff use).
- public void save_index () throws Error
Saves the index to the file specified in constructor.
- public async SearchResultWithDocument[] search (string query, uint64 k = 5) throws Error
Inherited Members:
All known members inherited from class OLLMvector.VectorBase
All known members inherited from class GLib.Object
- @get
- @new
- @ref
- @set
- add_toggle_ref
- add_weak_pointer
- bind_property
- connect
- constructed
- disconnect
- dispose
- dup_data
- dup_qdata
- force_floating
- freeze_notify
- get_class
- get_data
- get_property
- get_qdata
- get_type
- getv
- interface_find_property
- interface_install_property
- interface_list_properties
- is_floating
- new_valist
- new_with_properties
- newv
- notify
- notify_property
- ref_count
- ref_sink
- remove_toggle_ref
- remove_weak_pointer
- replace_data
- replace_qdata
- set_data
- set_data_full
- set_property
- set_qdata
- set_qdata_full
- set_valist
- setv
- steal_data
- steal_qdata
- thaw_notify
- unref
- watch_closure
- weak_ref
- weak_unref