From a768ee46d2e67caf68509012811ff623f41459ea Mon Sep 17 00:00:00 2001 From: 1bcMax Date: Sun, 15 Nov 2026 19:01:26 +0000 Subject: [PATCH 1/2] feat: decisions(); refuse search on non-xAI models; route search to xai/*; fix Surf pointer - decisions() on LLMClient, AsyncLLMClient, SolanaLLMClient and AsyncSolanaLLMClient (POST /v1/decisions, OpenAI Decisions-compatible). Live: $0.001045 on Solana exact. - search=True / search_parameters / x_search|web_search tools on a non-xai/* model (or fallback) raise ValueError before anything is sent; the gateway answered 400 SEARCH_UNSUPPORTED after the probe. Docstring examples fixed. - smart_chat_completion(search=True) narrows the routed chain to xai/*, else the catalog's search-capable xAI models (cheapest; premium: priciest), mirroring the TS SDK. The free profile with search raises. - SurfClient's warning named LLMClient.price, which does not exist. - CLAUDE.md / AGENTS.md: no Pyth, no retired free-model list. --- AGENTS.md | 7 +- CHANGELOG.md | 25 ++ CLAUDE.md | 7 +- README.md | 47 +++- blockrun_llm/__init__.py | 4 + blockrun_llm/client.py | 94 ++++++- blockrun_llm/decisions.py | 83 ++++++ blockrun_llm/router_adapter.py | 125 ++++++++- blockrun_llm/solana_client.py | 98 +++++++ blockrun_llm/surf.py | 8 +- blockrun_llm/types.py | 24 +- tests/unit/test_decisions_and_search.py | 325 ++++++++++++++++++++++++ 12 files changed, 829 insertions(+), 18 deletions(-) create mode 100644 blockrun_llm/decisions.py create mode 100644 tests/unit/test_decisions_and_search.py diff --git a/AGENTS.md b/AGENTS.md index 6fee3be..7d61ee6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,7 +4,7 @@ Guidance for AI coding agents working with the BlockRun Python SDK. ## Project Overview -**blockrun-llm** is a Python SDK for pay-per-request access to AI models (GPT, Claude, Gemini, DeepSeek, NVIDIA) using API account credit or x402 wallets on Solana and Base. **Includes 8 fully-free NVIDIA-hosted models** — DeepSeek V4 Flash (1M ctx), Nemotron Nano Omni (vision), Qwen3 Next + Coder, Llama 4 Maverick, Mistral Small 4, plus `gpt-oss-120b/20b` (hidden from `/v1/models` but direct calls still work). Accessible via `routing_profile="free"` or any `nvidia/*` model id. +**blockrun-llm** is a Python SDK for pay-per-request access to AI models (GPT, Claude, Gemini, DeepSeek, NVIDIA) using API account credit or x402 wallets on Solana and Base. **Includes free models** ($0 in and out): the `free` routing profile ranks the ones in `FREE_TIERS` (`blockrun_llm/router_adapter.py`), and the README's Free Tier table lists the ones to pin by id. Some listed free ids are now answered by a different model; the README names them. Never hardcode a free-model list here: check the live catalog (`GET /v1/models`) instead. **Package:** `blockrun-llm` (PyPI) **Python:** >=3.9 @@ -20,7 +20,10 @@ blockrun-llm/ │ ├── client.py # LLMClient, AsyncLLMClient │ ├── anthropic_client.py # AnthropicClient (official SDK wrapper) │ ├── solana_client.py # SolanaLLMClient (Solana payments) -│ ├── router.py # ClawRouter smart routing +│ ├── router_core/ # Port of @blockrun/router-core (do not hand-edit; re-port from upstream) +│ ├── router_adapter.py # Catalog resolution, free profile, xai/*-only search routing +│ ├── router.py # Back-compat shim over router_core +│ ├── decisions.py # decisions() body check (POST /v1/decisions) │ ├── image.py # Image generation client │ ├── types.py # Pydantic models and type definitions │ ├── validation.py # Input validation utilities diff --git a/CHANGELOG.md b/CHANGELOG.md index 5456040..1166ef5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,31 @@ All notable changes to blockrun-llm will be documented in this file. ## Unreleased +### Added +- **`decisions()`: typed judgments** on `LLMClient`, `AsyncLLMClient`, + `SolanaLLMClient` and `AsyncSolanaLLMClient` (`POST /v1/decisions`, OpenAI + Decisions-compatible, `gpt-6-luna`): `predicate` / `choice` / `score` + questions get one typed answer each (`DecisionsResponse`). Works with an API + key and with x402 on Base, Arc and Solana; only input tokens are billed + (live: $0.001045 on Solana for two questions). A malformed request raises + `ValueError` before anything is sent. Never served from the local cache. + +### Fixed +- **Search on a non-xAI model is refused before sending.** `search=True`, + `search_parameters` (other than `mode: "off"`) or an `x_search` / + `web_search` tool on a non-`xai/*` model (or fallback) raised a paid-path + 400 `SEARCH_UNSUPPORTED` from the gateway; it now raises `ValueError` with + nothing sent. The `chat()` / `chat_completion()` docstring examples used + `openai/gpt-5.2` with `search=True` and now use `xai/grok-4.7`. +- **`smart_chat_completion(..., search=True)` stays on `xai/*`.** The routed + chain is narrowed to its `xai/*` candidates; when it has none, it falls back + to the catalog's search-capable xAI models, cheapest first (`premium`: most + capable first), as the TypeScript SDK does. `routing_profile="free"` with + search raises `ValueError` (no free model serves search). +- `SurfClient`'s deprecation warning pointed at `LLMClient.price`, which does + not exist; it now names `PriceClient`, `LLMClient.pm` and + `LLMClient.defi` / `LLMClient.dex`. + ### Docs - **README model tables re-synced with the live catalog** (`GET /v1/models`, 2026-11-15). Added `anthropic/claude-fable-5.2`, `google/gemini-4-carbon`, diff --git a/CLAUDE.md b/CLAUDE.md index 4495eb8..20bc93a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,6 +1,6 @@ # BlockRun LLM SDK (Python) -Python SDK for 91 LLMs plus image/video/music/speech generation, standalone search, multi-chain RPC, and Pyth-backed market data — paid two ways: a BlockRun API key drawing on prepaid account credit, or USDC micropayments via x402 where the wallet signature is the authentication and the key never leaves your machine. +Python SDK for 91 LLMs plus image/video/music/speech generation, standalone search, multi-chain RPC, free market data (crypto / FX / commodity daily closes), and typed judgments (`decisions()`) — paid two ways: a BlockRun API key drawing on prepaid account credit, or USDC micropayments via x402 where the wallet signature is the authentication and the key never leaves your machine. ## Commands @@ -25,7 +25,7 @@ blockrun_llm/ ├── x402.py # x402 payment protocol ├── poll_auth.py # Solana media-poll ownership proofs (x-poll-* headers) ├── router_core/ # Port of @blockrun/router-core (shared with the TS SDK + gateway) -├── router_adapter.py # Host glue: catalog ids, payment floors, free profile +├── router_adapter.py # Host glue: catalog ids, payment floors, free profile, xai/*-only search routing ├── router.py # Back-compat shim over router_core ├── types.py # Type definitions ├── validation.py # Input validation @@ -37,7 +37,8 @@ blockrun_llm/ ├── portrait.py # Virtual Portrait enrollment (AI characters) ├── realface.py # RealFace enrollment (real-person likeness) ├── search.py # Standalone Grok Live Search -├── price.py # Pyth market data (crypto/fx/commodity/stocks) +├── decisions.py # decisions() body check — typed judgments (POST /v1/decisions) +├── price.py # Market data: crypto/fx/commodity daily closes (free); stock lists (price/history 501) ├── rpc.py # Multi-chain JSON-RPC (Tatum gateway, 40+ chains) └── anthropic_client.py # Anthropic-compatible client ``` diff --git a/README.md b/README.md index c7eb781..6407924 100644 --- a/README.md +++ b/README.md @@ -1070,6 +1070,46 @@ for url in result.citations or []: print(url) ``` +## Decisions — typed judgments (`decisions()`) + +`decisions()` asks `gpt-6-luna` questions with a fixed answer space and gets one +typed answer per question instead of text: a `predicate` (probability that it +holds), a `choice` (one of your values, with per-value probabilities) or a +`score` (position on an ordered rubric). Request and response match OpenAI's +Decisions API. It is on `LLMClient`, `AsyncLLMClient`, `SolanaLLMClient` and +`AsyncSolanaLLMClient`, with an API key or a wallet. + +```python +from blockrun_llm import LLMClient + +client = LLMClient() + +result = client.decisions( + "My card was charged twice for one order and nobody answers my emails.", + [ + {"type": "predicate", "name": "urgent", "instructions": "Does this need a reply today?"}, + {"type": "choice", "name": "team", "instructions": "Which team owns this?", + "choices": [{"value": "billing"}, {"value": "shipping"}, + {"value": "none", "description": "fits no team"}]}, + {"type": "score", "name": "anger", "instructions": "How upset is the writer?", + "levels": [{"label": "calm"}, {"label": "annoyed"}, {"label": "furious"}]}, # lowest first + ], +) +print(result.answers[0]["probability"]) # 0.85 +print(result.answers[1]["choice"]) # 'billing' +print(result.answers[2]["score"]) # 1 (index on the rubric) +``` + +Only input tokens are billed. A wallet call pays the 402's quote: an +upper-bound estimate of the input tokens plus the $0.001 transaction fee. With +an API key the account is billed on reported tokens. `input` is a string or +messages with text and inline `data:image/*` images (hosted image URLs are +refused); the gateway caps a call at 64 questions, 255 choices or levels each, +120,000 characters and 8 images, and refuses an over-limit request with a 400 +before any payment. A malformed request (no questions, a duplicate name, a +choice without choices) raises `ValueError` before anything is sent. A `choice` +always picks one of your values, so give it a `none` value. + ## Market Data (`PriceClient`) Crypto, FX and commodity prices, OHLC history and symbol lists — all **free**, @@ -1446,8 +1486,11 @@ from blockrun_llm import LLMClient client = LLMClient() -# Live Search runs on xai/* models only; any other model answers -# 400 SEARCH_UNSUPPORTED. +# Live Search runs on xai/* models only. The SDK refuses search on any other +# model with a ValueError before anything is sent or paid (the gateway would +# answer 400 SEARCH_UNSUPPORTED). smart_chat_completion(..., search=True) +# routes to the catalog's search-capable xAI models: cheapest first, most +# capable first on routing_profile="premium". # Simple: enable live search with search=True response = client.chat( "xai/grok-4.7", diff --git a/blockrun_llm/__init__.py b/blockrun_llm/__init__.py index 9673a1e..5cadcd0 100644 --- a/blockrun_llm/__init__.py +++ b/blockrun_llm/__init__.py @@ -80,6 +80,7 @@ list_models, testnet_client, ) +from .decisions import DECISIONS_DEFAULT_MODEL from .image import ImageClient from .music import MusicClient from .phone import PhoneClient @@ -120,6 +121,7 @@ ChatCompletionChunk, ChatMessage, ChatResponse, + DecisionsResponse, ImageData, ImageModel, ImageResponse, @@ -200,6 +202,7 @@ __version__ = "1.22.3" __all__ = [ + "DECISIONS_DEFAULT_MODEL", "DEFAULT_API_KEY_URL", "ENV_API_KEY", "ENV_API_KEY_URL", @@ -225,6 +228,7 @@ "ChatCompletionChunk", "ChatMessage", "ChatResponse", + "DecisionsResponse", "ImageClient", "ImageData", "ImageModel", diff --git a/blockrun_llm/client.py b/blockrun_llm/client.py index c7cc550..5c0332f 100644 --- a/blockrun_llm/client.py +++ b/blockrun_llm/client.py @@ -61,9 +61,12 @@ resolve_api_key, wallet_only, ) +from .decisions import build_decisions_body from .router_adapter import ( BASE_MINIMUM_PAYMENT_USD, build_model_pricing, + requests_search, + require_search_model, route_with_catalog, routing_profile_for_model, routing_text, @@ -81,6 +84,7 @@ APIError, ChatCompletionChunk, ChatResponse, + DecisionsResponse, ImageResponse, PaymentError, RetiredEndpointError, @@ -1117,6 +1121,7 @@ def smart_chat_completion( tool_choice=tool_choice, conversation_chars=view["conversation_chars"], has_vision=view["has_vision"], + search=requests_search(search, search_parameters, tools), minimum_payment_usd=BASE_MINIMUM_PAYMENT_USD, ) response = self.chat_completion( @@ -1217,7 +1222,7 @@ def chat( # With xAI Live Search (for real-time X/Twitter data) response = client.chat( - "openai/gpt-5.2", + "xai/grok-4.7", "What are the latest posts from @blockrunai?", search=True # Enable live search ) @@ -1303,7 +1308,7 @@ def chat_completion( # With xAI Live Search result = client.chat_completion( - "openai/gpt-5.2", + "xai/grok-4.7", [{"role": "user", "content": "Latest news about AI?"}], search=True ) @@ -1372,6 +1377,7 @@ def chat_completion( body["top_p"] = top_p # Handle xAI Live Search parameters + require_search_model([model, *(fallback_models or [])], search, search_parameters, tools) if search_parameters is not None: body["search_parameters"] = search_parameters elif search is True: @@ -1497,6 +1503,7 @@ def chat_completion_stream( body["tools"] = tools if tool_choice is not None: body["tool_choice"] = tool_choice + require_search_model([model, *(fallback_models or [])], search, search_parameters, tools) if search_parameters is not None: body["search_parameters"] = search_parameters elif search is True: @@ -2432,6 +2439,46 @@ def search( data = self._request_with_payment_raw("/v1/search", body) return SearchResult(**data) + def decisions( + self, + input: str | list[dict[str, Any]], + questions: list[dict[str, Any]], + *, + model: str | None = None, + metadata: dict[str, str] | None = None, + ) -> DecisionsResponse: + """ + Typed judgments (OpenAI Decisions-compatible, ``gpt-6-luna``): one typed + answer per question instead of text. + + Each question has a fixed answer space: ``predicate`` (probability that + it holds), ``choice`` (one of your ``choices[].value``, with per-value + probabilities) or ``score`` (position on ``levels``, lowest first). + Only input tokens are billed. With a wallet the 402 quotes an + upper-bound estimate of them plus the $0.001 fee, and that quote + settles; with an API key the account pays the reported tokens. A request + over the gateway's limits is refused with a 400 before payment. A + ``choice`` always picks one of your values: give it a ``none`` value. + + Raises: + ValueError: on a malformed request, before anything is sent. + + Example: + result = client.decisions( + "My card was charged twice for one order.", + [ + {"type": "predicate", "name": "urgent", + "instructions": "Does this need a reply today?"}, + {"type": "choice", "name": "team", "instructions": "Which team owns this?", + "choices": [{"value": "billing"}, {"value": "shipping"}, {"value": "none"}]}, + ], + ) + print(result.answers[0]["probability"], result.answers[1]["choice"]) + """ + body = build_decisions_body(input, questions, model=model, metadata=metadata) + data = self._request_with_payment_raw("/v1/decisions", body) + return DecisionsResponse(**data) + # ── Exa Web Search (Powered by Exa) ───────────────────────────────────── def exa(self, path: str, body: dict[str, Any]) -> dict[str, Any]: @@ -3327,6 +3374,7 @@ async def smart_chat_completion( tool_choice=tool_choice, conversation_chars=view["conversation_chars"], has_vision=view["has_vision"], + search=requests_search(search, search_parameters, tools), minimum_payment_usd=BASE_MINIMUM_PAYMENT_USD, ) response = await self.chat_completion( @@ -3449,6 +3497,7 @@ async def chat_completion( body["top_p"] = top_p # Handle xAI Live Search parameters + require_search_model([model, *(fallback_models or [])], search, search_parameters, tools) if search_parameters is not None: body["search_parameters"] = search_parameters elif search is True: @@ -3538,6 +3587,7 @@ async def chat_completion_stream( body["tools"] = tools if tool_choice is not None: body["tool_choice"] = tool_choice + require_search_model([model, *(fallback_models or [])], search, search_parameters, tools) if search_parameters is not None: body["search_parameters"] = search_parameters elif search is True: @@ -4342,6 +4392,46 @@ async def search( data = await self._request_with_payment_raw("/v1/search", body) return SearchResult(**data) + async def decisions( + self, + input: str | list[dict[str, Any]], + questions: list[dict[str, Any]], + *, + model: str | None = None, + metadata: dict[str, str] | None = None, + ) -> DecisionsResponse: + """ + Typed judgments (OpenAI Decisions-compatible, ``gpt-6-luna``): one typed + answer per question instead of text. + + Each question has a fixed answer space: ``predicate`` (probability that + it holds), ``choice`` (one of your ``choices[].value``, with per-value + probabilities) or ``score`` (position on ``levels``, lowest first). + Only input tokens are billed. With a wallet the 402 quotes an + upper-bound estimate of them plus the $0.001 fee, and that quote + settles; with an API key the account pays the reported tokens. A request + over the gateway's limits is refused with a 400 before payment. A + ``choice`` always picks one of your values: give it a ``none`` value. + + Raises: + ValueError: on a malformed request, before anything is sent. + + Example: + result = await client.decisions( + "My card was charged twice for one order.", + [ + {"type": "predicate", "name": "urgent", + "instructions": "Does this need a reply today?"}, + {"type": "choice", "name": "team", "instructions": "Which team owns this?", + "choices": [{"value": "billing"}, {"value": "shipping"}, {"value": "none"}]}, + ], + ) + print(result.answers[0]["probability"], result.answers[1]["choice"]) + """ + body = build_decisions_body(input, questions, model=model, metadata=metadata) + data = await self._request_with_payment_raw("/v1/decisions", body) + return DecisionsResponse(**data) + # ── Prediction Markets (Powered by Predexon) ──────────────────────────── async def pm(self, path: str, **params: Any) -> dict[str, Any]: diff --git a/blockrun_llm/decisions.py b/blockrun_llm/decisions.py new file mode 100644 index 0000000..c9b757a --- /dev/null +++ b/blockrun_llm/decisions.py @@ -0,0 +1,83 @@ +"""Decisions — typed judgments, OpenAI Decisions-compatible (``POST /v1/decisions``). + +The caller sends evidence (``input``) and questions with a fixed answer space +(``predicate``, ``choice`` or ``score``) and gets one typed answer per question +back instead of text. Served on every rail: an account API key on +api.blockrun.ai, and x402 ``exact`` on Base, Arc and Solana. Only input tokens +are billed. + +The gateway owns the limits (64 questions, 255 choices or levels, 120,000 +characters of text, 8 inline ``data:image/*`` images, no hosted image URLs) +and refuses an over-limit request with a 400 before any payment. This module +only checks the shape a caller can still get wrong, so a malformed request +fails before anything is sent. +""" + +from __future__ import annotations + +from collections.abc import Mapping, Sequence +from typing import Any + +#: The model OpenAI serves Decisions from; the gateway also accepts +#: ``openai/gpt-6-luna`` and ``openai/gpt-6-luna-decisions``. +DECISIONS_DEFAULT_MODEL = "gpt-6-luna" + +_QUESTION_TYPES = ("predicate", "choice", "score") + + +def build_decisions_body( + input: str | Sequence[Mapping[str, Any]], + questions: Sequence[Mapping[str, Any]], + *, + model: str | None = None, + metadata: Mapping[str, str] | None = None, +) -> dict[str, Any]: + """The request body for ``POST /v1/decisions``, after a shape check. + + Raises: + ValueError: on a malformed request. Nothing has been sent. + """ + empty = ( + len(input) == 0 + if isinstance(input, str) + else not isinstance(input, Sequence) or len(input) == 0 + ) + if empty: + raise ValueError( + "decisions: input must be a non-empty string or a non-empty list of messages" + ) + if not isinstance(questions, Sequence) or isinstance(questions, str) or len(questions) == 0: + raise ValueError("decisions: questions must be a non-empty list") + names: set[str] = set() + for i, q in enumerate(questions): + if not isinstance(q, Mapping): + raise ValueError(f"decisions: questions[{i}] must be a dict") + if q.get("type") not in _QUESTION_TYPES: + raise ValueError( + f'decisions: questions[{i}].type must be "predicate", "choice" or "score"' + ) + name = q.get("name") + if not isinstance(name, str) or not name: + raise ValueError(f"decisions: questions[{i}].name must be a non-empty string") + instructions = q.get("instructions") + if not isinstance(instructions, str) or not instructions: + raise ValueError(f"decisions: questions[{i}].instructions must be a non-empty string") + if name in names: + raise ValueError( + f'decisions: questions[{i}].name "{name}" is used twice; answers are keyed by name' + ) + names.add(name) + if q["type"] == "choice" and not q.get("choices"): + raise ValueError(f"decisions: questions[{i}] (choice) needs a non-empty choices list") + if q["type"] == "score" and not q.get("levels"): + raise ValueError( + f"decisions: questions[{i}] (score) needs a non-empty levels list, lowest first" + ) + body: dict[str, Any] = { + "model": model or DECISIONS_DEFAULT_MODEL, + "input": input if isinstance(input, str) else [dict(m) for m in input], + "questions": [dict(q) for q in questions], + } + if metadata is not None: + body["metadata"] = dict(metadata) + return body diff --git a/blockrun_llm/router_adapter.py b/blockrun_llm/router_adapter.py index 560cba6..d233111 100644 --- a/blockrun_llm/router_adapter.py +++ b/blockrun_llm/router_adapter.py @@ -14,6 +14,7 @@ from __future__ import annotations import math +import re from collections.abc import Mapping, Sequence from typing import Any @@ -141,6 +142,82 @@ class ResolvedRoutingDecision(RoutingDecision, total=False): } +class ModelPricingMap(dict): # type: ignore[type-arg] + """The router's pricing map, plus the catalog's search-capable models. + + ``search_models`` lists the available ``xai/*`` chat models the catalog + tags ``search`` (every available ``xai/*`` chat model when none is + tagged). The gateway serves search on ``xai/*`` ids only. + """ + + search_models: list[str] + + +def requests_search( + search: bool | None = None, + search_parameters: Mapping[str, Any] | None = None, + tools: Sequence[Mapping[str, Any]] | None = None, +) -> bool: + """Whether a call asks for xAI search. + + An ``x_search`` / ``web_search`` tool, or ``search_parameters`` whose + ``mode`` is not ``"off"``, or the ``search=True`` shortcut when no + ``search_parameters`` are given (the precedence the request body follows). + The gateway serves search on ``xai/*`` models only and answers any other + model with a non-transient 400 ``SEARCH_UNSUPPORTED``. + """ + if any(tool.get("type") in ("x_search", "web_search") for tool in tools or []): + return True + if search_parameters is not None: + return search_parameters.get("mode") != "off" + return search is True + + +def require_search_model( + models: Sequence[str], + search: bool | None = None, + search_parameters: Mapping[str, Any] | None = None, + tools: Sequence[Mapping[str, Any]] | None = None, +) -> None: + """Refuse, before anything is sent or paid, a search call on a non-xAI model.""" + if not requests_search(search, search_parameters, tools): + return + wrong = [model for model in models if not model.startswith("xai/")] + if wrong: + raise ValueError( + "Search (search=True, search_parameters, or an x_search / web_search tool) runs on " + f"xai/* models only; the gateway refuses {', '.join(wrong)} with a 400. " + "Use an xai/* model (e.g. xai/grok-4.7), smart_chat_completion(..., search=True), " + "or drop the search options." + ) + + +def _search_fallback_chain( + model_pricing: Mapping[str, ModelPricing], routing_profile: str | None +) -> list[str]: + """Search models when the route has none: cheapest first (premium: priciest first).""" + pool = getattr(model_pricing, "search_models", None) + if pool is None: + pool = [model_id for model_id in model_pricing if model_id.startswith("xai/")] + pool = [model_id for model_id in pool if model_id in model_pricing] + + def price(model_id: str) -> float: + entry = model_pricing[model_id] + return entry["input_price"] + entry["output_price"] + + # Ties go to the newer id (the larger one in version order). + by_id = sorted(pool, key=_version_key, reverse=True) + if routing_profile == "premium": + return sorted(by_id, key=price, reverse=True) + return sorted(by_id, key=price) + + +def _version_key(model_id: str) -> list[Any]: + return [ + (0, int(part)) if part.isdigit() else (1, part) for part in re.split(r"(\d+)", model_id) + ] + + def build_model_pricing(models: list[dict[str, Any]]) -> dict[str, ModelPricing]: """Build the router's pricing map from a ``/v1/models`` payload. @@ -153,7 +230,7 @@ def build_model_pricing(models: list[dict[str, Any]]) -> dict[str, ModelPricing] older snapshots used top-level ``inputPrice`` / ``outputPrice``. Both are accepted so the SDK keeps working through backend transitions. """ - pricing: dict[str, ModelPricing] = {} + pricing = ModelPricingMap() for model in models: if model.get("available") is False: continue @@ -169,6 +246,15 @@ def build_model_pricing(models: list[dict[str, Any]]) -> dict[str, ModelPricing] "output_price": float(output_price or 0), "flat_price": float(flat_price or 0), } + xai_chat = [ + model + for model in models + if str(model.get("id", "")).startswith("xai/") + and model["id"] in pricing + and "chat" in (model.get("categories") or []) + ] + tagged = [model for model in xai_chat if "search" in (model.get("categories") or [])] + pricing.search_models = [model["id"] for model in (tagged or xai_chat)] return pricing @@ -278,13 +364,16 @@ def route_with_catalog( minimum_payment_usd: float = SOLANA_MINIMUM_PAYMENT_USD, conversation_chars: int | None = None, has_vision: bool = False, + search: bool = False, config: RoutingConfig | None = None, now: Any = None, ) -> ResolvedRoutingDecision: """Route a request and resolve the ranking against the live catalog. ``routing_profile`` accepts Router Core's ``"eco" | "auto" | "premium"`` - plus the SDK-only ``"free"``. + plus the SDK-only ``"free"``. ``search`` (see :func:`requests_search`) + keeps only ``xai/*`` candidates, the only models the gateway serves search + on. """ tool_list = list(tools or []) if tool_choice == "none": @@ -353,6 +442,30 @@ def route_with_catalog( if free_only: callable_models = free_only + # Search runs on xai/* only: the gateway refuses any other model with a + # non-transient 400, so a non-xai pick (or fallback) would fail outright. + # Keep the router's order among the xai/* candidates. When the route has + # none (the common case: the router seldom ranks xAI), fall back to the + # catalog's search-capable xAI models, cheapest first (premium: most + # capable first). Mirrors the TypeScript SDK's routeWithCatalog. + search_fallback = False + if search: + if is_free_profile: + raise ValueError( + "The free profile has no search-capable model: search runs on paid xai/* " + "models only. Use routing_profile='eco' (or another) or drop the search options." + ) + searchable = [model_id for model_id in callable_models if model_id.startswith("xai/")] + if not searchable: + searchable = _search_fallback_chain(model_pricing, routing_profile) + search_fallback = True + if not searchable: + raise ValueError( + "Search runs on xai/* models only, and the catalog lists no available xai/* " + "chat model. Call an xai/* model directly or drop the search options." + ) + callable_models = searchable + # Capacity check against the FULL conversation, not just the routing prompt # — an agent transcript can be 100x the last user message, and a context # overflow is a non-transient 400 the fallback chain won't save. Models @@ -392,7 +505,13 @@ def route_with_catalog( resolved_decision["cost_estimate"] = cost_estimate resolved_decision["savings"] = savings resolved_decision["model"] = model - if model != decision["model"]: + if search_fallback: + which = "most capable" if routing_profile == "premium" else "cheapest" + resolved_decision["reasoning"] = ( + f"{decision['reasoning']} | search runs on xai/* only; the route had none, " + f"so the {which} search-capable xAI model: {model}" + ) + elif model != decision["model"]: resolved_decision["reasoning"] = f"{decision['reasoning']} | catalog fallback: {model}" resolved_decision["candidates"] = available_candidates if "candidate_scores" in decision: diff --git a/blockrun_llm/solana_client.py b/blockrun_llm/solana_client.py index 57ae1b5..ab6aa91 100644 --- a/blockrun_llm/solana_client.py +++ b/blockrun_llm/solana_client.py @@ -48,6 +48,7 @@ # in both fallback chains. client.py does not import this module, so there is # no cycle. from .client import _SETTLED_ATTR, _enforce_spend_limits, _mark_settled +from .decisions import build_decisions_body from .jobs import absolute_poll_url from .poll_auth import ( is_poll_ownership_refusal, @@ -61,6 +62,8 @@ from .router_adapter import ( SOLANA_MINIMUM_PAYMENT_USD, build_model_pricing, + requests_search, + require_search_model, route_with_catalog, routing_profile_for_model, routing_text, @@ -79,6 +82,7 @@ BlockrunError, ChatCompletionChunk, ChatResponse, + DecisionsResponse, ImageResponse, MusicResponse, PaymentError, @@ -1225,6 +1229,7 @@ def smart_chat_completion( tool_choice=tool_choice, conversation_chars=view["conversation_chars"], has_vision=view["has_vision"], + search=requests_search(search, search_parameters or None, tools), minimum_payment_usd=SOLANA_MINIMUM_PAYMENT_USD, ) response = self.chat_completion( @@ -1333,6 +1338,9 @@ def chat_completion( body["temperature"] = temperature if top_p is not None: body["top_p"] = top_p + require_search_model( + [model, *(fallback_models or [])], search, search_parameters or None, tools + ) if search_parameters: body["search_parameters"] = search_parameters elif search: @@ -1465,6 +1473,9 @@ def chat_completion_stream( body["temperature"] = temperature if top_p is not None: body["top_p"] = top_p + require_search_model( + [model, *(fallback_models or [])], search, search_parameters or None, tools + ) if search_parameters: body["search_parameters"] = search_parameters elif search: @@ -3786,6 +3797,46 @@ def search( data = self._request_with_payment_raw("/v1/search", body, timeout=eff_timeout) return SearchResult(**data) + def decisions( + self, + input: str | list[dict[str, Any]], + questions: list[dict[str, Any]], + *, + model: str | None = None, + metadata: dict[str, str] | None = None, + ) -> DecisionsResponse: + """ + Typed judgments (OpenAI Decisions-compatible, ``gpt-6-luna``): one typed + answer per question instead of text. + + Each question has a fixed answer space: ``predicate`` (probability that + it holds), ``choice`` (one of your ``choices[].value``, with per-value + probabilities) or ``score`` (position on ``levels``, lowest first). + Only input tokens are billed. With a wallet the 402 quotes an + upper-bound estimate of them plus the $0.001 fee, and that quote + settles; with an API key the account pays the reported tokens. A request + over the gateway's limits is refused with a 400 before payment. A + ``choice`` always picks one of your values: give it a ``none`` value. + + Raises: + ValueError: on a malformed request, before anything is sent. + + Example: + result = client.decisions( + "My card was charged twice for one order.", + [ + {"type": "predicate", "name": "urgent", + "instructions": "Does this need a reply today?"}, + {"type": "choice", "name": "team", "instructions": "Which team owns this?", + "choices": [{"value": "billing"}, {"value": "shipping"}, {"value": "none"}]}, + ], + ) + print(result.answers[0]["probability"], result.answers[1]["choice"]) + """ + body = build_decisions_body(input, questions, model=model, metadata=metadata) + data = self._request_with_payment_raw("/v1/decisions", body) + return DecisionsResponse(**data) + # ── Prediction Markets (Powered by Predexon) ──────────────────────────── def pm(self, path: str, **params: Any) -> dict[str, Any]: @@ -4466,6 +4517,7 @@ async def smart_chat_completion( tool_choice=tool_choice, conversation_chars=view["conversation_chars"], has_vision=view["has_vision"], + search=requests_search(search, search_parameters or None, tools), minimum_payment_usd=SOLANA_MINIMUM_PAYMENT_USD, ) response = await self.chat_completion( @@ -4563,6 +4615,9 @@ async def chat_completion( body["temperature"] = temperature if top_p is not None: body["top_p"] = top_p + require_search_model( + [model, *(fallback_models or [])], search, search_parameters or None, tools + ) if search_parameters: body["search_parameters"] = search_parameters elif search: @@ -4637,6 +4692,9 @@ async def chat_completion_stream( body["temperature"] = temperature if top_p is not None: body["top_p"] = top_p + require_search_model( + [model, *(fallback_models or [])], search, search_parameters or None, tools + ) if search_parameters: body["search_parameters"] = search_parameters elif search: @@ -5303,6 +5361,46 @@ async def search( data = await self._request_with_payment_raw("/v1/search", body, timeout=eff_timeout) return SearchResult(**data) + async def decisions( + self, + input: str | list[dict[str, Any]], + questions: list[dict[str, Any]], + *, + model: str | None = None, + metadata: dict[str, str] | None = None, + ) -> DecisionsResponse: + """ + Typed judgments (OpenAI Decisions-compatible, ``gpt-6-luna``): one typed + answer per question instead of text. + + Each question has a fixed answer space: ``predicate`` (probability that + it holds), ``choice`` (one of your ``choices[].value``, with per-value + probabilities) or ``score`` (position on ``levels``, lowest first). + Only input tokens are billed. With a wallet the 402 quotes an + upper-bound estimate of them plus the $0.001 fee, and that quote + settles; with an API key the account pays the reported tokens. A request + over the gateway's limits is refused with a 400 before payment. A + ``choice`` always picks one of your values: give it a ``none`` value. + + Raises: + ValueError: on a malformed request, before anything is sent. + + Example: + result = await client.decisions( + "My card was charged twice for one order.", + [ + {"type": "predicate", "name": "urgent", + "instructions": "Does this need a reply today?"}, + {"type": "choice", "name": "team", "instructions": "Which team owns this?", + "choices": [{"value": "billing"}, {"value": "shipping"}, {"value": "none"}]}, + ], + ) + print(result.answers[0]["probability"], result.answers[1]["choice"]) + """ + body = build_decisions_body(input, questions, model=model, metadata=metadata) + data = await self._request_with_payment_raw("/v1/decisions", body) + return DecisionsResponse(**data) + # ── Balance ───────────────────────────────────────────────────────────── async def get_balance(self) -> float: diff --git a/blockrun_llm/surf.py b/blockrun_llm/surf.py index 558ebb3..29aa9fc 100644 --- a/blockrun_llm/surf.py +++ b/blockrun_llm/surf.py @@ -189,8 +189,9 @@ class SurfClient: .. deprecated:: Both gateways have answered every ``/v1/surf/*`` call with ``410 - endpoint_retired`` since 2026-09-06. Use ``LLMClient.price`` for prices - and ``LLMClient.pm`` for prediction markets. This client will be removed + endpoint_retired`` since 2026-09-06. Use ``PriceClient`` for prices, + ``LLMClient.pm`` for prediction markets, and ``LLMClient.defi`` / + ``LLMClient.dex`` for DeFi and DEX data. This client will be removed in a future release. Wraps the `/v1/surf/*` partner proxy. Use SurfClient.endpoints() for discovery @@ -209,7 +210,8 @@ def __init__( ): warnings.warn( "SurfClient is deprecated: the gateway retired /v1/surf/* on 2026-09-06 " - "(410 endpoint_retired). Use LLMClient.price or LLMClient.pm instead.", + "(410 endpoint_retired). Use PriceClient for prices, LLMClient.pm for " + "prediction markets, or LLMClient.defi / LLMClient.dex for DeFi and DEX data.", DeprecationWarning, stacklevel=2, ) diff --git a/blockrun_llm/types.py b/blockrun_llm/types.py index e23aa90..9a18c95 100644 --- a/blockrun_llm/types.py +++ b/blockrun_llm/types.py @@ -2,7 +2,7 @@ from typing import Any, Dict, List, Literal, Optional, Union -from pydantic import BaseModel +from pydantic import BaseModel, ConfigDict # Tool calling types (OpenAI compatible) @@ -958,9 +958,27 @@ class SearchResult(BaseModel): model: Optional[str] = None -# Pyth-backed market data types (crypto, stocks, fx, commodity) +class DecisionsResponse(BaseModel): + """Response from ``POST /v1/decisions`` (OpenAI Decisions-compatible). + + ``answers`` holds one typed answer per question, in the order asked: + ``{"type": "predicate", "name", "probability"}``, + ``{"type": "choice", "name", "choice", "probabilities": [{"value", "probability"}], "confidence"}`` + or ``{"type": "score", "name", "score", "probabilities": [{"value", "label", "probability"}], + "confidence"}``. Only input tokens are billed (``usage.output_tokens`` is 0). + """ + + model_config = ConfigDict(extra="allow") + + model: str + answers: List[Dict[str, Any]] + usage: Optional[Dict[str, Any]] = None + id: Optional[str] = None + + +# Market data types (crypto, fx, commodity daily closes; stock symbol lists) class PricePoint(BaseModel): - """A single latest price quote from the Pyth network.""" + """A single latest price quote (a daily close, not realtime).""" symbol: str price: float diff --git a/tests/unit/test_decisions_and_search.py b/tests/unit/test_decisions_and_search.py new file mode 100644 index 0000000..9853948 --- /dev/null +++ b/tests/unit/test_decisions_and_search.py @@ -0,0 +1,325 @@ +"""decisions() and the xAI-only search guard. + +decisions(): typed judgments on POST /v1/decisions (OpenAI Decisions-compatible). +Search: the gateway serves search on xai/* models only and answers any other +model with a non-transient 400 SEARCH_UNSUPPORTED, so an explicit non-xAI +model is refused before anything is sent, and routed calls stay on xai/*. +""" + +from __future__ import annotations + +import json +from typing import Any + +import httpx +import pytest + +import blockrun_llm.cache as cache_mod +from blockrun_llm import DECISIONS_DEFAULT_MODEL, DecisionsResponse, LLMClient +from blockrun_llm.decisions import build_decisions_body +from blockrun_llm.router_adapter import ( + build_model_pricing, + require_search_model, + requests_search, + route_with_catalog, +) + +from ..helpers import TEST_PRIVATE_KEY, build_payment_required_response + +QUESTIONS = [ + {"type": "predicate", "name": "urgent", "instructions": "Does this need a reply today?"}, + { + "type": "choice", + "name": "team", + "instructions": "Which team?", + "choices": [{"value": "billing"}, {"value": "none"}], + }, + { + "type": "score", + "name": "anger", + "instructions": "How upset?", + "levels": [{"label": "calm"}, {"label": "furious"}], + }, +] + +# The shape gpt-6-luna answered with on sol.blockrun.ai, 2026-11-15. +ANSWER = { + "model": "gpt-6-luna", + "answers": [ + {"type": "predicate", "name": "urgent", "probability": 0.85}, + { + "type": "choice", + "name": "team", + "choice": "billing", + "confidence": 1, + "probabilities": [ + {"value": "billing", "probability": 1}, + {"value": "none", "probability": 0}, + ], + }, + { + "type": "score", + "name": "anger", + "score": 1, + "confidence": 1, + "probabilities": [ + {"value": 0, "label": "calm", "probability": 0}, + {"value": 1, "label": "furious", "probability": 1}, + ], + }, + ], + "usage": {"input_tokens": 386, "output_tokens": 0, "total_tokens": 386}, +} + + +@pytest.fixture(autouse=True) +def isolated_cache(monkeypatch, tmp_path): + monkeypatch.setattr(cache_mod, "CACHE_DIR", tmp_path / "cache") + monkeypatch.setattr(cache_mod, "DATA_DIR", tmp_path / "data") + monkeypatch.setattr(cache_mod, "COST_LOG_PATH", tmp_path / "cost_log.jsonl") + return tmp_path + + +# ── decisions() ─────────────────────────────────────────────────────────── + + +class TestBuildDecisionsBody: + def test_defaults_the_model_and_forwards_the_rest(self): + body = build_decisions_body("text", QUESTIONS, metadata={"ticket": "42"}) + assert body == { + "model": DECISIONS_DEFAULT_MODEL, + "input": "text", + "questions": QUESTIONS, + "metadata": {"ticket": "42"}, + } + + def test_keeps_a_callers_model(self): + assert build_decisions_body("t", QUESTIONS, model="openai/gpt-6-luna")["model"] == ( + "openai/gpt-6-luna" + ) + + @pytest.mark.parametrize( + "input_,questions,match", + [ + ("", QUESTIONS, "input"), + ([], QUESTIONS, "input"), + ("t", [], "questions"), + ("t", [{"type": "rank", "name": "a", "instructions": "x"}], "type"), + ("t", [{"type": "predicate", "name": "", "instructions": "x"}], "name"), + ("t", [{"type": "predicate", "name": "a", "instructions": ""}], "instructions"), + ("t", [QUESTIONS[0], QUESTIONS[0]], "twice"), + ("t", [{"type": "choice", "name": "a", "instructions": "x", "choices": []}], "choices"), + ("t", [{"type": "score", "name": "a", "instructions": "x"}], "levels"), + ], + ) + def test_refuses_a_malformed_request(self, input_: Any, questions: Any, match: str): + with pytest.raises(ValueError, match=match): + build_decisions_body(input_, questions) + + +def _wallet_gateway(seen: list[httpx.Request], answer: dict[str, Any] = ANSWER): + def handler(request: httpx.Request) -> httpx.Response: + seen.append(request) + if request.headers.get("PAYMENT-SIGNATURE") is None: + return httpx.Response( + 402, + headers={"payment-required": build_payment_required_response(amount="1069")}, + json={"error": "Payment Required"}, + ) + return httpx.Response(200, json=answer) + + return handler + + +def test_llmclient_decisions_pays_the_quote_and_returns_typed_answers(): + seen: list[httpx.Request] = [] + client = LLMClient(private_key=TEST_PRIVATE_KEY) + client._client = httpx.Client(transport=httpx.MockTransport(_wallet_gateway(seen))) + + result = client.decisions("My card was charged twice.", QUESTIONS) + + assert isinstance(result, DecisionsResponse) + assert result.answers == ANSWER["answers"] + assert result.usage and result.usage["output_tokens"] == 0 + assert [str(r.url) for r in seen] == ["https://blockrun.ai/api/v1/decisions"] * 2 + sent = json.loads(seen[0].content) + assert sent["model"] == "gpt-6-luna" and sent["questions"] == QUESTIONS + assert json.loads(seen[1].content) == sent + assert client.get_spending()["calls"] == 1 + + +def test_decisions_is_never_served_from_cache(): + seen: list[httpx.Request] = [] + client = LLMClient(private_key=TEST_PRIVATE_KEY) + client._client = httpx.Client(transport=httpx.MockTransport(_wallet_gateway(seen))) + + client.decisions("same", QUESTIONS) + client.decisions("same", QUESTIONS) + + assert len([r for r in seen if r.headers.get("PAYMENT-SIGNATURE")]) == 2 + + +def test_decisions_sends_nothing_for_a_malformed_request(): + seen: list[httpx.Request] = [] + client = LLMClient(private_key=TEST_PRIVATE_KEY) + client._client = httpx.Client(transport=httpx.MockTransport(_wallet_gateway(seen))) + with pytest.raises(ValueError, match="questions"): + client.decisions("text", []) + assert seen == [] + + +# ── search guard ────────────────────────────────────────────────────────── + + +class TestRequestsSearch: + @pytest.mark.parametrize( + "kwargs,expected", + [ + ({}, False), + ({"search": True}, True), + ({"search": False}, False), + ({"search_parameters": {"mode": "on"}}, True), + ({"search_parameters": {"mode": "off"}}, False), + ({"search": True, "search_parameters": {"mode": "off"}}, False), + ({"tools": [{"type": "x_search"}]}, True), + ({"tools": [{"type": "web_search"}]}, True), + ({"tools": [{"type": "function", "function": {"name": "f"}}]}, False), + ], + ) + def test_detection(self, kwargs: dict[str, Any], expected: bool): + assert requests_search(**kwargs) is expected + + def test_require_search_model_refuses_a_non_xai_model(self): + with pytest.raises(ValueError, match="openai/gpt-5.2"): + require_search_model(["openai/gpt-5.2"], True) + require_search_model(["xai/grok-4.7"], True) + require_search_model(["openai/gpt-5.2"], None, {"mode": "off"}) + + +@pytest.mark.parametrize("model", ["openai/gpt-5.2", "anthropic/claude-sonnet-5"]) +def test_chat_completion_refuses_search_on_a_non_xai_model_before_sending(model: str): + seen: list[httpx.Request] = [] + client = LLMClient(private_key=TEST_PRIVATE_KEY) + client._client = httpx.Client(transport=httpx.MockTransport(_wallet_gateway(seen))) + with pytest.raises(ValueError, match="xai/"): + client.chat_completion(model, [{"role": "user", "content": "news?"}], search=True) + assert seen == [] + + +def test_chat_completion_refuses_a_non_xai_fallback_with_search(): + client = LLMClient(private_key=TEST_PRIVATE_KEY) + with pytest.raises(ValueError, match="openai/gpt-5.2"): + client.chat_completion( + "xai/grok-4.7", + [{"role": "user", "content": "news?"}], + search=True, + fallback_models=["openai/gpt-5.2"], + ) + + +# The catalog rows the search fallback reads (categories matter). +SEARCH_CATALOG = [ + { + "id": "google/gemini-2.5-flash", + "categories": ["chat"], + "pricing": {"input": 0.15, "output": 0.6}, + }, + { + "id": "google/gemini-3.1-pro", + "categories": ["chat"], + "pricing": {"input": 1.25, "output": 10}, + }, + { + "id": "anthropic/claude-opus-4.7", + "categories": ["chat"], + "pricing": {"input": 5, "output": 25}, + }, + { + "id": "deepseek/deepseek-reasoner", + "categories": ["chat"], + "pricing": {"input": 0.28, "output": 0.42}, + }, + {"id": "xai/grok-4.7", "categories": ["chat", "search"], "pricing": {"input": 3, "output": 15}}, + { + "id": "xai/grok-4.5", + "categories": ["chat", "search"], + "pricing": {"input": 0.2, "output": 0.5}, + }, + { + "id": "xai/grok-build-0.1", + "categories": ["chat", "coding"], + "pricing": {"input": 0.2, "output": 1}, + }, + { + "id": "xai/grok-old", + "categories": ["chat", "search"], + "available": False, + "pricing": {"input": 0.1, "output": 0.1}, + }, +] + + +class TestSearchRouting: + def test_pricing_records_the_catalogs_search_models(self): + pricing = build_model_pricing(SEARCH_CATALOG) + # Tagged, available xai/* chat models only. + assert sorted(pricing.search_models) == ["xai/grok-4.5", "xai/grok-4.7"] # type: ignore[attr-defined] + + def test_without_search_nothing_changes(self): + pricing = build_model_pricing(SEARCH_CATALOG) + decision = route_with_catalog("What is the capital of France?", None, 256, pricing) + assert not decision["model"].startswith("xai/") + + @pytest.mark.parametrize("profile", ["eco", "auto"]) + def test_routes_to_the_cheapest_search_model(self, profile: str): + pricing = build_model_pricing(SEARCH_CATALOG) + decision = route_with_catalog( + "Latest AI news?", None, 256, pricing, routing_profile=profile, search=True + ) + assert decision["model"] == "xai/grok-4.5" + assert decision["candidates"] == ["xai/grok-4.5", "xai/grok-4.7"] + assert decision["fallbacks"] == ["xai/grok-4.7"] + assert "search runs on xai/* only" in decision["reasoning"] + + def test_premium_routes_to_the_most_capable_search_model(self): + pricing = build_model_pricing(SEARCH_CATALOG) + decision = route_with_catalog( + "Latest AI news?", None, 256, pricing, routing_profile="premium", search=True + ) + assert decision["model"] == "xai/grok-4.7" + + def test_free_profile_with_search_is_refused(self): + pricing = build_model_pricing(SEARCH_CATALOG) + with pytest.raises(ValueError, match="free profile"): + route_with_catalog("news?", None, 256, pricing, routing_profile="free", search=True) + + def test_a_catalog_without_xai_is_refused(self): + pricing = build_model_pricing([r for r in SEARCH_CATALOG if not r["id"].startswith("xai/")]) + with pytest.raises(ValueError, match="no available xai"): + route_with_catalog("news?", None, 256, pricing, search=True) + + def test_smart_chat_completion_with_search_calls_an_xai_model(self): + seen: list[httpx.Request] = [] + chat_ok = { + "id": "c", + "object": "chat.completion", + "created": 0, + "model": "xai/grok-4.5", + "choices": [ + { + "index": 0, + "message": {"role": "assistant", "content": "ok"}, + "finish_reason": "stop", + } + ], + } + client = LLMClient(private_key=TEST_PRIVATE_KEY) + client._client = httpx.Client(transport=httpx.MockTransport(_wallet_gateway(seen, chat_ok))) + client._model_pricing_cache = build_model_pricing(SEARCH_CATALOG) + + result = client.smart_chat_completion( + [{"role": "user", "content": "Latest AI news?"}], search=True + ) + + assert result.model == "xai/grok-4.5" + assert json.loads(seen[0].content)["model"] == "xai/grok-4.5" From 5e9e9e6a9437a78771bfe3d7bb5062b11ef8caff Mon Sep 17 00:00:00 2001 From: 1bcMax Date: Sun, 15 Nov 2026 19:03:09 +0000 Subject: [PATCH 2/2] test: sort imports --- tests/unit/test_decisions_and_search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test_decisions_and_search.py b/tests/unit/test_decisions_and_search.py index 9853948..f8e1119 100644 --- a/tests/unit/test_decisions_and_search.py +++ b/tests/unit/test_decisions_and_search.py @@ -19,8 +19,8 @@ from blockrun_llm.decisions import build_decisions_body from blockrun_llm.router_adapter import ( build_model_pricing, - require_search_model, requests_search, + require_search_model, route_with_catalog, )