This commit is contained in:
+11
-5
@@ -17,6 +17,8 @@ CONFIG_FIELDS: dict[str, dict[str, Any]] = {
|
||||
"ollama_num_ctx": {"env": "OLLAMA_NUM_CTX", "type": "integer", "secret": False},
|
||||
"openai_base_url": {"env": "OPENAI_BASE_URL", "type": "string", "secret": False},
|
||||
"openai_model": {"env": "OPENAI_MODEL", "type": "string", "secret": False},
|
||||
"deepseek_base_url": {"env": "DEEPSEEK_BASE_URL", "type": "string", "secret": False},
|
||||
"deepseek_model": {"env": "DEEPSEEK_MODEL", "type": "string", "secret": False},
|
||||
"model_reasoning_effort": {"env": "MODEL_REASONING_EFFORT", "type": "string", "secret": False},
|
||||
"codex_command": {"env": "CODEX_COMMAND", "type": "string", "secret": False},
|
||||
"codex_model": {"env": "CODEX_MODEL", "type": "string", "secret": False},
|
||||
@@ -26,6 +28,7 @@ CONFIG_FIELDS: dict[str, dict[str, Any]] = {
|
||||
"scwiki_base_url": {"env": "SCWIKI_BASE_URL", "type": "string", "secret": False},
|
||||
"scwiki_api_base_url": {"env": "SCWIKI_API_BASE_URL", "type": "string", "secret": False},
|
||||
"openai_api_key": {"env": "OPENAI_API_KEY", "type": "string", "secret": True},
|
||||
"deepseek_api_key": {"env": "DEEPSEEK_API_KEY", "type": "string", "secret": True},
|
||||
"uex_secret_key": {"env": "UEX_SECRET_KEY", "type": "string", "secret": True},
|
||||
"uex_bearer_token": {"env": "UEX_BEARER_TOKEN", "type": "string", "secret": True},
|
||||
"traderai_user_name": {"env": "TRADERAI_USER_NAME", "type": "string", "secret": False},
|
||||
@@ -77,6 +80,8 @@ class Settings(BaseSettings):
|
||||
ollama_num_ctx: int = 64512
|
||||
openai_base_url: str = "https://api.openai.com/v1"
|
||||
openai_model: str = "gpt-5.4-mini"
|
||||
deepseek_base_url: str = "https://api.deepseek.com"
|
||||
deepseek_model: str = "deepseek-v4-flash"
|
||||
model_reasoning_effort: str = "medium"
|
||||
codex_command: str = "codex"
|
||||
codex_model: str = "gpt-5.4"
|
||||
@@ -86,14 +91,15 @@ class Settings(BaseSettings):
|
||||
scwiki_base_url: str = "https://starcitizen.tools"
|
||||
scwiki_api_base_url: str = "https://api.star-citizen.wiki"
|
||||
openai_api_key: str | None = Field(default=None)
|
||||
deepseek_api_key: str | None = Field(default=None)
|
||||
uex_secret_key: str | None = Field(default=None)
|
||||
uex_bearer_token: str | None = Field(default=None)
|
||||
traderai_user_name: str | None = Field(default=None)
|
||||
traderai_memory_path: str = Field(default_factory=lambda: str(default_memory_path()))
|
||||
uex_notification_poll_seconds: int = 60
|
||||
uex_notification_poll_seconds: int = 300
|
||||
require_write_approval: bool = True
|
||||
|
||||
@field_validator("openai_api_key", "uex_secret_key", "uex_bearer_token", "traderai_user_name", mode="before")
|
||||
@field_validator("openai_api_key", "deepseek_api_key", "uex_secret_key", "uex_bearer_token", "traderai_user_name", mode="before")
|
||||
@classmethod
|
||||
def _blank_optional(cls, value: Any) -> Any:
|
||||
return None if value == "" else value
|
||||
@@ -102,13 +108,13 @@ class Settings(BaseSettings):
|
||||
@classmethod
|
||||
def _normalize_model_provider(cls, value: Any) -> str:
|
||||
text = str(value or "ollama").strip().casefold()
|
||||
return text if text in {"ollama", "openai", "codex"} else "ollama"
|
||||
return text if text in {"ollama", "deepseek"} else "ollama"
|
||||
|
||||
@field_validator("model_reasoning_effort", mode="before")
|
||||
@classmethod
|
||||
def _normalize_reasoning_effort(cls, value: Any) -> str:
|
||||
text = str(value or "medium").strip().casefold()
|
||||
return text if text in {"none", "minimal", "low", "medium", "high", "xhigh"} else "medium"
|
||||
return text if text in {"none", "minimal", "low", "medium", "high", "xhigh", "max"} else "medium"
|
||||
|
||||
@field_validator("traderai_memory_path", mode="before")
|
||||
@classmethod
|
||||
@@ -167,7 +173,7 @@ def save_settings(values: dict[str, Any]) -> dict[str, Any]:
|
||||
def _coerce_value(key: str, value: Any) -> Any:
|
||||
field_type = CONFIG_FIELDS[key]["type"]
|
||||
if value == "":
|
||||
return None if key in {"openai_api_key", "uex_secret_key", "uex_bearer_token", "traderai_user_name"} else ""
|
||||
return None if key in {"openai_api_key", "deepseek_api_key", "uex_secret_key", "uex_bearer_token", "traderai_user_name"} else ""
|
||||
if field_type == "integer":
|
||||
return int(value)
|
||||
if field_type == "boolean":
|
||||
|
||||
Reference in New Issue
Block a user