Skip to content

Commit 5f88168

Browse files
author
acer-king
committed
validating capacity before being used
1 parent 51780d2 commit 5f88168

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

validators/services/capacity.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,25 @@ async def query_capacity_to_miners(self, available_uids):
3232
if isinstance(resp, Exception):
3333
bt.logging.error(f"exception happens while querying capacity to miner {uid}, {resp}")
3434
else:
35-
uid_to_capacity[uid] = resp.bandwidth_rpm
35+
uid_to_capacity[uid] = self.validate_capacity(resp.bandwidth_rpm)
3636
self.uid_to_capacity = deepcopy(uid_to_capacity)
3737
return uid_to_capacity
38+
39+
def validate_capacity(self, bandwidth):
40+
try:
41+
open_ai_cap = bandwidth.get("OpenAI").get("gpt-4o")
42+
anthropic_cap = bandwidth.get("Anthropic").get("claude-3-5-sonnet-20240620")
43+
groq_cap = bandwidth.get("Groq").get("llama-3.1-70b-versatile")
44+
return {
45+
"OpenAI": {
46+
"gpt-4o": int(open_ai_cap)
47+
},
48+
"Anthropic": {
49+
"claude-3-5-sonnet-20240620": int(anthropic_cap)
50+
},
51+
"Groq": {
52+
"llama-3.1-70b-versatile": int(groq_cap)
53+
}
54+
}
55+
except Exception as err:
56+
return None

0 commit comments

Comments
 (0)