From e38f7b7acc59534def159ef2622ba662005aca5e Mon Sep 17 00:00:00 2001 From: DevDendrite Date: Fri, 17 Oct 2025 14:30:02 +0200 Subject: [PATCH 1/2] fetch a question from BitQuant API --- quant/utils/questions.py | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/quant/utils/questions.py b/quant/utils/questions.py index 6de3903..69e25f7 100644 --- a/quant/utils/questions.py +++ b/quant/utils/questions.py @@ -1,3 +1,8 @@ +import bittensor as bt +import requests +import random + + """ List of questions that can be answered by the crypto analysis document. """ @@ -50,4 +55,36 @@ "What are the top 3 safest memecoins to buy on Sui?", "What are the top 3 safest memecoins to buy on Base?", "What are the top 3 safest memecoins to buy on Ethereum?", -] \ No newline at end of file +] + + +def fetch_question_once( + api_url: str = "https://quant-api.opengradient.ai/api/subnet/question", + timeout: float = 60.0, +) -> str: + response_obj = requests.get( + api_url, + timeout=timeout + ) + + response_obj.raise_for_status() + question_result = response_obj.json() + return question_result["question"] + + +def fetch_question( + api_url: str = "https://quant-api.opengradient.ai/api/subnet/question", + timeout: float = 60.0, + retry_count: int = 3, +) -> str: + for i in range(retry_count + 1): + try: + question = fetch_question_once(api_url, timeout=timeout) + bt.logging.info(f"Fetched question: '{question}'") + return question + except Exception as ex: + bt.logging.warning(f"Question fetch failed during try no. {i + 1} on: {ex}") + + question = random.choice(questions) + bt.logging.warning(f"Fetching question failed too many times; returning one of the default questions: '{question}'") + return question From 59a66206b7aee12b15646664f6c8a83bd6e1c0a9 Mon Sep 17 00:00:00 2001 From: DevDendrite Date: Fri, 17 Oct 2025 14:31:28 +0200 Subject: [PATCH 2/2] make validator fetch questions from centralized API --- quant/validator/forward.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/quant/validator/forward.py b/quant/validator/forward.py index 9421a4f..8c48553 100644 --- a/quant/validator/forward.py +++ b/quant/validator/forward.py @@ -17,13 +17,12 @@ import os import time -import random import bittensor as bt from quant.protocol import QuantQuery, QuantSynapse from quant.validator.reward import get_rewards from quant.utils.uids import get_random_uids -from quant.utils.questions import questions +from quant.utils.questions import fetch_question async def forward(self): @@ -46,7 +45,7 @@ async def forward(self): wallet_address = "5HHSqMvTCvgtzdqFb5BbtYjB8cEiJjf8UZ6p5rQczagL" query = QuantQuery( - query=random.choice(questions), + query=fetch_question(), userID=wallet_address, metadata={ "Create_Proof": "True",