fix: config saving and config loading
Build Release EXE / build-windows-exe (release) Successful in 50s
Build Release EXE / build-windows-exe (release) Successful in 50s
This commit is contained in:
@@ -13,6 +13,7 @@ from traderai.tools import ToolRegistry
|
||||
|
||||
SYSTEM_PROMPT = """You are TraderAI, a local assistant for UEX marketplace work.
|
||||
Use tools when the user asks about UEX data, open/current listings, active negotiations, unread notifications, messages, offers, or posting ads.
|
||||
UEX credentials are configured server-side when available. Never ask the user to provide UEX_SECRET_KEY or UEX_BEARER_TOKEN in chat; call the authenticated UEX tool and only mention credential configuration if the tool returns an authentication error.
|
||||
Use the specific UEX tool for the needed endpoint, such as get_uex_commodities_prices or get_uex_vehicles. Use fields, limit, and summary mode so tool results stay compact.
|
||||
When the user asks for history, trends, changes over time, or past prices, prefer the summarize_uex_*_history tools when available; use search_uex_api_index(history_only=true) if you need to discover history endpoints.
|
||||
Prefer open and current UEX marketplace information. Do not use historical sale data, completed sale records, or sale/average-history information unless the user explicitly asks for historical sales.
|
||||
@@ -215,6 +216,21 @@ class OllamaAgent:
|
||||
parts = [
|
||||
f"Current local date/time: {iso_now()} UTC; {iso_now_in_zone(local_zone)} {local_zone}.",
|
||||
]
|
||||
uex = getattr(self.tools, "uex", None)
|
||||
if uex:
|
||||
auth_methods = []
|
||||
if uex.secret_key:
|
||||
auth_methods.append("secret key")
|
||||
if uex.bearer_token:
|
||||
auth_methods.append("bearer token")
|
||||
if auth_methods:
|
||||
parts.append(
|
||||
"UEX API authentication is configured server-side with "
|
||||
+ " and ".join(auth_methods)
|
||||
+ "; use authenticated UEX tools directly and do not ask for tokens."
|
||||
)
|
||||
else:
|
||||
parts.append("UEX API authentication is not configured server-side.")
|
||||
if self.user_name:
|
||||
parts.append(f"Known user name/handle: {self.user_name}.")
|
||||
|
||||
|
||||
+9
-1
@@ -62,7 +62,7 @@ class Settings(BaseSettings):
|
||||
|
||||
ollama_base_url: str = "http://localhost:11434"
|
||||
ollama_model: str = "qwen3.5:9b"
|
||||
ollama_num_ctx: int = 64000
|
||||
ollama_num_ctx: int = 64512
|
||||
uex_base_url: str = "https://api.uexcorp.space/2.0"
|
||||
uex_secret_key: str | None = Field(default=None)
|
||||
uex_bearer_token: str | None = Field(default=None)
|
||||
@@ -90,6 +90,11 @@ def get_settings() -> Settings:
|
||||
def settings_payload(settings: Settings | None = None) -> dict[str, Any]:
|
||||
current = settings or get_settings()
|
||||
values = current.model_dump()
|
||||
secrets_configured = {}
|
||||
for key, meta in CONFIG_FIELDS.items():
|
||||
if meta.get("secret"):
|
||||
secrets_configured[key] = bool(values.get(key))
|
||||
values[key] = ""
|
||||
return {
|
||||
"app_data_dir": str(ensure_app_data_dir()),
|
||||
"config_path": str(user_config_path()),
|
||||
@@ -97,6 +102,7 @@ def settings_payload(settings: Settings | None = None) -> dict[str, Any]:
|
||||
"edge_profile_dir": str(edge_profile_dir()),
|
||||
"values": values,
|
||||
"fields": CONFIG_FIELDS,
|
||||
"secrets_configured": secrets_configured,
|
||||
}
|
||||
|
||||
|
||||
@@ -106,6 +112,8 @@ def save_settings(values: dict[str, Any]) -> dict[str, Any]:
|
||||
for key, value in values.items():
|
||||
if key not in CONFIG_FIELDS:
|
||||
continue
|
||||
if CONFIG_FIELDS[key].get("secret") and value == "":
|
||||
continue
|
||||
next_values[key] = _coerce_value(key, value)
|
||||
|
||||
path = user_config_path()
|
||||
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
from __future__ import annotations
|
||||
|
||||
__version__ = "0.0.1"
|
||||
__version__ = "0.0.2"
|
||||
|
||||
RELEASES_URL = "https://git.hudsonriggs.systems/LambdaBankingConglomerate/TraderAI/releases"
|
||||
RELEASES_API_URL = "https://git.hudsonriggs.systems/api/v1/repos/LambdaBankingConglomerate/TraderAI/releases"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user