feat: add fraud detection validator
This commit is contained in:
@@ -147,10 +147,10 @@ class _GatewayHandler(http.server.BaseHTTPRequestHandler):
|
||||
|
||||
text = node_resp["text"]
|
||||
model = body.get("model", "stub-model")
|
||||
session_id = str(uuid.uuid4())
|
||||
if server.contracts is not None and route_nodes:
|
||||
api_key = _api_key_from_authorization(self.headers.get("Authorization"))
|
||||
if api_key:
|
||||
session_id = str(uuid.uuid4())
|
||||
tokens = max(1, _estimate_token_count(messages, text))
|
||||
for node in route_nodes:
|
||||
wallet_address = node.get("wallet_address")
|
||||
@@ -165,6 +165,14 @@ class _GatewayHandler(http.server.BaseHTTPRequestHandler):
|
||||
tokens=tokens,
|
||||
speed_score=float(node.get("score", 1.0)),
|
||||
)
|
||||
if server.contracts is not None:
|
||||
server.contracts.validation.record_completed_inference(
|
||||
session_id=session_id,
|
||||
model=model,
|
||||
messages=messages if isinstance(messages, list) else [],
|
||||
observed_output=text,
|
||||
route_nodes=route_nodes,
|
||||
)
|
||||
|
||||
if streaming:
|
||||
self._send_sse_response(text, model)
|
||||
|
||||
Reference in New Issue
Block a user