Skip to main content

Apollo Config & Pydantic Settings

Project description

apollo_settings

Apollo Config & Pydantic Settings

Install

pip install apollo-settings

Usage

import time
from apollo_settings import ApolloSettings, ApolloSettingsConfigDict


class MySettings(ApolloSettings):
    model_config = ApolloSettingsConfigDict(
        meta_url='your_meta_url',
        app_id='your_app_id',
    )

    openai_api_base: str = 'test'
    rerank_model: str = 'test'
    rerank_threshold: float = 0.2


class ChatEninge:

    def __init__(self, rerank_model: str) -> None:
        self.rerank_model = rerank_model
    
    def update_model(self, settings: MySettings):
        self.rerank_model = settings.rerank_model


settings = MySettings()
engine = ChatEninge(rerank_model=settings.rerank_model)
settings.on_change(engine.update_model, fields=['rerank_model'])
print(settings)
print(engine.rerank_model)
time.sleep(1)
print(settings)
print(engine.rerank_model)

ApolloClient code from @crowod

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apollo_settings-0.2.0.tar.gz (4.9 kB view hashes)

Uploaded Source

Built Distribution

apollo_settings-0.2.0-py3-none-any.whl (5.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page