forked from Deen-Bridge/dnb-ai
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
49 lines (37 loc) · 1.43 KB
/
Copy pathconfig.py
File metadata and controls
49 lines (37 loc) · 1.43 KB
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
from functools import lru_cache
from pydantic import Field, field_validator
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
model_config = SettingsConfigDict(
env_file=".env",
case_sensitive=False,
# Many project settings live in .env but are consumed directly via
# os.getenv by the module that owns them (redis, tafsir, review, …).
# Treat anything not declared here as ignorable.
extra="ignore",
)
gemini_api_key: str = Field(default="test-key")
model_name: str = "gemini-1.5-flash"
temperature: float = Field(default=0.7, ge=0, le=2)
top_p: float = Field(default=0.8, ge=0, le=1)
top_k: int = Field(default=40, ge=1)
max_output_tokens: int = Field(default=2048, ge=1)
gemini_timeout: int = Field(default=30, ge=1)
cors_origins: list[str] = Field(
default_factory=lambda: [
"http://localhost:3000",
"https://deenbridge.vercel.app",
"https://dnb-frontend.vercel.app",
"http://localhost:8000",
]
)
port: int = Field(default=8000, ge=1)
@field_validator("cors_origins", mode="before")
@classmethod
def parse_cors_origins(cls, value):
if isinstance(value, str):
return [item.strip() for item in value.split(",") if item.strip()]
return value
@lru_cache
def get_settings() -> Settings:
return Settings()