Skip to content

Commit

Permalink
fix organic scoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Chkhikvadze committed Feb 3, 2024
1 parent 8554e4a commit 99d9a23
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
4 changes: 2 additions & 2 deletions validators/text_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
30 changes: 13 additions & 17 deletions validators/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 99d9a23

Please sign in to comment.