From 344ca8cbe4b5cca8388fa5d90428f3c66b78880d Mon Sep 17 00:00:00 2001 From: richwardle Date: Fri, 6 Jun 2025 10:29:32 +0000 Subject: [PATCH 1/3] Depreciate Target Uids --- validator_api/gpt_endpoints.py | 38 ++++++++++++++-------------------- validator_api/serializers.py | 9 +++++--- validator_api/web_retrieval.py | 21 +++++++------------ 3 files changed, 28 insertions(+), 40 deletions(-) diff --git a/validator_api/gpt_endpoints.py b/validator_api/gpt_endpoints.py index 8e129a75b..b92fd6e4b 100644 --- a/validator_api/gpt_endpoints.py +++ b/validator_api/gpt_endpoints.py @@ -78,20 +78,15 @@ async def completions(request: CompletionsRequest, api_key: str = Depends(valida # By setting default, we are allowing a user to use whatever model we define as the standard, could also set to None. body["model"] = "mrfakename/mistral-small-3.1-24b-instruct-2503-hf" body["seed"] = int(body.get("seed") or random.randint(0, 1000000)) - if body.get("uids"): - try: - uids = list(map(int, body.get("uids"))) - except Exception: - logger.error(f"Error in uids: {body.get('uids')}") - else: - uids = filter_available_uids( - task=body.get("task"), - model=body.get("model"), - test=shared_settings.API_TEST_MODE, - n_miners=shared_settings.API_TOP_MINERS_TO_STREAM, - n_top_incentive=shared_settings.API_TOP_MINERS_SAMPLE, - explore=shared_settings.API_UIDS_EXPLORE, - ) + + uids = filter_available_uids( + task=body.get("task"), + model=body.get("model"), + test=shared_settings.API_TEST_MODE, + n_miners=shared_settings.API_TOP_MINERS_TO_STREAM, + n_top_incentive=shared_settings.API_TOP_MINERS_SAMPLE, + explore=shared_settings.API_UIDS_EXPLORE, + ) if not uids: raise HTTPException(status_code=500, detail="No available miners") @@ -217,16 +212,13 @@ async def submit_chain_of_thought_job( body["seed"] = int(body.get("seed") or random.randint(0, 1000000)) - uids = ( - [int(uid) for uid in body.get("uids")] - if body.get("uids") - else filter_available_uids( - task=body.get("task"), - model=body.get("model"), - test=shared_settings.API_TEST_MODE, - n_miners=shared_settings.API_TOP_MINERS_TO_STREAM, - ) + uids = filter_available_uids( + task=body.get("task"), + model=body.get("model"), + test=shared_settings.API_TEST_MODE, + n_miners=shared_settings.API_TOP_MINERS_TO_STREAM, ) + uids = [uid.map(int) for uid in uids] if not uids: raise HTTPException(status_code=500, detail="No available miners") diff --git a/validator_api/serializers.py b/validator_api/serializers.py index 363a345b4..008d9970f 100644 --- a/validator_api/serializers.py +++ b/validator_api/serializers.py @@ -20,8 +20,9 @@ def add_tools(self): uids: Optional[List[int]] = Field( default=None, - description="List of specific miner UIDs to query. If not provided, miners will be selected automatically.", + description="[DEPRECATED] This field will be removed in a future version. List of specific miner UIDs to query. If not provided, miners will be selected automatically. Please consider alternative mechanisms for miner selection if available.", example=[1, 2, 3], + deprecated=True, ) messages: List[Dict[str, str]] = Field( ..., @@ -98,8 +99,9 @@ class WebRetrievalRequest(BaseModel): uids: Optional[List[int]] = Field( default=None, - description="List of specific miner UIDs to query. If not provided, miners will be selected automatically.", + description="[DEPRECATED] This field will be removed in a future version. List of specific miner UIDs to query. If not provided, miners will be selected automatically. Please consider alternative mechanisms for miner selection if available.", example=[1, 2, 3], + deprecated=True, ) search_query: str = Field( ..., description="The query to search for on the web.", example="latest advancements in quantum computing" @@ -143,8 +145,9 @@ class TestTimeInferenceRequest(BaseModel): uids: Optional[List[int]] = Field( default=None, - description="List of specific miner UIDs to query. If not provided, miners will be selected automatically.", + description="[DEPRECATED] This field will be removed in a future version. List of specific miner UIDs to query. If not provided, miners will be selected automatically. Please consider alternative mechanisms for miner selection if available.", example=[1, 2, 3], + deprecated=True, ) messages: List[Dict[str, str]] = Field( ..., diff --git a/validator_api/web_retrieval.py b/validator_api/web_retrieval.py index 845406332..71df75bf5 100644 --- a/validator_api/web_retrieval.py +++ b/validator_api/web_retrieval.py @@ -43,20 +43,13 @@ async def web_retrieval( # noqa: C901 ): """Launch *all* requested miners in parallel, return immediately when the first miner delivers a valid result.""" # Choose miners. - if request.uids: - try: - uids: list[int] = list(map(int, request.uids)) - except Exception: - logger.error(f"Invalid uids supplied: {request.uids}") - raise HTTPException(status_code=500, detail="Invalid miner uids") - else: - available = filter_available_uids( - task="WebRetrievalTask", - test=shared_settings.API_TEST_MODE, - n_miners=request.n_miners, - explore=shared_settings.API_UIDS_EXPLORE, - ) - uids = random.sample(available, min(len(available), request.n_miners)) + available = filter_available_uids( + task="WebRetrievalTask", + test=shared_settings.API_TEST_MODE, + n_miners=request.n_miners, + explore=shared_settings.API_UIDS_EXPLORE, + ) + uids = random.sample(available, min(len(available), request.n_miners)) if not uids: raise HTTPException(status_code=500, detail="No available miners") From 295634f3bb724266244b24243d5611bda5e28ea5 Mon Sep 17 00:00:00 2001 From: richwardle Date: Tue, 10 Jun 2025 11:15:58 +0000 Subject: [PATCH 2/3] Deprecation In Docs --- docs/API_docs.md | 8 ++++---- validator_api/gpt_endpoints.py | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/API_docs.md b/docs/API_docs.md index d9ed68180..8ff299d9b 100644 --- a/docs/API_docs.md +++ b/docs/API_docs.md @@ -87,11 +87,11 @@ bash run_api.sh **Endpoint:** `POST /miner_availabilities/miner_availabilities` -**Description:** Fetches miner availabilities based on provided UIDs. +**Description:** Fetches miner availabilities based on provided UIDs. **Note: Specifying UIDs is deprecated.** **Request Body:** -- JSON array of integers or null (optional). +- JSON array of integers or null (optional, deprecated). --- @@ -169,13 +169,13 @@ Web Retrieval **Endpoint:** `GET /web_retrieval` -**Description:** Retrieves a list websites about a search query +**Description:** Retrieves a list websites about a search query. **Note: The `uids` parameter is deprecated.** **Parameters:** - **search_query** (str): The search term you'd like to look up - **n_miners** (int, optional): How many miners to query -- **uids**: (list[int], optional): which specific uids to query (Deprecated) +- **uids**: (list[int], optional, deprecated): which specific uids to query --- diff --git a/validator_api/gpt_endpoints.py b/validator_api/gpt_endpoints.py index 0f5afbc7d..a6055c4b3 100644 --- a/validator_api/gpt_endpoints.py +++ b/validator_api/gpt_endpoints.py @@ -48,7 +48,7 @@ async def completions(request: CompletionsRequest, api_key: str = Depends(valida - Mixture of miners ## Request Parameters: - - **uids** (List[int], optional): Specific miner UIDs to query. If not provided, miners will be selected automatically. + - **uids** (List[int], optional, deprecated): Specific miner UIDs to query. If not provided, miners will be selected automatically. **Note: This parameter is deprecated and will be removed in a future version.** - **messages** (List[dict]): List of message objects with 'role' and 'content' keys. Required. - **seed** (int, optional): Random seed for reproducible results. - **task** (str, optional): Task identifier to filter available miners. @@ -81,7 +81,7 @@ async def completions(request: CompletionsRequest, api_key: str = Depends(valida # By setting default, we are allowing a user to use whatever model we define as the standard, could also set to None. body["model"] = "mrfakename/mistral-small-3.1-24b-instruct-2503-hf" body["seed"] = int(body.get("seed") or random.randint(0, 1000000)) - + uids = filter_available_uids( task=body.get("task"), model=body.get("model"), @@ -90,7 +90,7 @@ async def completions(request: CompletionsRequest, api_key: str = Depends(valida n_top_incentive=shared_settings.API_TOP_UIDS_SAMPLE, explore=shared_settings.API_UIDS_EXPLORE, ) - + if not uids: raise HTTPException(status_code=500, detail="No available miners") @@ -123,7 +123,7 @@ async def test_time_inference(request: TestTimeInferenceRequest): ## Request Parameters: - **messages** (List[dict]): List of message objects with 'role' and 'content' keys. Required. - **model** (str, optional): Optional model identifier to use for inference. - - **uids** (List[int], optional): Optional list of specific miner UIDs to query. + - **uids** (List[int], optional, deprecated): Optional list of specific miner UIDs to query. **Note: This parameter is deprecated and will be removed in a future version.** ## Response: The response is streamed as server-sent events (SSE) with each step of reasoning. @@ -183,7 +183,7 @@ async def submit_chain_of_thought_job( /v1/chat/completions/jobs/{job_id} endpoint. ## Request Parameters: - - **uids** (List[int], optional): Specific miner UIDs to query. If not provided, miners will be selected automatically. + - **uids** (List[int], optional, deprecated): Specific miner UIDs to query. If not provided, miners will be selected automatically. **Note: This parameter is deprecated and will be removed in a future version.** - **messages** (List[dict]): List of message objects with 'role' and 'content' keys. Required. - **model** (str, optional): Model identifier to filter available miners. From 6ed2299b89fb90c250943255e86f832b9cc44820 Mon Sep 17 00:00:00 2001 From: richwardle Date: Tue, 10 Jun 2025 11:39:08 +0000 Subject: [PATCH 3/3] Precommit --- validator_api/web_retrieval.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validator_api/web_retrieval.py b/validator_api/web_retrieval.py index 073e559f9..8049e5fe8 100644 --- a/validator_api/web_retrieval.py +++ b/validator_api/web_retrieval.py @@ -43,7 +43,7 @@ async def web_retrieval( # noqa: C901 api_key: str = Depends(validate_api_key), ): """Launch *all* requested miners in parallel, return immediately when the first miner delivers a valid result.""" - + # Requesting UIDs is deprecated. uids: np.ndarray = get_uids(sampling_mode="random", k=shared_settings.API_EXTRA_UIDS_QUERY)