Spaces:
Sleeping
Sleeping
fix: validate Nemotron companion responses
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|