Skip to content

Commit

Permalink
feat(ingestion_pipeline): default concurrency is the number of cpus (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
timonv authored Jun 13, 2024
1 parent 1036d56 commit f10bc30
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions swiftide/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ tokio = { version = "1.38.0", features = ["full"] }
tracing = { version = "0.1.40", features = ["log"] }
strum = "0.26.2"
strum_macros = "0.26.4"
num_cpus = "1.16.0"

# Integrations
async-openai = { version = "0.23.2", optional = true }
Expand Down
13 changes: 11 additions & 2 deletions swiftide/src/ingestion/ingestion_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,23 @@ pub struct IngestionPipeline {
concurrency: usize,
}

impl Default for IngestionPipeline {
fn default() -> Self {
Self {
stream: Box::pin(futures_util::stream::empty()),
storage: None,
concurrency: num_cpus::get(),
}
}
}

// A lazy pipeline for ingesting files, adding metadata, chunking, transforming, embedding and then storing them.
impl IngestionPipeline {
pub fn from_loader(loader: impl Loader + 'static) -> Self {
let stream = loader.into_stream();
Self {
stream: stream.boxed(),
storage: None,
concurrency: 10,
..Default::default()
}
}

Expand Down

0 comments on commit f10bc30

Please sign in to comment.