diff --git a/autogpt_platform/backend/backend/copilot/prompting.py b/autogpt_platform/backend/backend/copilot/prompting.py index b0ec560730..21cae58192 100644 --- a/autogpt_platform/backend/backend/copilot/prompting.py +++ b/autogpt_platform/backend/backend/copilot/prompting.py @@ -436,25 +436,11 @@ def get_baseline_web_search_supplement() -> str: * SendWebRequest (fetch an arbitrary URL) — ``SEND_WEB_REQUEST_BLOCK_ID``. - The Perplexity model list is pulled from ``PerplexityModel`` at - render time — if a sonar SKU is added / dropped upstream the - supplement follows automatically and the registry test catches - block-ID drift. - The supplement is static — no per-user / per-session content — so it stays on the cacheable prefix. Append to the baseline system prompt only; SDK callers would just confuse their native ``WebSearch`` with a competing block recipe. """ - from backend.blocks.perplexity import PerplexityModel # noqa: PLC0415 - - default_model = PerplexityModel.SONAR.value - # Enumerate in declaration order so the default sonar SKU stays - # first. ``.value`` gives the provider-prefixed form Kimi must pass - # verbatim (``perplexity/sonar``, not bare ``sonar``) — the block's - # input validator coerces unknown values back to SONAR, so the - # previous prompt silently degraded every call. - model_lines = "\n".join(f" - ``{m.value}``" for m in PerplexityModel) return f""" ## Web Search & URL Fetch (fast mode) @@ -464,13 +450,10 @@ copilot blocks via ``run_block`` when you need live web content. ### Web search with citations — Perplexity - Block ID: ``{PERPLEXITY_BLOCK_ID}`` -- Input: ``{{"prompt": "", "model": "{default_model}"}}``. -- ``model`` MUST be one of the provider-prefixed values below (pass the - full string verbatim — unknown values silently fall back to - ``{default_model}``): -{model_lines} -- Default to ``{default_model}`` unless the user asks for deeper - research, in which case pass ``perplexity/sonar-deep-research``. +- Input: ``{{"prompt": "", "model": "sonar"}}`` + (``model`` defaults to ``sonar``; other options: ``sonar-pro``, + ``sonar-reasoning``, ``sonar-reasoning-pro``, ``sonar-deep-research`` + — use ``sonar`` unless the user asks for deeper research.) - Output: ``response`` (string), ``annotations`` (list of URL citations). - Requires Perplexity credentials connected to the user's account. If the block errors with a missing-credentials message, call diff --git a/autogpt_platform/backend/backend/copilot/prompting_test.py b/autogpt_platform/backend/backend/copilot/prompting_test.py index c8be038012..837044772d 100644 --- a/autogpt_platform/backend/backend/copilot/prompting_test.py +++ b/autogpt_platform/backend/backend/copilot/prompting_test.py @@ -87,44 +87,9 @@ class TestBaselineWebSearchSupplement: assert '"prompt"' in text # SendWebRequest required input. assert '"url"' in text - - def test_supplement_uses_perplexitymodel_enum_values_verbatim(self): - """Regression: the earlier supplement invented bare sonar IDs - (``"sonar"``, ``"sonar-reasoning"``, ``"sonar-reasoning-pro"``) - that don't match ``PerplexityModel`` values — every call logged - an ``Invalid PerplexityModel`` warning and silently fell back to - plain ``sonar``. The supplement must now list exactly the enum - values, in full provider-prefixed form, and the default must - equal ``PerplexityModel.SONAR.value``.""" - from backend.blocks.perplexity import PerplexityModel - - text = prompting.get_baseline_web_search_supplement() - # Every enum value surfaces verbatim. - for model in PerplexityModel: - assert ( - model.value in text - ), f"Supplement missing {model.value!r} (known PerplexityModel value)" - # The default example carries the provider prefix so Kimi can - # pass it through without the fallback warning firing. - assert f'"model": "{PerplexityModel.SONAR.value}"' in text - - def test_supplement_does_not_mention_invented_sonar_variants(self): - """Regression: these bare strings were listed as valid Perplexity - models before the enum-driven rewrite — none match a real - ``PerplexityModel`` value, so the block silently fell back to - ``SONAR`` on every call. Guard against the next reader - accidentally reintroducing them.""" - text = prompting.get_baseline_web_search_supplement() - # ``sonar-reasoning`` / ``sonar-reasoning-pro`` are not enum - # members today — if upstream adds them, re-enable this check - # alongside an ``assert PerplexityModel.SONAR_REASONING ...``. - assert "sonar-reasoning" not in text - # Bare ``"sonar"`` without the ``perplexity/`` prefix is rejected - # by the block's model validator; the enum-driven supplement - # should emit only the provider-prefixed form. Check the - # quote-wrapped bare form to avoid matching ``perplexity/sonar``. - assert '"sonar"' not in text - assert '"sonar-pro"' not in text + # Default Perplexity model is named explicitly so Kimi doesn't + # guess (``sonar-xl`` etc. 404 on the Perplexity API). + assert '"sonar"' in text def test_supplement_flags_credentials_dependency(self): text = prompting.get_baseline_web_search_supplement()