Spaces:
Sleeping
Sleeping
import os | |
import pathlib | |
from functools import lru_cache | |
from environs import Env | |
from openai import AsyncOpenAI | |
env = Env() | |
env.read_env() | |
class BaseConfig: | |
BASE_DIR: pathlib.Path = pathlib.Path(__file__).parent.parent | |
OPENAI_CLIENT = AsyncOpenAI(api_key=os.getenv('OPENAI_API_KEY')) | |
REPORT_PROMPT = """Summarize the key points from the user's messages, organizing the summary into a structured | |
format. Conclude with a brief report in the language that the user speaks that encapsulates the essence of the | |
discussion.""" | |
DATABASE_URL = ( | |
f"postgresql+psycopg://{os.getenv('DATABASE_USER')}:" | |
f"{os.getenv('DATABASE_PASSWORD')}@" | |
f"{os.getenv('DATABASE_HOST')}:" | |
f"{os.getenv('DATABASE_PORT')}/" | |
f"{os.getenv('DATABASE_NAME')}" | |
) | |
IMAGE_PROMPT = """Summarize architectural style, layout, and unique features of property images briefly. | |
Highlight key elements like natural light, outdoor spaces, and distinctive design details. Mention root uses, | |
major fixtures, and special amenities concisely. Assess curb appeal, condition, and notable upgrades briefly, | |
focusing on aspects enhancing comfort, aesthetic, and quality of living. Limit response to a short paragraph. """ | |
class DevelopmentConfig(BaseConfig): | |
pass | |
class ProductionConfig(BaseConfig): | |
ORIGINS = [ | |
"http://localhost:3000", | |
] | |
class TestConfig(BaseConfig): | |
pass | |
def get_settings() -> DevelopmentConfig | ProductionConfig | TestConfig: | |
config_cls_dict = { | |
'development': DevelopmentConfig, | |
'production': ProductionConfig, | |
'testing': TestConfig | |
} | |
config_name = env('FASTAPI_CONFIG', default='production') | |
config_cls = config_cls_dict[config_name] | |
return config_cls() | |
settings = get_settings() | |