Root cause of the 45 s timeouts: the local model got the full hosted prompt (~3.1k tokens with examples). Any prompt-cache miss meant ~40 s of CPU prefill on the single slot, and every request queued behind one paid it too. - LOCAL_PROMPT/_local_system_prompt: terse action list, one-line examples, default page text, one line per listing (L-refs, dollar prices). No per-visitor data in it, so the cache always hits; it only changes with the catalog. - _local_user: look overrides (if any) + keyword/budget MATCHING LISTINGS hint + 'VISITOR: <message>'. - max_tokens 200 for the local model; over-budget card picks dropped when some fit (_respect_budget). - Buy vs sell examples separated (sell my own thing -> listing form, never checkout). - 18/18 correct on typical prompts, warm median 5.9 s, max 7.7 s; cold prefill ~13 s.
29 lines
2.0 KiB
Python
29 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Page-text slots: server defaults match the React app, and the model prompt shows them. No server or model needed.
|
|
(Text edits are made by the model with set_theme copy; there is no rule-based text editing.)"""
|
|
import os, sys
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
|
os.environ.pop("AGENT_MARKET_LLM_API_KEY_FILE", None)
|
|
from market.copyedit import DEFAULT_COPY, current_copy
|
|
from market import agent
|
|
|
|
results = []
|
|
def check(name, ok, d=""):
|
|
results.append(bool(ok)); print(("PASS " if ok else "FAIL ") + name + (f" [{d}]" if d else ""))
|
|
|
|
app = open(os.path.join(os.path.dirname(__file__), "..", "web", "src", "App.tsx"), encoding="utf-8").read()
|
|
ok = all(s in app for s in (DEFAULT_COPY["logo"], DEFAULT_COPY["headline"], DEFAULT_COPY["subhead"])) and \
|
|
all(c["label"] in app for c in DEFAULT_COPY["chips"]) and all(b.split("{fee}% ")[-1] in app for b in DEFAULT_COPY["bullets"])
|
|
check("DEFAULT_COPY in sync with web/src/App.tsx", ok)
|
|
check("model prompt explains top-left = logo and includes PAGE_TEXT", "TOP-LEFT" in agent.UI_SCHEMA and '"logo": "Agent Market"' in agent._page_text("{}"))
|
|
check("PAGE_TEXT follows the visitor's overrides", '"logo": "New Internet"' in agent._page_text('{"copy":{"logo":"New Internet"}}'))
|
|
check("fee in bullets follows FEE_BPS", current_copy({}, 250)["bullets"][0].startswith("2.5% "))
|
|
check("compact local prompt maps TOP-LEFT = logo and has a logo example; hosted prompt has no examples block",
|
|
"TOP-LEFT" in agent.LOCAL_PROMPT and '"copy":{"logo"' in agent.LOCAL_PROMPT and "EXAMPLES" not in agent.UI_SCHEMA)
|
|
gone = [n for n in ("fallback_agent", "_rules_check") if hasattr(agent, n)]
|
|
import market.theme as th, market.copyedit as ce
|
|
gone += [n for n in ("parse_look_command",) if hasattr(th, n)] + [n for n in ("parse_copy_edit",) if hasattr(ce, n)]
|
|
check("no rule-based typed-message code left", not gone, gone)
|
|
print(f"\n{sum(results)}/{len(results)} passed")
|
|
sys.exit(0 if all(results) else 1)
|