#![deny(unsafe_code)]
pub mod cache;
pub(crate) mod cache_dir;
pub mod cancellation;
pub mod core;
pub mod engine;
pub mod error;
pub mod extraction;
pub mod extractors;
#[cfg(all(
feature = "layout-detection",
any(feature = "pdf", feature = "ocr", feature = "ocr-wasm")
))]
pub mod model_cache;
pub mod plugins;
pub mod rendering;
pub mod telemetry;
pub mod text;
pub mod types;
pub mod utils;
#[cfg(any(feature = "ocr", feature = "pdf", feature = "paddle-ocr"))]
pub mod table_core;
#[cfg(feature = "tower-service")]
pub mod service;
#[cfg(feature = "api")]
pub mod api;
#[cfg(feature = "mcp")]
pub mod mcp;
#[cfg(feature = "chunking")]
pub mod chunking;
#[cfg(feature = "diff")]
pub mod diff;
#[cfg(all(feature = "liter-llm", not(target_arch = "wasm32")))]
pub mod llm;
#[cfg(feature = "embedding-presets")]
pub mod embeddings;
#[cfg(any(feature = "reranker-presets", feature = "reranker"))]
pub mod reranking;
#[cfg(feature = "onnx-runtime")]
pub(crate) mod onnx;
#[cfg(any(feature = "sparse-embedding-presets", feature = "sparse-embeddings"))]
pub mod sparse_embeddings;
#[cfg(any(feature = "late-interaction-presets", feature = "late-interaction"))]
pub mod late_interaction;
#[cfg(feature = "ocr")]
pub mod image;
#[cfg(feature = "language-detection")]
pub mod language_detection;
#[cfg(feature = "stopwords")]
pub mod stopwords;
#[cfg(any(feature = "keywords-yake", feature = "keywords-rake"))]
pub mod keywords;
#[cfg(feature = "enrichment")]
pub mod enrichment;
#[cfg(feature = "heuristics")]
pub mod heuristics;
#[cfg(feature = "heuristics")]
pub use heuristics::{
BoundaryReason, ChunkInfo, ChunkPlan, ChunkingDecision, ChunkingReason, ConfidenceSignals, ConfidenceWeights,
DocumentBoundary, DocumentMetadata, HeuristicsConfig, HeuristicsError, MultidocInput, MultidocThresholds,
NoChunkingReason, PageRange, PageSignals, SchemaCompliance, StructuredCallMode, StructuredInput,
StructuredThresholds, UserChunkConfig, analyze_document, analyze_with_user_chunks,
boundaries_from_extraction_result, calculate_chunk_plan, calculate_plan_from_overrides, check_format_limits,
choose_call_mode, detect_boundaries, score_confidence,
};
#[cfg(feature = "presets")]
pub mod presets;
#[cfg(any(feature = "ocr", feature = "ocr-wasm"))]
pub mod ocr;
#[cfg(any(
feature = "paddle-ocr",
feature = "embeddings",
feature = "reranker",
feature = "onnx-runtime",
feature = "layout-detection",
feature = "auto-rotate",
feature = "transcription"
))]
pub mod ort_discovery;
#[cfg(not(target_arch = "wasm32"))]
pub(crate) mod model_download;
#[cfg(any(layout_detection, auto_rotate))]
pub(crate) mod inference;
#[cfg(any(feature = "paddle-ocr", feature = "paddle-ocr-types"))]
pub mod paddle_ocr;
#[cfg(feature = "candle-ocr")]
pub mod candle_ocr;
#[cfg(feature = "auto-rotate-types")]
pub mod doc_orientation;
#[cfg(feature = "layout-types")]
pub mod layout;
#[cfg(feature = "pdf")]
pub mod pdf;
#[cfg(feature = "transcription")]
pub mod transcription;
#[cfg(feature = "captioning")]
pub mod captioning;
pub use error::{Result, XbergError};
pub use types::*;
#[cfg(feature = "office")]
pub use extraction::office_metadata::{CoreProperties, DocxAppProperties};
#[cfg(feature = "url-ingestion")]
pub use core::extract::map_url;
pub use core::extract::{extract, extract_batch};
#[cfg(feature = "pdf")]
pub use core::split::{SplitConfig, SplitSegment, SplitStrategy, split_and_extract};
pub use core::config::{
AccelerationConfig, CallMode, CaptioningConfig, ChunkClassificationConfig, ChunkClassificationDefinition,
ChunkSizing, ChunkerType, ChunkingConfig, ContentFilterConfig, EmailConfig, EmbeddingConfig, EmbeddingModelType,
ExecutionProviderType, ExtractInput, ExtractInputKind, ExtractionConfig, ExtractionErrorItem, ExtractionResult,
ExtractionSummary, FileExtractionConfig, ImageExtractionConfig, JupyterCellRendering, LanguageDetectionConfig,
LlmConfig, MergeMode, NerBackendKind, NerConfig, OcrConfig, OutputFormat, PageClassificationConfig, PageConfig,
PostProcessorConfig, RedactionConfig, RedactionPattern, RedactionTerm, RerankerConfig, RerankerHead,
RerankerModelType, StructuredExtractionConfig, SummarizationConfig, TableChunkingMode, TokenReductionOptions,
TranslationConfig, UrlExtractionConfig, UrlExtractionMode,
};
pub use core::config::{
LateInteractionConfig, LateInteractionModelType, SparseEmbeddingConfig, SparseEmbeddingModelType,
};
#[cfg(feature = "transcription-types")]
pub use core::config::{TranscriptionConfig, WhisperModel};
#[cfg(any(feature = "url-ingestion", feature = "url-config-types"))]
pub use crawlberg::{
AssetCategory, AuthConfig, BrowserBackend, BrowserConfig, BrowserMode, BrowserWait, ContentConfig, CrawlConfig,
ProxyConfig, SsrfPolicy,
};
#[cfg(feature = "url-ingestion")]
pub use crawlberg::{MapResult, SitemapUrl};
pub use extractors::security::SecurityLimits;
#[cfg(feature = "presets")]
pub use presets::{
LoadError, MetaSchema, Preset, PresetCategory, PresetSample, PresetSummary, Registry, ResolveError, ResolvedPreset,
resolve,
};
#[cfg(feature = "quality")]
pub use text::{ReductionLevel, TokenReductionConfig};
#[cfg(all(
feature = "ner-llm",
not(target_arch = "wasm32"),
not(all(target_os = "android", target_arch = "x86_64"))
))]
#[cfg_attr(alef, alef(skip))]
pub use text::ner::llm::LlmBackend;
#[cfg(feature = "ner-llm")]
pub use text::ner::NerBackend;
#[cfg(any(not(feature = "ner-llm"), all(target_os = "android", target_arch = "x86_64")))]
#[derive(Clone, Debug)]
#[cfg_attr(alef, alef(skip))]
pub struct LlmBackend {
_config: LlmConfig,
}
#[cfg(any(not(feature = "ner-llm"), all(target_os = "android", target_arch = "x86_64")))]
impl LlmBackend {
pub fn new(config: LlmConfig) -> Self {
Self { _config: config }
}
pub async fn detect(&self, _text: &str, _categories: &[crate::EntityCategory]) -> Result<Vec<crate::Entity>> {
Err(crate::XbergError::Other(
"ner-llm feature not available on this target".into(),
))
}
pub async fn detect_with_custom(
&self,
_text: &str,
_categories: &[crate::EntityCategory],
_custom_labels: &[String],
) -> Result<Vec<crate::Entity>> {
Err(crate::XbergError::Other(
"ner-llm feature not available on this target".into(),
))
}
}
#[cfg(feature = "ner-onnx")]
pub use text::ner::gline::GlineBackend;
#[cfg(not(feature = "ner-onnx"))]
#[derive(Clone, Debug)]
pub struct GlineBackend {
pub repo_id: String,
pub model_path: std::path::PathBuf,
pub tokenizer_path: std::path::PathBuf,
}
#[cfg(not(feature = "ner-onnx"))]
impl GlineBackend {
pub fn new(_repo_id: Option<&str>) -> Result<Self> {
Err(crate::XbergError::Other(
"ner-onnx feature not available on this target".into(),
))
}
pub async fn detect(&self, _text: &str, _categories: &[crate::EntityCategory]) -> Result<Vec<crate::Entity>> {
Err(crate::XbergError::Other(
"ner-onnx feature not available on this target".into(),
))
}
pub async fn detect_with_custom(
&self,
_text: &str,
_categories: &[crate::EntityCategory],
_custom_labels: &[String],
) -> Result<Vec<crate::Entity>> {
Err(crate::XbergError::Other(
"ner-onnx feature not available on this target".into(),
))
}
}
#[cfg(all(feature = "liter-llm", not(target_arch = "wasm32")))]
pub use llm::region_extractor::RegionKind;
#[cfg(not(all(feature = "liter-llm", not(target_arch = "wasm32"))))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum RegionKind {
Figure,
DenseTable,
ComplexLayout,
Caption,
}
#[cfg(not(all(feature = "liter-llm", not(target_arch = "wasm32"))))]
impl RegionKind {
pub fn default_prompt(self) -> &'static str {
""
}
}
#[cfg(feature = "ner")]
#[cfg_attr(alef, alef(skip))]
pub use text::ner::detect_entities;
#[cfg(feature = "classification")]
#[cfg_attr(alef, alef(skip))]
pub use text::classification::classify_document;
#[cfg(feature = "redaction")]
pub use text::redaction::strategy::TokenCounter;
#[cfg(feature = "api-types")]
pub use core::server_config::ServerConfig;
#[cfg(feature = "pdf")]
pub use core::config::{HierarchyConfig, PdfConfig};
#[cfg(feature = "html")]
pub use core::config::{HtmlOutputConfig, HtmlTheme};
#[cfg(feature = "html")]
pub use rendering::StyledHtmlRenderer;
#[cfg(feature = "paddle-ocr-types")]
pub use paddle_ocr::{ModelPaths, PaddleLanguage, PaddleOcrConfig};
#[cfg(feature = "paddle-ocr")]
pub use paddle_ocr::{ModelCacheStats, ModelManager, ModelManifestEntry, PaddleOcrBackend};
pub use cache::CacheStats;
#[cfg(feature = "layout-types")]
pub use core::config::{LayoutDetectionConfig, LayoutStrategy, TableModel};
#[cfg(feature = "layout-types")]
pub use layout::types::{BBox, DetectionResult, LayoutClass, LayoutDetection};
#[cfg(feature = "layout-types")]
pub use layout::types::RecognizedTable;
#[cfg(any(feature = "ocr", feature = "ocr-wasm"))]
pub use ocr::types::PSMMode;
pub use core::config::{OcrPipelineConfig, OcrPipelineStage, OcrQualityThresholds, OcrStrategy, VlmFallbackPolicy};
#[cfg(feature = "auto-rotate-types")]
pub use doc_orientation::OrientationResult;
#[cfg(any(feature = "keywords-yake", feature = "keywords-rake"))]
pub use keywords::{Keyword, KeywordAlgorithm, KeywordConfig};
#[cfg(feature = "keywords-rake")]
pub use keywords::RakeParams;
#[cfg(feature = "keywords-yake")]
pub use keywords::YakeParams;
#[cfg(feature = "markdown-footnotes")]
pub use text::markdown_footnotes::{
Citation, FootnoteAnchor, FootnoteConfig, FootnoteDefinition, find_footnote_anchors, find_inference_markers,
find_unmarked_claims, parse_citations, parse_footnote_definitions, verify_excerpt,
};
#[cfg(feature = "diff")]
pub use diff::{DiffHunk, DiffOptions, EmbeddedChanges, EmbeddedDiff, ExtractionDiff, TableDiff, compare};
#[cfg(feature = "tree-sitter")]
pub use core::config::{CodeContentMode, TreeSitterConfig, TreeSitterProcessConfig};
#[cfg(feature = "tree-sitter")]
pub use tree_sitter_language_pack::{
ChunkContext, CodeChunk, CommentInfo, CommentKind, Diagnostic, DiagnosticSeverity, DocstringFormat, DocstringInfo,
ExportInfo, ExportKind, FileMetrics, ImportInfo, ProcessConfig, ProcessResult, Span, StructureItem, StructureKind,
SymbolInfo, SymbolKind, process as process_code,
};
pub use core::mime::{SupportedFormat, detect_mime_type_from_bytes, get_extensions_for_mime, list_supported_formats};
pub fn detect_mime_type(path: String, check_exists: bool) -> crate::Result<String> {
core::mime::detect_mime_type(path, check_exists)
}
#[cfg(feature = "pdf")]
pub use pdf::render::{pdf_page_count, render_pdf_page_to_png};
#[cfg_attr(alef, alef(skip))]
pub use plugins::{
clear_document_extractors, clear_embedding_backends, clear_ocr_backends, clear_post_processors, clear_renderers,
clear_reranker_backends, clear_tokenizer_backends, clear_validators, list_document_extractors,
list_embedding_backends, list_ocr_backends, list_post_processors, list_renderers, list_reranker_backends,
list_tokenizer_backends, list_validators, register_document_extractor, register_embedding_backend,
register_ocr_backend, register_post_processor, register_renderer, register_reranker_backend,
register_tokenizer_backend, register_validator, unregister_document_extractor, unregister_embedding_backend,
unregister_ocr_backend, unregister_post_processor, unregister_renderer, unregister_reranker_backend,
unregister_tokenizer_backend, unregister_validator,
};
#[cfg_attr(alef, alef(skip))]
pub use plugins::{
DocumentExtractor, EmbeddingBackend, OcrBackend, OcrBackendType, PostProcessor, ProcessingStage, Renderer,
RerankerBackend, TokenizerBackend, Validator,
};
#[cfg(feature = "embedding-presets")]
pub use embeddings::EmbeddingPreset;
#[cfg(any(feature = "embeddings", feature = "static-embeddings"))]
#[cfg_attr(alef, alef(skip))]
pub fn embed_texts(texts: Vec<String>, config: &core::config::EmbeddingConfig) -> crate::Result<Vec<Vec<f32>>> {
embeddings::embed_texts(&texts, config)
}
#[cfg(all(
feature = "embedding-presets",
not(feature = "embeddings"),
not(feature = "static-embeddings")
))]
#[cfg_attr(alef, alef(skip))]
pub fn embed_texts(_texts: Vec<String>, _config: &core::config::EmbeddingConfig) -> crate::Result<Vec<Vec<f32>>> {
Err(XbergError::validation(
"embed_texts requires the `embeddings` (ONNX Runtime) or `static-embeddings` (pure-Rust) feature; \
neither is enabled on this build",
))
}
#[cfg(all(
feature = "tokio-runtime",
any(feature = "embeddings", feature = "static-embeddings")
))]
#[cfg_attr(alef, alef(skip))]
pub use embeddings::embed_texts_async;
#[cfg(all(
feature = "embedding-presets",
not(feature = "embeddings"),
not(feature = "static-embeddings"),
feature = "tokio-runtime"
))]
#[cfg_attr(alef, alef(skip))]
pub async fn embed_texts_async(
_texts: Vec<String>,
_config: &core::config::EmbeddingConfig,
) -> crate::Result<Vec<Vec<f32>>> {
Err(XbergError::validation(
"embed_texts_async requires the `embeddings` (ONNX Runtime) or `static-embeddings` (pure-Rust) feature; \
neither is enabled on this build",
))
}
#[cfg(feature = "embedding-presets")]
#[cfg_attr(alef, alef(skip))]
pub fn get_embedding_preset(name: &str) -> Option<embeddings::EmbeddingPreset> {
embeddings::get_preset(name)
}
#[cfg(feature = "embedding-presets")]
#[cfg_attr(alef, alef(skip))]
pub fn list_embedding_presets() -> Vec<String> {
embeddings::list_presets()
}
#[cfg(feature = "embedding-presets")]
#[cfg_attr(alef, alef(skip))]
pub fn embedding_query_prefix(config: &EmbeddingConfig) -> Option<String> {
embeddings::embedding_query_prefix(config)
}
#[cfg(not(feature = "embedding-presets"))]
#[cfg_attr(alef, alef(skip))]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct EmbeddingPreset {
pub name: String,
pub chunk_size: usize,
pub overlap: usize,
pub model_repo: String,
pub pooling: String,
pub model_file: String,
pub dimensions: usize,
pub description: String,
}
#[cfg(not(feature = "embedding-presets"))]
#[cfg_attr(alef, alef(skip))]
pub fn get_embedding_preset(_name: &str) -> Option<EmbeddingPreset> {
None
}
#[cfg(not(feature = "embedding-presets"))]
#[cfg_attr(alef, alef(skip))]
pub fn list_embedding_presets() -> Vec<String> {
Vec::new()
}
#[cfg(feature = "reranker-presets")]
pub use reranking::RerankerPreset;
#[cfg(any(feature = "reranker-presets", feature = "reranker"))]
pub use reranking::RerankedDocument;
#[cfg(feature = "reranker")]
#[cfg_attr(alef, alef(skip))]
pub fn rerank(
query: String,
documents: Vec<String>,
config: &core::config::RerankerConfig,
) -> crate::Result<Vec<reranking::RerankedDocument>> {
reranking::rerank(query, documents, config)
}
#[cfg(all(feature = "reranker-presets", not(feature = "reranker")))]
#[cfg_attr(alef, alef(skip))]
pub fn rerank(
_query: String,
_documents: Vec<String>,
_config: &core::config::RerankerConfig,
) -> crate::Result<Vec<reranking::RerankedDocument>> {
Err(XbergError::validation(
"rerank requires the `reranker` feature, which depends on ONNX Runtime; \
not available on this target (Android x86_64 emulator or WASM)",
))
}
#[cfg(all(feature = "reranker", feature = "tokio-runtime"))]
#[cfg_attr(alef, alef(skip))]
pub use reranking::rerank_async;
#[doc(alias = "rerank")]
#[cfg(all(feature = "reranker-presets", not(feature = "reranker"), feature = "tokio-runtime"))]
#[cfg_attr(alef, alef(skip))]
pub async fn rerank_async(
_query: String,
_documents: Vec<String>,
_config: &core::config::RerankerConfig,
) -> crate::Result<Vec<reranking::RerankedDocument>> {
Err(XbergError::validation(
"rerank_async requires the `reranker` feature, which depends on ONNX Runtime; \
not available on this target (Android x86_64 emulator or WASM)",
))
}
#[cfg(feature = "reranker-presets")]
#[cfg_attr(alef, alef(skip))]
pub fn get_reranker_preset(name: &str) -> Option<reranking::RerankerPreset> {
reranking::get_preset(name)
}
#[cfg(feature = "reranker-presets")]
#[cfg_attr(alef, alef(skip))]
pub fn list_reranker_presets() -> Vec<String> {
reranking::list_presets()
}
#[cfg(not(feature = "reranker-presets"))]
#[cfg_attr(alef, alef(skip))]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct RerankerPreset {
pub name: String,
pub model_repo: String,
pub model_file: String,
pub max_length: usize,
pub description: String,
}
#[cfg(not(feature = "reranker-presets"))]
#[cfg_attr(alef, alef(skip))]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "api", derive(utoipa::ToSchema))]
pub struct RerankedDocument {
pub index: usize,
pub score: f32,
pub document: String,
}
#[cfg(not(feature = "reranker-presets"))]
#[cfg_attr(alef, alef(skip))]
pub fn get_reranker_preset(_name: &str) -> Option<RerankerPreset> {
None
}
#[cfg(not(feature = "reranker-presets"))]
#[cfg_attr(alef, alef(skip))]
pub fn list_reranker_presets() -> Vec<String> {
Vec::new()
}
#[cfg(feature = "sparse-embedding-presets")]
pub use sparse_embeddings::{SparseEmbedding, SparseEmbeddingPreset};
#[cfg(feature = "sparse-embeddings")]
#[cfg_attr(alef, alef(skip))]
pub fn embed_sparse(
texts: Vec<String>,
config: &core::config::SparseEmbeddingConfig,
) -> crate::Result<Vec<SparseEmbedding>> {
sparse_embeddings::embed_sparse(&texts, config)
}
#[cfg(all(feature = "sparse-embedding-presets", not(feature = "sparse-embeddings")))]
#[cfg_attr(alef, alef(skip))]
pub fn embed_sparse(
_texts: Vec<String>,
_config: &core::config::SparseEmbeddingConfig,
) -> crate::Result<Vec<SparseEmbedding>> {
Err(XbergError::validation(
"embed_sparse requires the `sparse-embeddings` feature, which depends on ONNX Runtime; \
not available on this target (Android x86_64 emulator or WASM)",
))
}
#[cfg(all(feature = "sparse-embeddings", feature = "tokio-runtime"))]
#[cfg_attr(alef, alef(skip))]
pub use sparse_embeddings::embed_sparse_async;
#[cfg(all(
feature = "sparse-embedding-presets",
not(feature = "sparse-embeddings"),
feature = "tokio-runtime"
))]
#[cfg_attr(alef, alef(skip))]
pub async fn embed_sparse_async(
_texts: Vec<String>,
_config: &core::config::SparseEmbeddingConfig,
) -> crate::Result<Vec<SparseEmbedding>> {
Err(XbergError::validation(
"embed_sparse_async requires the `sparse-embeddings` feature, which depends on ONNX Runtime; \
not available on this target (Android x86_64 emulator or WASM)",
))
}
#[cfg(feature = "sparse-embedding-presets")]
#[cfg_attr(alef, alef(skip))]
pub fn get_sparse_embedding_preset(name: &str) -> Option<sparse_embeddings::SparseEmbeddingPreset> {
sparse_embeddings::get_preset(name)
}
#[cfg(feature = "sparse-embedding-presets")]
#[cfg_attr(alef, alef(skip))]
pub fn list_sparse_embedding_presets() -> Vec<String> {
sparse_embeddings::list_presets()
}
#[cfg(not(feature = "sparse-embedding-presets"))]
#[cfg_attr(alef, alef(skip))]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "api", derive(utoipa::ToSchema))]
pub struct SparseEmbedding {
pub indices: Vec<u32>,
pub values: Vec<f32>,
}
#[cfg(not(feature = "sparse-embedding-presets"))]
#[cfg_attr(alef, alef(skip))]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct SparseEmbeddingPreset {
pub name: String,
pub model_repo: String,
pub model_file: String,
pub additional_files: Vec<String>,
pub max_length: usize,
pub description: String,
}
#[cfg(not(feature = "sparse-embedding-presets"))]
#[cfg_attr(alef, alef(skip))]
pub fn get_sparse_embedding_preset(_name: &str) -> Option<SparseEmbeddingPreset> {
None
}
#[cfg(not(feature = "sparse-embedding-presets"))]
#[cfg_attr(alef, alef(skip))]
pub fn list_sparse_embedding_presets() -> Vec<String> {
Vec::new()
}
#[cfg(feature = "late-interaction-presets")]
pub use late_interaction::{
LateInteractionMatch, LateInteractionPreset, MultiVectorEmbedding, max_sim_rank, max_sim_score,
};
#[cfg(feature = "late-interaction")]
#[cfg_attr(alef, alef(skip))]
pub fn embed_multi_vector(
texts: Vec<String>,
config: &core::config::LateInteractionConfig,
is_query: bool,
) -> crate::Result<Vec<MultiVectorEmbedding>> {
late_interaction::embed_multi_vector(&texts, config, is_query)
}
#[cfg(all(feature = "late-interaction-presets", not(feature = "late-interaction")))]
#[cfg_attr(alef, alef(skip))]
pub fn embed_multi_vector(
_texts: Vec<String>,
_config: &core::config::LateInteractionConfig,
_is_query: bool,
) -> crate::Result<Vec<MultiVectorEmbedding>> {
Err(XbergError::validation(
"embed_multi_vector requires the `late-interaction` feature, which depends on ONNX Runtime; \
not available on this target (Android x86_64 emulator or WASM)",
))
}
#[cfg(all(feature = "late-interaction", feature = "tokio-runtime"))]
#[cfg_attr(alef, alef(skip))]
pub use late_interaction::embed_multi_vector_async;
#[cfg(all(
feature = "late-interaction-presets",
not(feature = "late-interaction"),
feature = "tokio-runtime"
))]
#[cfg_attr(alef, alef(skip))]
pub async fn embed_multi_vector_async(
_texts: Vec<String>,
_config: &core::config::LateInteractionConfig,
_is_query: bool,
) -> crate::Result<Vec<MultiVectorEmbedding>> {
Err(XbergError::validation(
"embed_multi_vector_async requires the `late-interaction` feature, which depends on ONNX Runtime; \
not available on this target (Android x86_64 emulator or WASM)",
))
}
#[cfg(feature = "late-interaction-presets")]
#[cfg_attr(alef, alef(skip))]
pub fn get_late_interaction_preset(name: &str) -> Option<late_interaction::LateInteractionPreset> {
late_interaction::get_preset(name)
}
#[cfg(feature = "late-interaction-presets")]
#[cfg_attr(alef, alef(skip))]
pub fn list_late_interaction_presets() -> Vec<String> {
late_interaction::list_presets()
}
#[cfg(not(feature = "late-interaction-presets"))]
#[cfg_attr(alef, alef(skip))]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "api", derive(utoipa::ToSchema))]
pub struct MultiVectorEmbedding {
pub num_tokens: u32,
pub dim: u32,
pub data: Vec<f32>,
}
#[cfg(not(feature = "late-interaction-presets"))]
#[cfg_attr(alef, alef(skip))]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "api", derive(utoipa::ToSchema))]
pub struct LateInteractionMatch {
pub index: usize,
pub score: f32,
}
#[cfg(not(feature = "late-interaction-presets"))]
#[cfg_attr(alef, alef(skip))]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct LateInteractionPreset {
pub name: String,
pub model_repo: String,
pub model_file: String,
pub additional_files: Vec<String>,
pub max_length: usize,
pub query_max_length: usize,
pub dim: usize,
pub description: String,
}
#[cfg(not(feature = "late-interaction-presets"))]
#[cfg_attr(alef, alef(skip))]
pub fn get_late_interaction_preset(_name: &str) -> Option<LateInteractionPreset> {
None
}
#[cfg(not(feature = "late-interaction-presets"))]
#[cfg_attr(alef, alef(skip))]
pub fn list_late_interaction_presets() -> Vec<String> {
Vec::new()
}
#[cfg(all(feature = "captioning", feature = "tokio-runtime"))]
#[cfg_attr(alef, alef(skip))]
pub use captioning::caption_image;
#[cfg(all(feature = "captioning", feature = "tokio-runtime"))]
#[cfg_attr(alef, alef(skip))]
pub use captioning::caption_image_file;
#[cfg(all(feature = "captioning", feature = "tokio-runtime"))]
#[cfg_attr(alef, alef(skip))]
pub use captioning::caption_images;
pub mod enrich;
#[cfg_attr(alef, alef(skip))]
pub use enrich::enrich;
pub use enrich::{EnrichedResult, EnrichmentConfig};
#[cfg(feature = "ner")]
pub use enrich::NerEnrichmentConfig;
#[cfg(feature = "classification")]
pub use enrich::ClassificationEnrichmentConfig;
#[cfg(feature = "captioning")]
pub use enrich::CaptioningEnrichmentConfig;