Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fix app config loadout #1804

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions py/core/base/providers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"""
Expand Down
1 change: 0 additions & 1 deletion py/core/main/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions py/r2r/r2r.toml
Original file line number Diff line number Diff line change
@@ -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 = 100
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"
Expand Down
Loading