pub struct RagConfig {Show 31 fields
pub provider: LlmProvider,
pub api_endpoint: String,
pub api_key: Option<String>,
pub model: String,
pub max_tokens: usize,
pub temperature: f32,
pub top_p: f32,
pub timeout_secs: u64,
pub max_retries: u32,
pub embedding_provider: EmbeddingProvider,
pub embedding_model: String,
pub embedding_dimensions: usize,
pub chunk_size: usize,
pub chunk_overlap: usize,
pub top_k: usize,
pub similarity_threshold: f32,
pub hybrid_search: bool,
pub semantic_weight: f32,
pub keyword_weight: f32,
pub query_expansion: bool,
pub response_filtering: bool,
pub caching: bool,
pub cache_ttl_secs: u64,
pub rate_limiting: RateLimitConfig,
pub retry_config: RetryConfig,
pub custom_headers: HashMap<String, String>,
pub debug_mode: bool,
pub max_context_length: usize,
pub response_format: ResponseFormat,
pub logging: LoggingConfig,
pub monitoring: MonitoringConfig,
}Expand description
RAG configuration
Fields§
§provider: LlmProviderLLM provider
api_endpoint: StringLLM API endpoint
api_key: Option<String>API key for authentication
model: StringModel name to use
max_tokens: usizeMaximum tokens for generation
temperature: f32Temperature for generation (0.0 to 2.0)
top_p: f32Top-p sampling (0.0 to 1.0)
timeout_secs: u64Request timeout in seconds
max_retries: u32Maximum retry attempts
embedding_provider: EmbeddingProviderEmbedding provider
embedding_model: StringEmbedding model name
embedding_dimensions: usizeEmbedding dimensions
chunk_size: usizeChunk size for document splitting
chunk_overlap: usizeChunk overlap for document splitting
top_k: usizeTop-k similar chunks to retrieve
similarity_threshold: f32Similarity threshold (0.0 to 1.0)
hybrid_search: boolEnable hybrid search (combines semantic and keyword search)
semantic_weight: f32Weight for semantic search in hybrid mode (0.0 to 1.0)
keyword_weight: f32Weight for keyword search in hybrid mode (0.0 to 1.0)
query_expansion: boolEnable query expansion
response_filtering: boolEnable response filtering
caching: boolEnable caching
cache_ttl_secs: u64Cache TTL in seconds
rate_limiting: RateLimitConfigRate limiting configuration
retry_config: RetryConfigRetry configuration
custom_headers: HashMap<String, String>Custom headers for API requests
debug_mode: boolEnable debug mode
max_context_length: usizeMaximum context length
response_format: ResponseFormatResponse format preferences
logging: LoggingConfigLogging configuration
monitoring: MonitoringConfigPerformance monitoring
Implementations§
Source§impl RagConfig
impl RagConfig
Sourcepub fn new(provider: LlmProvider, model: String) -> Self
pub fn new(provider: LlmProvider, model: String) -> Self
Create a new RAG configuration
Sourcepub fn with_api_key(self, api_key: String) -> Self
pub fn with_api_key(self, api_key: String) -> Self
Set API key
Sourcepub fn with_endpoint(self, endpoint: String) -> Self
pub fn with_endpoint(self, endpoint: String) -> Self
Set API endpoint
Sourcepub fn with_model_params(
self,
max_tokens: usize,
temperature: f32,
top_p: f32,
) -> Self
pub fn with_model_params( self, max_tokens: usize, temperature: f32, top_p: f32, ) -> Self
Set model parameters
Sourcepub fn with_embedding(
self,
provider: EmbeddingProvider,
model: String,
dimensions: usize,
) -> Self
pub fn with_embedding( self, provider: EmbeddingProvider, model: String, dimensions: usize, ) -> Self
Set embedding configuration
Sourcepub fn with_chunking(self, chunk_size: usize, chunk_overlap: usize) -> Self
pub fn with_chunking(self, chunk_size: usize, chunk_overlap: usize) -> Self
Set chunking parameters
Sourcepub fn with_retrieval(self, top_k: usize, similarity_threshold: f32) -> Self
pub fn with_retrieval(self, top_k: usize, similarity_threshold: f32) -> Self
Set retrieval parameters
Sourcepub fn with_hybrid_search(
self,
semantic_weight: f32,
keyword_weight: f32,
) -> Self
pub fn with_hybrid_search( self, semantic_weight: f32, keyword_weight: f32, ) -> Self
Enable hybrid search
Sourcepub fn with_caching(self, enabled: bool, ttl_secs: u64) -> Self
pub fn with_caching(self, enabled: bool, ttl_secs: u64) -> Self
Set caching configuration
Sourcepub fn with_rate_limit(self, requests_per_minute: u32, burst_size: u32) -> Self
pub fn with_rate_limit(self, requests_per_minute: u32, burst_size: u32) -> Self
Set rate limiting
Sourcepub fn with_retry(self, max_attempts: u32, backoff_secs: u64) -> Self
pub fn with_retry(self, max_attempts: u32, backoff_secs: u64) -> Self
Set retry configuration
Sourcepub fn with_header(self, key: String, value: String) -> Self
pub fn with_header(self, key: String, value: String) -> Self
Add custom header
Sourcepub fn with_debug_mode(self, debug: bool) -> Self
pub fn with_debug_mode(self, debug: bool) -> Self
Enable debug mode
Sourcepub fn timeout_duration(&self) -> Duration
pub fn timeout_duration(&self) -> Duration
Get timeout duration
Sourcepub fn cache_ttl_duration(&self) -> Duration
pub fn cache_ttl_duration(&self) -> Duration
Get cache TTL duration
Sourcepub fn is_caching_enabled(&self) -> bool
pub fn is_caching_enabled(&self) -> bool
Check if caching is enabled
Sourcepub fn is_rate_limited(&self) -> bool
pub fn is_rate_limited(&self) -> bool
Check if rate limiting is enabled
Sourcepub fn requests_per_minute(&self) -> u32
pub fn requests_per_minute(&self) -> u32
Get requests per minute limit
Sourcepub fn burst_size(&self) -> u32
pub fn burst_size(&self) -> u32
Get burst size for rate limiting
Sourcepub fn max_retry_attempts(&self) -> u32
pub fn max_retry_attempts(&self) -> u32
Get maximum retry attempts
Sourcepub fn backoff_duration(&self) -> Duration
pub fn backoff_duration(&self) -> Duration
Get backoff duration for retries
Sourcepub fn is_exponential_backoff(&self) -> bool
pub fn is_exponential_backoff(&self) -> bool
Check if exponential backoff is enabled
Sourcepub fn response_format(&self) -> &ResponseFormat
pub fn response_format(&self) -> &ResponseFormat
Get response format
Sourcepub fn logging_config(&self) -> &LoggingConfig
pub fn logging_config(&self) -> &LoggingConfig
Get logging configuration
Sourcepub fn monitoring_config(&self) -> &MonitoringConfig
pub fn monitoring_config(&self) -> &MonitoringConfig
Get monitoring configuration