Configuration
Relta exposes configuration from the relta.Configuration
class. The following parameters are key configuration options:
Option |
Type |
Default |
Description |
relta_dir_path |
Path |
Path(".relta") |
Main directory for Relta files |
openai_key |
str |
- |
OpenAI API key (set via OPENAI_API_KEY) |
debug |
bool |
False |
Enable debug mode (not fully implemented) |
github_token |
str |
"" |
GitHub token (set via GITHUB_TOKEN) |
github_repo |
str |
"" |
GitHub repository (set via GITHUB_REPO) |
github_base_branch |
str |
"" |
GitHub base branch (set via GITHUB_BASE_BRANCH) |
The list of all configuration options is available in the source code.
The typical setup is to store Relta-specific configuration in pyproject.toml
in a [tool.relta]
section and use a .env
file for secrets like OPENAI_API_KEY
.
Configuration Source Priorities
The relta.Configuration
object automatically populates from the following sources, in descending order of priority:
- Passing in variables when initializing
relta.Configuration
to be passed into relta.Client
relta.toml
pyproject.toml
in a [tool.relta]
section
- Environment variables, or a
.env
file
- Default values
API Reference
Bases: BaseSettings
Configuration class for Relta
Any attributes ending with _dir_path
will be created when a Client
object is initialized.
Source code in src/relta/config.py
| class Configuration(BaseSettings):
"""Configuration class for Relta
Any attributes ending with `_dir_path` will be created when a `Client` object is initialized.
"""
# Unfortunately, default values cannot be `None`, so you will have to add some extra logic when using config variables that are optional.
model_config = SettingsConfigDict(
toml_file="relta.toml",
pyproject_toml_table_header=("tool", "relta"),
env_file=".env",
extra="ignore",
)
@classmethod
def settings_customise_sources(
cls,
settings_cls: Type[BaseSettings],
init_settings: PydanticBaseSettingsSource,
env_settings: PydanticBaseSettingsSource,
dotenv_settings: PydanticBaseSettingsSource,
file_secret_settings: PydanticBaseSettingsSource,
) -> tuple[PydanticBaseSettingsSource, ...]:
return (
init_settings,
env_settings,
TomlConfigSettingsSource(settings_cls),
PyprojectTomlConfigSettingsSource(settings_cls),
dotenv_settings,
file_secret_settings,
)
relta_dir_path: Path = Path(".relta")
relta_semantic_layer_dir_path: Path = relta_dir_path / "semantic_layer"
transient_data_dir_path: Path = relta_dir_path / "data"
relta_internal_path: Path = relta_dir_path / "relta_internal.duckdb"
relta_data_path: Path = relta_dir_path / "relta_data.duckdb"
chat_memory_path: Path = relta_dir_path / "chat_memory.sqlite"
semantic_memory_path: Path = relta_dir_path / "semantic_memory.sqlite"
storage_path: Path = relta_dir_path / "relta.sqlite"
storage_table: str = "messages"
storage_session_id_field: str = "session_id"
openai_key: str = Field(alias="OPENAI_API_KEY")
json_dumps_kwargs: dict = {"indent": 2}
yaml_dumps_kwargs: dict = {"sort_keys": False}
encryption_key: str = Field(alias="ENCRYPTION_KEY", default="")
auto_generate_encryption_key: bool = Field(
alias="AUTO_GENERATE_ENCRYPTION_KEY", default=True
)
debug: bool = False # TODO: Further implement debug mode.
anonymized_telemetry: bool = True
low_cardinality_cutoff: int = 100
github_token: str = Field(alias="GITHUB_TOKEN", default="")
github_repo: str = Field(alias="GITHUB_REPO", default="")
github_base_branch: str = Field(alias="GITHUB_BASE_BRANCH", default="")
logfire_token: str = Field(alias="LOGFIRE_TOKEN", default="")
|