Skip to content

Settings

Redbox used the pydantic_settings library to manage settings. This library allows for settings to be defined in a type-safe way using Pydantic models. This is done by creating a Settings class that inherits from BaseSettings and defines the settings as class attributes.

redbox.models.settings.Settings

Bases: BaseSettings

Settings for the redbox application.

ai class-attribute instance-attribute

ai = AISettings()

anthropic_api_key class-attribute instance-attribute

anthropic_api_key = None

openai_api_key class-attribute instance-attribute

openai_api_key = 'NotAKey'

azure_openai_api_key class-attribute instance-attribute

azure_openai_api_key = 'NotAKey'

azure_openai_endpoint class-attribute instance-attribute

azure_openai_endpoint = None

openai_api_version class-attribute instance-attribute

openai_api_version = '2023-12-01-preview'

azure_api_version_embeddings class-attribute instance-attribute

azure_api_version_embeddings = '2024-02-01'

azure_openai_model class-attribute instance-attribute

azure_openai_model = 'azure/gpt-35-turbo-16k'

azure_embedding_model class-attribute instance-attribute

azure_embedding_model = 'text-embedding-3-large'

llm_max_tokens class-attribute instance-attribute

llm_max_tokens = 1024

embedding_backend class-attribute instance-attribute

embedding_backend = 'azure'

embedding_max_retries class-attribute instance-attribute

embedding_max_retries = 10

embedding_retry_min_seconds class-attribute instance-attribute

embedding_retry_min_seconds = 10

embedding_retry_max_seconds class-attribute instance-attribute

embedding_retry_max_seconds = 120

embedding_max_batch_size class-attribute instance-attribute

embedding_max_batch_size = 512

embedding_document_field_name class-attribute instance-attribute

embedding_document_field_name = 'embedding'

embedding_openai_base_url class-attribute instance-attribute

embedding_openai_base_url = None

embedding_openai_model class-attribute instance-attribute

embedding_openai_model = 'text-embedding-ada-002'

chat_backend class-attribute instance-attribute

chat_backend = 'azure'

partition_strategy class-attribute instance-attribute

partition_strategy = 'fast'

clustering_strategy class-attribute instance-attribute

clustering_strategy = None

elastic class-attribute instance-attribute

elastic_root_index class-attribute instance-attribute

elastic_root_index = 'redbox-data'

kibana_system_password class-attribute instance-attribute

kibana_system_password = 'redboxpass'

metricbeat_internal_password class-attribute instance-attribute

metricbeat_internal_password = 'redboxpass'

filebeat_internal_password class-attribute instance-attribute

filebeat_internal_password = 'redboxpass'

heartbeat_internal_password class-attribute instance-attribute

heartbeat_internal_password = 'redboxpass'

monitoring_internal_password class-attribute instance-attribute

monitoring_internal_password = 'redboxpass'

beats_system_password class-attribute instance-attribute

beats_system_password = 'redboxpass'

minio_host class-attribute instance-attribute

minio_host = 'minio'

minio_port class-attribute instance-attribute

minio_port = 9000

aws_access_key class-attribute instance-attribute

aws_access_key = None

aws_secret_key class-attribute instance-attribute

aws_secret_key = None

aws_region class-attribute instance-attribute

aws_region = 'eu-west-2'

bucket_name class-attribute instance-attribute

bucket_name = 'redbox-storage-dev'

embedding_model class-attribute instance-attribute

embedding_model = 'all-mpnet-base-v2'

embed_queue_name class-attribute instance-attribute

embed_queue_name = 'redbox-embedder-queue'

ingest_queue_name class-attribute instance-attribute

ingest_queue_name = 'redbox-ingester-queue'

worker_ingest_min_chunk_size class-attribute instance-attribute

worker_ingest_min_chunk_size = 120

worker_ingest_max_chunk_size class-attribute instance-attribute

worker_ingest_max_chunk_size = 300

redis_host class-attribute instance-attribute

redis_host = 'redis'

redis_port class-attribute instance-attribute

redis_port = 6379

object_store class-attribute instance-attribute

object_store = 'minio'

dev_mode class-attribute instance-attribute

dev_mode = False

superuser_email class-attribute instance-attribute

superuser_email = None

model_config class-attribute instance-attribute

model_config = SettingsConfigDict(env_file='.env', env_nested_delimiter='__', extra='allow', frozen=True)

redis_url property

redis_url

elasticsearch_client cached

elasticsearch_client()
Source code in redbox-core/redbox/models/settings.py
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
@lru_cache(1)
def elasticsearch_client(self) -> Elasticsearch:
    if isinstance(self.elastic, ElasticLocalSettings):
        log.info("Connecting to self managed Elasticsearch")
        log.info("Elasticsearch host = %s", self.elastic.host)
        return Elasticsearch(
            hosts=[
                {
                    "host": self.elastic.host,
                    "port": self.elastic.port,
                    "scheme": self.elastic.scheme,
                }
            ],
            basic_auth=(self.elastic.user, self.elastic.password),
        )

    log.info("Connecting to Elastic Cloud Cluster")
    log.info("Cloud ID = %s", self.elastic.cloud_id)
    log.info("Elastic Cloud API Key = %s", self.elastic.api_key)

    return Elasticsearch(cloud_id=self.elastic.cloud_id, api_key=self.elastic.api_key)

s3_client

s3_client()
Source code in redbox-core/redbox/models/settings.py
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
def s3_client(self):
    if self.object_store == "minio":
        client = boto3.client(
            "s3",
            aws_access_key_id=self.aws_access_key or "",
            aws_secret_access_key=self.aws_secret_key or "",
            endpoint_url=f"http://{self.minio_host}:{self.minio_port}",
        )

    elif self.object_store == "s3":
        client = boto3.client(
            "s3",
            aws_access_key_id=self.aws_access_key,
            aws_secret_access_key=self.aws_secret_key,
            region_name=self.aws_region,
        )
    elif self.object_store == "moto":
        from moto import mock_aws

        mock = mock_aws()
        mock.start()

        client = boto3.client(
            "s3",
            aws_access_key_id=self.aws_access_key,
            aws_secret_access_key=self.aws_secret_key,
            region_name=self.aws_region,
        )
    else:
        raise NotImplementedError

    return client

Elasticsearch Settings

Depending on the deployment scenarios we have two different ways to configure Elasticsearch: ElasticLocalSettings and ElasticCloudSettings.

ElasticLocalSettings

redbox.models.settings.ElasticLocalSettings

Bases: BaseModel

settings required for a local/ec2 instance of elastic

model_config class-attribute instance-attribute

model_config = SettingsConfigDict(frozen=True)

host class-attribute instance-attribute

host = 'elasticsearch'

port class-attribute instance-attribute

port = 9200

scheme class-attribute instance-attribute

scheme = 'http'

user class-attribute instance-attribute

user = 'elastic'

version class-attribute instance-attribute

version = '8.11.0'

password class-attribute instance-attribute

password = 'redboxpass'

subscription_level class-attribute instance-attribute

subscription_level = 'basic'

ElasticCloudSettings

redbox.models.settings.ElasticCloudSettings

Bases: BaseModel

settings required for elastic-cloud

model_config class-attribute instance-attribute

model_config = SettingsConfigDict(frozen=True)

api_key instance-attribute

api_key

cloud_id instance-attribute

cloud_id

subscription_level class-attribute instance-attribute

subscription_level = 'basic'