Skip to main content

swiftide_core/
lib.rs

1//! Core traits, types and pipeline plumbing shared by all Swiftide crates.
2//!
3//! Most users should depend on the [`swiftide`](https://docs.rs/swiftide) facade crate, which
4//! re-exports this crate's public API under `swiftide::traits`, `swiftide::chat_completion`,
5//! `swiftide::prompt`, `swiftide::indexing` and `swiftide::query`. Depend on `swiftide-core`
6//! directly when building your own integration and you only need the contracts.
7//!
8//! What lives here:
9//! - Indexing contracts: [`Loader`], [`Transformer`], [`BatchableTransformer`],
10//!   [`ChunkerTransformer`], [`Persist`] and [`NodeCache`], plus [`indexing::Node`] and
11//!   [`indexing::IndexingStream`].
12//! - Query contracts: [`TransformQuery`], [`Retrieve`], [`TransformResponse`], [`Answer`] and
13//!   [`EvaluateQuery`], plus the query states and search strategies in [`querying`].
14//! - Model contracts: [`SimplePrompt`], [`EmbeddingModel`], [`SparseEmbeddingModel`] and
15//!   [`ChatCompletion`], with chat messages and tool schemas in [`chat_completion`].
16//! - Agent contracts: [`AgentContext`], [`MessageHistory`], [`ToolExecutor`], and prompt templating
17//!   in [`prompt`].
18//!
19//! Guides: [indexing](https://swiftide.rs/indexing/), [querying](https://swiftide.rs/querying/),
20//! [models](https://swiftide.rs/models/) and [agents](https://swiftide.rs/agents/).
21// show feature flags in the generated documentation
22// https://doc.rust-lang.org/rustdoc/unstable-features.html#extensions-to-the-doc-attribute
23#![cfg_attr(docsrs, feature(doc_cfg))]
24#![cfg_attr(docsrs, doc(auto_cfg))]
25#![doc(html_logo_url = "https://github.com/bosun-ai/swiftide/raw/master/images/logo.png")]
26#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
27
28pub mod agent_traits;
29pub mod chat_completion;
30pub mod command_output;
31pub mod indexing_decorators;
32mod indexing_defaults;
33mod indexing_stream;
34pub mod indexing_traits;
35mod node;
36mod query;
37mod query_stream;
38pub mod query_traits;
39mod search_strategies;
40mod stream_backoff;
41pub mod token_estimation;
42pub mod tool_executor;
43pub mod type_aliases;
44
45pub mod document;
46pub mod prompt;
47pub use type_aliases::*;
48
49mod metadata;
50mod query_evaluation;
51
52/// All traits are available from the root
53pub use crate::agent_traits::{AgentContext, MessageHistory, ToolFeedback};
54pub use crate::chat_completion::traits::*;
55pub use crate::command_output::*;
56pub use crate::indexing_traits::*;
57pub use crate::query_traits::*;
58pub use crate::token_estimation::*;
59pub use crate::tool_executor::*;
60
61// Decorators are available from the root
62pub use crate::indexing_decorators::*;
63
64pub mod indexing {
65    pub use crate::indexing_decorators::*;
66    pub use crate::indexing_defaults::*;
67    pub use crate::indexing_stream::IndexingStream;
68    pub use crate::indexing_traits::*;
69    pub use crate::metadata::*;
70    pub use crate::node::*;
71}
72
73pub mod querying {
74    pub use crate::document::*;
75    pub use crate::query::*;
76    pub use crate::query_evaluation::*;
77    pub use crate::query_stream::*;
78    pub use crate::query_traits::*;
79    pub mod search_strategies {
80        pub use crate::search_strategies::*;
81    }
82}
83
84/// Re-export of commonly used dependencies.
85pub mod prelude;
86
87#[cfg(feature = "test-utils")]
88pub mod test_utils;
89
90pub mod util;
91
92#[cfg(feature = "metrics")]
93pub mod metrics;
94
95/// Pipeline statistics collection for monitoring and observability
96pub mod statistics;