DIV-45 commited on
Commit
dcc0e81
·
verified ·
1 Parent(s): 0745894

fix: validate Nemotron companion responses

Browse files
Files changed (1) hide show
  1. src/packetcourt/remote_nemotron.py +8 -1
src/packetcourt/remote_nemotron.py CHANGED
@@ -24,4 +24,11 @@ def _client():
24
 
25
  def review(snapshot: dict) -> dict:
26
  result = _client().predict(json.dumps(snapshot), api_name="/predict")
27
- return json.loads(result)
 
 
 
 
 
 
 
 
24
 
25
  def review(snapshot: dict) -> dict:
26
  result = _client().predict(json.dumps(snapshot), api_name="/predict")
27
+ if isinstance(result, dict):
28
+ return result
29
+ if not isinstance(result, str):
30
+ raise TypeError(f"Unexpected Nemotron response type: {type(result).__name__}")
31
+ payload = json.loads(result)
32
+ if not isinstance(payload, dict):
33
+ raise TypeError(f"Unexpected Nemotron JSON type: {type(payload).__name__}")
34
+ return payload