File size: 1,834 Bytes
d0e0a14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68e4446
 
 
 
 
 
 
d0e0a14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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


@lru_cache()
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()