pub struct ConfigManager { /* private fields */ }Expand description
Thread-safe mutable configuration manager.
Wraps Settings in Arc<RwLock<>> to allow runtime mutation from
setter methods. Tracks a monotonically increasing version counter
so that crate::ComponentManager can detect stale cached components
and reinitialize them.
§Example
use cognee_lib::config::{ConfigManager, Settings};
let cfg = ConfigManager::new(Settings::default());
assert_eq!(cfg.version(), 0);
cfg.set_llm_model("gpt-4o");
assert_eq!(cfg.version(), 1);
assert_eq!(cfg.read().llm_model, "gpt-4o");Implementations§
Source§impl ConfigManager
impl ConfigManager
Sourcepub fn read(&self) -> RwLockReadGuard<'_, Settings>
pub fn read(&self) -> RwLockReadGuard<'_, Settings>
Obtain a read-lock on the current settings.
Source§impl ConfigManager
impl ConfigManager
pub fn set_llm_provider(&self, provider: &str)
pub fn set_llm_model(&self, model: &str)
pub fn set_llm_api_key(&self, key: &str)
pub fn set_llm_endpoint(&self, endpoint: &str)
pub fn set_llm_fallback_model(&self, model: &str)
pub fn set_llm_fallback_provider(&self, provider: &str)
pub fn set_llm_fallback_endpoint(&self, endpoint: &str)
pub fn set_llm_fallback_api_key(&self, key: &str)
pub fn set_embedding_provider(&self, provider: &str)
pub fn set_embedding_model(&self, model: &str)
pub fn set_embedding_dimensions(&self, dims: u32)
pub fn set_embedding_endpoint(&self, endpoint: &str)
pub fn set_embedding_api_key(&self, key: &str)
pub fn set_embedding_api_version(&self, version: &str)
pub fn set_transcription_model(&self, model: &str)
pub fn set_vector_db_provider(&self, provider: &str)
pub fn set_vector_db_url(&self, url: &str)
Sourcepub fn set_relational_db_url(&self, url: &str)
pub fn set_relational_db_url(&self, url: &str)
Override the relational database URL (e.g. "sqlite:///path/to/db?mode=rwc").
Primarily used by language-binding tests to redirect each test’s DB to an isolated tmp directory so tests do not share the default on-disk DB.
Sourcepub fn set_relational_db_config(
&self,
url: Option<&str>,
provider: Option<&str>,
host: Option<&str>,
port: Option<u16>,
name: Option<&str>,
username: Option<&str>,
password: Option<&str>,
)
pub fn set_relational_db_config( &self, url: Option<&str>, provider: Option<&str>, host: Option<&str>, port: Option<u16>, name: Option<&str>, username: Option<&str>, password: Option<&str>, )
Set all relational DB connection fields at once.
Sourcepub fn set_migration_db_config(&self, url: &str)
pub fn set_migration_db_config(&self, url: &str)
Set the migration DB URL.
pub fn set_vector_db_key(&self, key: &str)
pub fn set_graph_database_provider(&self, provider: &str)
pub fn set_graph_model(&self, model: &str)
pub fn set_chunk_strategy(&self, strategy: &str)
pub fn set_chunk_engine(&self, engine: &str)
pub fn set_chunk_size(&self, size: u32)
pub fn set_chunk_overlap(&self, overlap: u32)
pub fn set_data_root_directory(&self, path: &str)
Sourcepub fn set_system_root_directory(&self, path: &str)
pub fn set_system_root_directory(&self, path: &str)
Set system root directory and cascade derived path updates.
Matches Python config.system_root_directory() (config.py lines 41-67):
graph_file_pathupdated if it was under the old system rootvector_db_urlupdated if it was under the old system root
pub fn set_monitoring_tool(&self, tool: &str)
pub fn set_classification_model(&self, model: &str)
pub fn set_summarization_model(&self, model: &str)
Sourcepub fn set_summarization_schema(&self, schema: Value) -> Result<(), ConfigError>
pub fn set_summarization_schema(&self, schema: Value) -> Result<(), ConfigError>
Set a custom JSON schema for the summarization output stage.
Mirrors Python’s cognee.config.set_summarization_model(CustomSchema):
accepts a JSON Schema Value describing the expected LLM output. The
schema must contain a summary string field. The stored value is
intended to be read by callers when constructing a CognifyConfig via
CognifyConfig::with_summary_schema.
Returns Err if the schema fails validation (missing summary field).
pub fn set_llm_api_version(&self, version: &str)
pub fn set_llm_temperature(&self, temperature: f64)
pub fn set_llm_streaming(&self, streaming: bool)
pub fn set_llm_max_completion_tokens(&self, tokens: u32)
pub fn set_llm_max_retries(&self, retries: u32)
pub fn set_llm_max_parallel_requests(&self, parallel: u32)
Sourcepub fn set_llm_mock(&self, mock: bool)
pub fn set_llm_mock(&self, mock: bool)
Select the record/replay mock LLM (MOCK_LLM parity).
Sourcepub fn set_llm_cassette(&self, cassette: &str)
pub fn set_llm_cassette(&self, cassette: &str)
Set the cassette path used by the replay mock (MOCK_LLM_CASSETTE).
Sourcepub fn set_llm_record_path(&self, path: &str)
pub fn set_llm_record_path(&self, path: &str)
Set the recording cassette output path (COGNEE_RECORD_LLM); empty = unset.
pub fn set_embedding_model_path(&self, path: &str)
pub fn set_embedding_tokenizer_path(&self, path: &str)
pub fn set_vector_db_host(&self, host: &str)
pub fn set_vector_db_port(&self, port: u16)
pub fn set_vector_db_name(&self, name: &str)
Sourcepub fn set_graph_file_path(&self, path: &str)
pub fn set_graph_file_path(&self, path: &str)
Set graph_file_path directly.
Unlike set_system_root_directory,
this is a plain field write and does not cascade to other paths.
pub fn set_cache_root_directory(&self, path: &str)
pub fn set_logs_root_directory(&self, path: &str)
pub fn set_ontology_file_path(&self, path: &str)
pub fn set_ontology_resolver(&self, resolver: &str)
pub fn set_ontology_matching_strategy(&self, strategy: &str)
Sourcepub fn get_settings(&self) -> HashMap<String, Value>
pub fn get_settings(&self) -> HashMap<String, Value>
Return a snapshot of the current settings with secrets masked.
All secret-bearing fields (*_api_key, *_password, *_key) are
replaced with "<redacted>" when non-empty, matching Python’s
config.get_settings() behaviour so callers can safely log or expose
the output without leaking credentials.
The returned map can be serialized to JSON for logging or debugging.
Source§impl ConfigManager
impl ConfigManager
Sourcepub fn set_llm_config(
&self,
values: &HashMap<String, Value>,
) -> Result<(), ConfigError>
pub fn set_llm_config( &self, values: &HashMap<String, Value>, ) -> Result<(), ConfigError>
Bulk-update LLM config from a map. Matches Python config.set_llm_config().
Sourcepub fn set_embedding_config(
&self,
values: &HashMap<String, Value>,
) -> Result<(), ConfigError>
pub fn set_embedding_config( &self, values: &HashMap<String, Value>, ) -> Result<(), ConfigError>
Bulk-update embedding config from a map. Matches Python config.set_embedding_config().
Sourcepub fn set_vector_db_config(
&self,
values: &HashMap<String, Value>,
) -> Result<(), ConfigError>
pub fn set_vector_db_config( &self, values: &HashMap<String, Value>, ) -> Result<(), ConfigError>
Bulk-update vector DB config from a map. Matches Python config.set_vector_db_config().
Sourcepub fn set_graph_db_config(
&self,
values: &HashMap<String, Value>,
) -> Result<(), ConfigError>
pub fn set_graph_db_config( &self, values: &HashMap<String, Value>, ) -> Result<(), ConfigError>
Bulk-update graph DB config from a map. Matches Python config.set_graph_db_config().
Sourcepub fn set(&self, key: &str, value: Value) -> Result<(), ConfigError>
pub fn set(&self, key: &str, value: Value) -> Result<(), ConfigError>
Generic setter matching Python’s config.set(key, value).
Dispatches to the appropriate typed setter based on the key name.
Returns ConfigError::UnknownKey for unrecognized keys and
ConfigError::TypeMismatch when the JSON value type doesn’t match.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ConfigManager
impl RefUnwindSafe for ConfigManager
impl Send for ConfigManager
impl Sync for ConfigManager
impl Unpin for ConfigManager
impl UnsafeUnpin for ConfigManager
impl UnwindSafe for ConfigManager
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T, U, C> IntoWithContext<U, C> for Twhere
U: FromWithContext<T, C>,
impl<T, U, C> IntoWithContext<U, C> for Twhere
U: FromWithContext<T, C>,
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.