diff --git a/validators/text_validator.py b/validators/text_validator.py index 24b34cca..7486340e 100644 --- a/validators/text_validator.py +++ b/validators/text_validator.py @@ -69,9 +69,9 @@ async def organic_scoring(self, metagraph, available_uids, messages): prompt = message_list[-1]['content'] uid_to_question[uid] = prompt message = message_list - syn = StreamPrompting(messages=message, model=self.model, seed=self.seed) + syn = StreamPrompting(messages=message_list, model=self.model, seed=self.seed, max_tokens=4048, temperature=self.temperature, provider=self.provider, top_p=self.top_p, top_k=self.top_k) bt.logging.info(f"Sending {syn.model} {self.query_type} request to uid: {uid}, timeout {self.timeout}: {message[0]['content']}") - task = self.query_miner(metagraph.axons[uid], uid, syn) + task = self.query_miner(metagraph, uid, syn) query_tasks.append(task) self.wandb_data["prompts"][uid] = prompt diff --git a/validators/validator.py b/validators/validator.py index 36ad35dd..3bb2ed20 100644 --- a/validators/validator.py +++ b/validators/validator.py @@ -38,8 +38,6 @@ organic_scoring_tasks = set() EXPECTED_ACCESS_KEY = os.environ.get('EXPECTED_ACCESS_KEY', "hello") -VALIDATOR_ACCESS_KEY = os.environ.get('VALIDATOR_ACCESS_KEY') - def get_config() -> bt.config: parser = argparse.ArgumentParser() @@ -150,29 +148,27 @@ async def process_text_validator(request: web.Request): return response - -async def organic_scoring(request: web.Request, data: dict): - # Check access key - access_key = request.headers.get("access-key") - if access_key != VALIDATOR_ACCESS_KEY: - raise HTTPException(status_code=401, detail="Invalid access key") - messages = data.get('messages') - config = get_config() - wallet = bt.wallet(config=config) - dendrite = bt.dendrite(wallet=wallet) - available_uids = await get_available_uids(dendrite, metagraph) - responses = await text_vali.organic_scoring(metagraph, available_uids, messages) - - return responses - class ValidatorApplication(web.Application): def __init__(self, *a, **kw): super().__init__(*a, **kw) self.weight_setter: WeightSetter | None = None +async def organic_scoring(request: web.Request): + # Check access key + # access_key = request.headers.get("access-key") + # if access_key != EXPECTED_ACCESS_KEY: + # raise web.Response(status_code=401, detail="Invalid access key") + body = await request.json() + messages = body['messages'] + available_uids = await validator_app.weight_setter.get_available_uids() + + responses = await text_vali.organic_scoring(metagraph, available_uids, messages) + + return web.json_response(responses) validator_app = ValidatorApplication() validator_app.add_routes([web.post('/text-validator/', process_text_validator)]) +validator_app.add_routes([web.post('/scoring/', organic_scoring)]) def main(run_aio_app=True, test=False) -> None: