From a86007f6165c7725549bc91c678bbc32b547b211 Mon Sep 17 00:00:00 2001 From: emrgnt-cmplxty Date: Fri, 10 Jan 2025 14:28:22 -0800 Subject: [PATCH 1/2] app config loadout fix --- py/core/base/providers/base.py | 30 +++++++++++++++++++++++------- py/core/main/config.py | 1 - py/r2r/r2r.toml | 2 +- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/py/core/base/providers/base.py b/py/core/base/providers/base.py index ed7e7905f..9cfda8dc6 100644 --- a/py/core/base/providers/base.py +++ b/py/core/base/providers/base.py @@ -3,10 +3,31 @@ from pydantic import BaseModel -from ..abstractions import R2RSerializable +class InnerConfig(BaseModel, ABC): + """A base provider configuration class""" + + class Config: + populate_by_name = True + arbitrary_types_allowed = True + ignore_extra = True -class AppConfig(R2RSerializable): + @classmethod + def create(cls: Type["ProviderConfig"], **kwargs: Any) -> "ProviderConfig": + base_args = cls.model_fields.keys() + filtered_kwargs = { + k: v if v != "None" else None + for k, v in kwargs.items() + if k in base_args + } + instance = cls(**filtered_kwargs) # type: ignore + for k, v in kwargs.items(): + if k not in base_args: + instance.extra_fields[k] = v + return instance + + +class AppConfig(InnerConfig): project_name: Optional[str] = None default_max_documents_per_user: Optional[int] = 100 default_max_chunks_per_user: Optional[int] = 10_000 @@ -51,11 +72,6 @@ class AppConfig(R2RSerializable): "org": 5_000_000, } - @classmethod - def create(cls, *args, **kwargs): - project_name = kwargs.get("project_name") - return AppConfig(project_name=project_name) - class ProviderConfig(BaseModel, ABC): """A base provider configuration class""" diff --git a/py/core/main/config.py b/py/core/main/config.py index 158387d12..c962cb770 100644 --- a/py/core/main/config.py +++ b/py/core/main/config.py @@ -103,7 +103,6 @@ def __init__(self, config_data: dict[str, Any]): self.database.update(self.kg) # type: ignore except: pass - self.app = AppConfig.create(**self.app) # type: ignore self.auth = AuthConfig.create(**self.auth, app=self.app) # type: ignore self.completion = CompletionConfig.create(**self.completion, app=self.app) # type: ignore diff --git a/py/r2r/r2r.toml b/py/r2r/r2r.toml index f574c545a..8cc2f45ca 100644 --- a/py/r2r/r2r.toml +++ b/py/r2r/r2r.toml @@ -1,7 +1,7 @@ [app] # app settings are global available like `r2r_config.agent.app` # project_name = "r2r_default" # optional, can also set with `R2R_PROJECT_NAME` env var -default_max_documents_per_user = 100 +default_max_documents_per_user = 10000 default_max_chunks_per_user = 10_000 default_max_collections_per_user = 5 From 660b91d80252590bb7361f7ab245722f627de685 Mon Sep 17 00:00:00 2001 From: emrgnt-cmplxty Date: Fri, 10 Jan 2025 14:29:11 -0800 Subject: [PATCH 2/2] bump defaults --- py/r2r/r2r.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/py/r2r/r2r.toml b/py/r2r/r2r.toml index 8cc2f45ca..ffa50aec2 100644 --- a/py/r2r/r2r.toml +++ b/py/r2r/r2r.toml @@ -1,9 +1,9 @@ [app] # app settings are global available like `r2r_config.agent.app` # project_name = "r2r_default" # optional, can also set with `R2R_PROJECT_NAME` env var -default_max_documents_per_user = 10000 -default_max_chunks_per_user = 10_000 -default_max_collections_per_user = 5 +default_max_documents_per_user = 10_000 +default_max_chunks_per_user = 10_000_000 +default_max_collections_per_user = 5_000 [agent] system_instruction_name = "rag_agent"