Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion shared/uids.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,6 @@ def get_uids(
return get_random_uids(k=k, exclude=exclude or [])
if sampling_mode == "top_incentive":
vpermit_tao_limit = shared_settings.NEURON_VPERMIT_TAO_LIMIT
return get_top_incentive_uids(k=k, vpermit_tao_limit=vpermit_tao_limit, own_uid=own_uid)
return get_top_incentive_uids(k=k, vpermit_tao_limit=vpermit_tao_limit)
if sampling_mode == "all":
return [int(uid) for uid in shared_settings.METAGRAPH.uids if (uid != own_uid and check_uid_availability(uid))]
9 changes: 4 additions & 5 deletions validator_api/gpt_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from shared.epistula import make_openai_query
from shared.settings import shared_settings
from shared.uids import get_uids

router = APIRouter()

Expand All @@ -18,10 +19,9 @@ async def forward_response(uid: int, body: dict[str, any], chunks: list[str]):
return

# if body.get("task") != "InferenceTask":
# logger.info(f"Skipping forwarding for non-inference task: {body.get('task')}")
# logger.debug(f"Skipping forwarding for non-inference task: {body.get('task')}")
# return
url = f"http://{shared_settings.VALIDATOR_API}/scoring"
logger.info(url)
payload = {"body": body, "chunks": chunks, "uid": uid}
# headers = {
# "Authorization": f"Bearer {shared_settings.SCORING_KEY}", #Add API key in Authorization header
Expand All @@ -30,7 +30,6 @@ async def forward_response(uid: int, body: dict[str, any], chunks: list[str]):
try:
timeout = httpx.Timeout(timeout=120.0, connect=60.0, read=30.0, write=30.0, pool=5.0)
async with httpx.AsyncClient(timeout=timeout) as client:
logger.debug(f"Payload: {payload}")
response = await client.post(url, json=payload) # , headers=headers)
if response.status_code == 200:
logger.info(f"Forwarding response completed with status {response.status_code}")
Expand All @@ -52,7 +51,8 @@ async def chat_completion(request: Request): # , cbackground_tasks: BackgroundT
body["seed"] = int(body.get("seed") or random.randint(0, 1000000))
STREAM = body.get("stream") or False
logger.debug(f"Streaming: {STREAM}")
uid = random.randint(0, len(shared_settings.METAGRAPH.axons) - 1)
# Get random miner from top 100 incentive.
uid = random.choice(get_uids(sampling_mode="top_incentive", k=100))
# uid = get_available_miner(task=body.get("task"), model=body.get("model"))
if uid is None:
logger.error("No available miner found")
Expand All @@ -67,7 +67,6 @@ async def stream_with_error_handling():
try:
async for chunk in response:
chunks_received = True
logger.debug(chunk.choices[0].delta.content)
collected_chunks.append(chunk.choices[0].delta.content)
yield f"data: {json.dumps(chunk.model_dump())}\n\n"

Expand Down
2 changes: 1 addition & 1 deletion validator_api/miner_availabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class MinerAvailabilitiesUpdater(AsyncLoopRunner):

async def run_step(self):
uids = get_uids(sampling_mode="random", k=100)
url = f"http://{shared_settings.VALIDATOR_IP}:{shared_settings.VALIDATOR_PORT}/miner_availabilities/miner_availabilities"
url = f"{shared_settings.VALIDATOR_API}/miner_availabilities/miner_availabilities"

try:
result = requests.post(url, json=uids.tolist(), timeout=10)
Expand Down
Loading