Skip to content

Commit

Permalink
feat: fix example issue (Abraxas-365#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
return764 committed Oct 13, 2024
1 parent 8db3a1e commit c3ecb36
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
16 changes: 6 additions & 10 deletions examples/vector_store_sqlite_vec.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
// Make sure vec0 libraries are installed in the system or the path of the executable.
// And install ollama on system with `nomic-embed-text` embedding model
// Next run `ollama serve` to start your ollama local server
// To run this example execute: cargo run --example vector_store_sqlite_vec --features sqlite-vec,ollama
// To run this example execute: cargo run --example vector_store_sqlite_vec --features sqlite-vec
// Download the libraries from https://github.com/asg017/sqlite-vec

#[cfg(feature = "sqlite-vec")]
use langchain_rust::{
embedding::openai::openai_embedder::OpenAiEmbedder,
schemas::Document,
vectorstore::{sqlite_vec::StoreBuilder, VecStoreOptions, VectorStore},
};
#[cfg(feature = "ollama")]
use langchain_rust::embedding::{
ollama::ollama_embedder::OllamaEmbedder,
};

#[cfg(feature = "sqlite-vec")]
use std::io::Write;

#[cfg(feature = "sqlite-vec")]
#[tokio::main]
async fn main() {
// Initialize Embedder
let embedder = OllamaEmbedder::default().with_model("nomic-embed-text");
let embedder = OpenAiEmbedder::default();

let database_url = std::env::var("DATABASE_URL").unwrap_or("sqlite::memory:".to_string());

Expand Down Expand Up @@ -77,7 +73,7 @@ async fn main() {

#[cfg(not(feature = "sqlite-vec"))]
fn main() {
println!("This example requires the 'sqlite' feature to be enabled.");
println!("This example requires the 'sqlite-vec' feature to be enabled.");
println!("Please run the command as follows:");
println!("cargo run --example vector_store_sqlite --features sqlite");
println!("cargo run --example vector_store_sqlite_vec --features sqlite-vec");
}
2 changes: 1 addition & 1 deletion examples/vector_store_sqlite_vss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ async fn main() {
fn main() {
println!("This example requires the 'sqlite-vss' feature to be enabled.");
println!("Please run the command as follows:");
println!("cargo run --example vector_store_sqlite --features sqlite-vss");
println!("cargo run --example vector_store_sqlite_vss --features sqlite-vss");
}

0 comments on commit c3ecb36

Please sign in to comment.