diff --git a/.env.example b/.env.example index 43e69da..67e3a2c 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,6 @@ OLLAMA_BASE_URL=http://localhost:11434 OLLAMA_MODEL=qwen3.5:9b -OLLAMA_NUM_CTX=64000 +OLLAMA_NUM_CTX=64512 UEX_BASE_URL=https://api.uexcorp.space/2.0 UEX_SECRET_KEY= UEX_BEARER_TOKEN= diff --git a/README.md b/README.md index 61df174..6e198cf 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Local Ollama-powered chat for UEX marketplace workflows. ## Notes -Ollama runs locally at `http://localhost:11434` by default. This app talks to Ollama's native chat API with tool schemas, then executes approved UEX calls in the FastAPI backend. `OLLAMA_NUM_CTX` controls the per-request Ollama context window; `64000` is the default because Ollama recommends at least 64k tokens for agent-style workflows when hardware allows it. +Ollama runs locally at `http://localhost:11434` by default. This app talks to Ollama's native chat API with tool schemas, then executes approved UEX calls in the FastAPI backend. `OLLAMA_NUM_CTX` controls the per-request Ollama context window; `64512` is the default because Ollama recommends at least 64k tokens for agent-style workflows when hardware allows it. ## Releases And Updates diff --git a/pyproject.toml b/pyproject.toml index 01b1f45..09fb8a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "traderai" -version = "0.0.1" +version = "0.0.2" description = "Local Ollama-powered assistant for UEX marketplace workflows." requires-python = ">=3.11" dependencies = [ @@ -35,3 +35,4 @@ include = ["traderai*"] + diff --git a/traderai/agent.py b/traderai/agent.py index feb9750..635e802 100644 --- a/traderai/agent.py +++ b/traderai/agent.py @@ -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}.") diff --git a/traderai/config.py b/traderai/config.py index 34a0582..61067b0 100644 --- a/traderai/config.py +++ b/traderai/config.py @@ -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() diff --git a/traderai/version.py b/traderai/version.py index c358f15..fd764d2 100644 --- a/traderai/version.py +++ b/traderai/version.py @@ -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" + diff --git a/uv.lock b/uv.lock index 0ed8993..7cf0b1e 100644 --- a/uv.lock +++ b/uv.lock @@ -755,7 +755,7 @@ wheels = [ [[package]] name = "traderai" -version = "0.0.1" +version = "0.0.2" source = { virtual = "." } dependencies = [ { name = "apscheduler" }, @@ -1047,3 +1047,4 @@ wheels = [ + diff --git a/web/app.js b/web/app.js index 01815b7..19b6cbd 100644 --- a/web/app.js +++ b/web/app.js @@ -416,9 +416,6 @@ function fetchErrorMessage(error) { } const configFieldIds = { - ollama_base_url: "config-ollama-base-url", - ollama_model: "config-ollama-model", - ollama_num_ctx: "config-ollama-num-ctx", uex_base_url: "config-uex-base-url", uex_secret_key: "config-uex-secret-key", uex_bearer_token: "config-uex-bearer-token", @@ -446,11 +443,15 @@ async function refreshConfig() { function renderConfig(config) { const values = config.values || {}; + const secretsConfigured = config.secrets_configured || {}; for (const [key, id] of Object.entries(configFieldIds)) { const field = document.getElementById(id); if (!field) continue; if (field.type === "checkbox") { field.checked = Boolean(values[key]); + } else if (field.type === "password") { + field.value = ""; + field.placeholder = secretsConfigured[key] ? "Configured" : ""; } else { field.value = values[key] ?? ""; } @@ -572,7 +573,7 @@ async function postOllamaAction(endpoint, options = {}) { } function configuredOllamaModel() { - return document.getElementById("ollama-model")?.value || document.getElementById("config-ollama-model")?.value || ""; + return document.getElementById("ollama-model")?.value || ""; } async function checkForUpdate() { diff --git a/web/index.html b/web/index.html index f0de222..6b81aca 100644 --- a/web/index.html +++ b/web/index.html @@ -59,9 +59,6 @@
- - -