支持自定义端口
This commit is contained in:
@@ -2,9 +2,12 @@ from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class Settings:
|
||||
port: int
|
||||
api_key: str | None
|
||||
base_url: str
|
||||
model: str
|
||||
@@ -13,7 +16,9 @@ class Settings:
|
||||
|
||||
@classmethod
|
||||
def from_env(cls) -> "Settings":
|
||||
load_dotenv(dotenv_path=Path.cwd() / ".env", override=False)
|
||||
return cls(
|
||||
port=int(os.getenv("SERVICE_PORT", "8000")),
|
||||
api_key=os.getenv("DEEPSEEK_API_KEY"),
|
||||
base_url=os.getenv("DEEPSEEK_BASE_URL", "https://api.deepseek.com"),
|
||||
model=os.getenv("DEEPSEEK_MODEL", "deepseek-v4-flash"),
|
||||
|
||||
Reference in New Issue
Block a user