macore-client-dev 0.1.90__tar.gz → 0.1.92__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {macore_client_dev-0.1.90 → macore_client_dev-0.1.92}/PKG-INFO +1 -1
- {macore_client_dev-0.1.90 → macore_client_dev-0.1.92}/macore_client/__about__.py +1 -1
- {macore_client_dev-0.1.90 → macore_client_dev-0.1.92}/macore_client/__init__.py +2 -1
- {macore_client_dev-0.1.90 → macore_client_dev-0.1.92}/macore_client/client.py +62 -0
- macore_client_dev-0.1.92/macore_client/decision.py +270 -0
- {macore_client_dev-0.1.90 → macore_client_dev-0.1.92}/.gitignore +0 -0
- {macore_client_dev-0.1.90 → macore_client_dev-0.1.92}/macore_client/cli.py +0 -0
- {macore_client_dev-0.1.90 → macore_client_dev-0.1.92}/macore_client/live_check.py +0 -0
- {macore_client_dev-0.1.90 → macore_client_dev-0.1.92}/pyproject.toml +0 -0
|
@@ -5,5 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
from macore_client.client import MacClient
|
|
7
7
|
from macore_client.__about__ import __version__
|
|
8
|
+
from macore_client.decision import DecisionResult, DecisionAuditReceipt, ThresholdResult, NoulAnswer, ChoiceAnswer, ScoreAnswer
|
|
8
9
|
|
|
9
|
-
__all__ = ["MacClient", "__version__"]
|
|
10
|
+
__all__ = ["MacClient", "__version__", "DecisionResult", "DecisionAuditReceipt", "ThresholdResult", "NoulAnswer", "ChoiceAnswer", "ScoreAnswer"]
|
|
@@ -16,6 +16,12 @@ import contextlib
|
|
|
16
16
|
import sys
|
|
17
17
|
from typing import Any
|
|
18
18
|
from urllib.parse import urlparse
|
|
19
|
+
from dataclasses import asdict
|
|
20
|
+
import uuid
|
|
21
|
+
from macore_client.decision import (
|
|
22
|
+
DecisionResult, DecisionAuditReceipt, ThresholdResult, finite,
|
|
23
|
+
selected_probability, validate_decision_request, DecisionRemoteError, answer_from_dict,
|
|
24
|
+
)
|
|
19
25
|
|
|
20
26
|
|
|
21
27
|
def _import_jsonrpc_client() -> Any:
|
|
@@ -44,6 +50,8 @@ COMMANDS: tuple[str, ...] = (
|
|
|
44
50
|
"model_session_get",
|
|
45
51
|
"model_session_delete",
|
|
46
52
|
"model_chat",
|
|
53
|
+
"model_decide",
|
|
54
|
+
"model_decision_record",
|
|
47
55
|
"model_count_tokens",
|
|
48
56
|
"model_estimate_request_capacity",
|
|
49
57
|
"model_request_status",
|
|
@@ -138,6 +146,58 @@ class MacClient:
|
|
|
138
146
|
if close is not None:
|
|
139
147
|
await close()
|
|
140
148
|
|
|
149
|
+
async def model_decide(self, *, provider_id: str, model_id: str, state: Any,
|
|
150
|
+
questions: dict[str, Any], definition_id: str,
|
|
151
|
+
provider_key_id: str = "noauth:default") -> DecisionResult:
|
|
152
|
+
"""One pinned native decision; any transport/remote/protocol failure raises."""
|
|
153
|
+
params = validate_decision_request(dict(provider_id=provider_id, model_id=model_id,
|
|
154
|
+
state=state, questions=questions, definition_id=definition_id, provider_key_id=provider_key_id))
|
|
155
|
+
result = await self.call("model_decide", params)
|
|
156
|
+
if not isinstance(result, dict) or result.get("success") is not True:
|
|
157
|
+
raise DecisionRemoteError(result if isinstance(result, dict) else {})
|
|
158
|
+
decision = DecisionResult.from_dict(result["data"])
|
|
159
|
+
if decision.provider_id != provider_id or decision.requested_model_id != model_id or list(decision.answers) != list(questions):
|
|
160
|
+
raise ValueError("model_decide response correlation differs")
|
|
161
|
+
for question_id, answer in decision.answers.items():
|
|
162
|
+
answer_from_dict(asdict(answer), questions[question_id])
|
|
163
|
+
return decision
|
|
164
|
+
|
|
165
|
+
async def model_decision_record(self, *, decision_audit_id: str, question_id: str,
|
|
166
|
+
target: str | bool | int, selected_probability: float,
|
|
167
|
+
threshold: float, outcome: str, audit_id: str) -> DecisionAuditReceipt:
|
|
168
|
+
"""Persist audit-only threshold evaluation; never performs inference."""
|
|
169
|
+
result = await self.call("model_decision_record", dict(decision_audit_id=decision_audit_id,
|
|
170
|
+
question_id=question_id, target=target, selected_probability=selected_probability,
|
|
171
|
+
threshold=threshold, outcome=outcome, audit_id=audit_id))
|
|
172
|
+
if not isinstance(result, dict) or result.get("success") is not True:
|
|
173
|
+
raise DecisionRemoteError(result if isinstance(result, dict) else {})
|
|
174
|
+
data = result["data"]
|
|
175
|
+
if set(data) != set(DecisionAuditReceipt.__dataclass_fields__):
|
|
176
|
+
raise ValueError("invalid decision audit receipt fields")
|
|
177
|
+
receipt = DecisionAuditReceipt(**data)
|
|
178
|
+
if receipt.decision_audit_id != decision_audit_id or receipt.audit_id != audit_id:
|
|
179
|
+
raise ValueError("audit receipt correlation differs")
|
|
180
|
+
return receipt
|
|
181
|
+
|
|
182
|
+
async def decide_with_threshold(self, *, decision: DecisionResult, question_id: str,
|
|
183
|
+
threshold: float, target: bool | int | None = None) -> ThresholdResult:
|
|
184
|
+
"""Compare native target probability, then require the durable server receipt."""
|
|
185
|
+
if not isinstance(decision, DecisionResult) or not isinstance(question_id, str) or question_id not in decision.answers:
|
|
186
|
+
raise ValueError("question_id must identify a typed decision answer")
|
|
187
|
+
if not finite(threshold):
|
|
188
|
+
raise ValueError("threshold must be a finite number in [0,1], not boolean")
|
|
189
|
+
answer = decision.answers[question_id]
|
|
190
|
+
answer_from_dict(asdict(answer))
|
|
191
|
+
chosen, probability = selected_probability(answer, target)
|
|
192
|
+
outcome = "accepted" if probability >= threshold else "below_threshold"
|
|
193
|
+
receipt = await self.model_decision_record(decision_audit_id=decision.audit_record_id,
|
|
194
|
+
question_id=question_id, target=chosen, selected_probability=probability,
|
|
195
|
+
threshold=threshold, outcome=outcome, audit_id=str(uuid.uuid4()))
|
|
196
|
+
if receipt.request_id != decision.request_id:
|
|
197
|
+
raise ValueError("threshold receipt request identity differs")
|
|
198
|
+
return ThresholdResult(decision.request_id, receipt.audit_record_id, question_id,
|
|
199
|
+
chosen, probability, threshold, outcome, answer)
|
|
200
|
+
|
|
141
201
|
async def info(self, section: str, *, page: int = 1, page_size: int = 1000) -> Any:
|
|
142
202
|
"""Return one bounded page of embedded MAC reference documentation."""
|
|
143
203
|
return await self.call("info", {"section": section, "page": page, "page_size": page_size})
|
|
@@ -223,6 +283,8 @@ for _command in COMMANDS:
|
|
|
223
283
|
"openai_models",
|
|
224
284
|
"model_pricing_get",
|
|
225
285
|
"provider_balance_get",
|
|
286
|
+
"model_decide",
|
|
287
|
+
"model_decision_record",
|
|
226
288
|
}:
|
|
227
289
|
continue
|
|
228
290
|
setattr(MacClient, _command, _make_method(_command))
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"""Typed native decisions, strict JSON validation and client-owned threshold policy."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import math
|
|
5
|
+
from dataclasses import asdict, dataclass
|
|
6
|
+
from typing import Any, Mapping, TypeAlias
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class DecisionValidationError(ValueError):
|
|
10
|
+
"""One field violation, before any provider or audit side effect."""
|
|
11
|
+
|
|
12
|
+
def __init__(self, violation: str, field: str, expected: str = "valid value") -> None:
|
|
13
|
+
super().__init__(f"{field}: {violation}; expected {expected}")
|
|
14
|
+
self.violation, self.field, self.expected = violation, field, expected
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class DecisionRemoteError(RuntimeError):
|
|
18
|
+
"""A remote ErrorResult retains its original integer code and diagnostics."""
|
|
19
|
+
|
|
20
|
+
def __init__(self, result: Mapping[str, Any]) -> None:
|
|
21
|
+
error = result.get("error") or result
|
|
22
|
+
self.code = error.get("code")
|
|
23
|
+
self.details = error.get("data", error.get("details"))
|
|
24
|
+
super().__init__(str(error.get("message", "decision command failed")))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def finite(value: Any, low: float = 0, high: float = 1) -> bool:
|
|
28
|
+
return type(value) in (int, float) and math.isfinite(value) and low <= value <= high
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def json_value(value: Any, field: str) -> None:
|
|
32
|
+
"""Reject non-JSON/nonfinite values without coercion."""
|
|
33
|
+
if value is None or type(value) in (str, bool, int):
|
|
34
|
+
return
|
|
35
|
+
if type(value) is float and math.isfinite(value):
|
|
36
|
+
return
|
|
37
|
+
if isinstance(value, list):
|
|
38
|
+
for item in value:
|
|
39
|
+
json_value(item, field)
|
|
40
|
+
return
|
|
41
|
+
if isinstance(value, dict) and all(isinstance(k, str) for k in value):
|
|
42
|
+
if value.get("type") in ("image", "box", "locate") or "data_base64" in value:
|
|
43
|
+
raise DecisionValidationError("value", field, "JSON without binary/image assets")
|
|
44
|
+
for item in value.values():
|
|
45
|
+
json_value(item, field)
|
|
46
|
+
return
|
|
47
|
+
raise DecisionValidationError("type", field, "finite JSON")
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def text(value: Any, field: str) -> None:
|
|
51
|
+
if not isinstance(value, str):
|
|
52
|
+
raise DecisionValidationError("type", field, "string")
|
|
53
|
+
if not value.strip():
|
|
54
|
+
raise DecisionValidationError("value", field, "nonempty string")
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def validate_decision_request(params: Mapping[str, Any]) -> dict[str, Any]:
|
|
58
|
+
"""Unknown -> required -> conditional -> type/value, preserving all identities."""
|
|
59
|
+
required = ("provider_id", "model_id", "state", "questions", "definition_id")
|
|
60
|
+
for key in params:
|
|
61
|
+
if key not in (*required, "provider_key_id"):
|
|
62
|
+
raise DecisionValidationError("unknown", key)
|
|
63
|
+
questions = params.get("questions")
|
|
64
|
+
if isinstance(questions, dict):
|
|
65
|
+
for question in questions.values():
|
|
66
|
+
if isinstance(question, dict) and any(k not in ("type", "instructions", "criteria") for k in question):
|
|
67
|
+
raise DecisionValidationError("unknown", "questions")
|
|
68
|
+
for key in required:
|
|
69
|
+
if key not in params:
|
|
70
|
+
raise DecisionValidationError("missing", key)
|
|
71
|
+
questions = params["questions"]
|
|
72
|
+
if isinstance(questions, dict):
|
|
73
|
+
for question in questions.values():
|
|
74
|
+
if not isinstance(question, dict):
|
|
75
|
+
continue
|
|
76
|
+
if any(k not in ("type", "instructions", "criteria") for k in question):
|
|
77
|
+
raise DecisionValidationError("unknown", "questions")
|
|
78
|
+
for key in ("type", "instructions"):
|
|
79
|
+
if key not in question:
|
|
80
|
+
raise DecisionValidationError("missing", "questions", key)
|
|
81
|
+
if question.get("type") in ("choice", "score") and "criteria" not in question:
|
|
82
|
+
raise DecisionValidationError("missing", "questions", "criteria")
|
|
83
|
+
for key in ("provider_id", "model_id", "definition_id"):
|
|
84
|
+
text(params[key], key)
|
|
85
|
+
if "provider_key_id" in params:
|
|
86
|
+
text(params["provider_key_id"], "provider_key_id")
|
|
87
|
+
state = params["state"]
|
|
88
|
+
if not isinstance(state, (str, dict, list)):
|
|
89
|
+
raise DecisionValidationError("type", "state", "string, object or array")
|
|
90
|
+
json_value(state, "state")
|
|
91
|
+
if not isinstance(questions, dict):
|
|
92
|
+
raise DecisionValidationError("type", "questions", "object")
|
|
93
|
+
if not questions:
|
|
94
|
+
raise DecisionValidationError("value", "questions", "nonempty object")
|
|
95
|
+
for name, question in questions.items():
|
|
96
|
+
if not isinstance(name, str) or not name.strip() or not isinstance(question, dict):
|
|
97
|
+
raise DecisionValidationError("value", "questions", "named question objects")
|
|
98
|
+
kind = question.get("type")
|
|
99
|
+
if kind not in ("noul", "choice", "score"):
|
|
100
|
+
raise DecisionValidationError("value", "questions", "noul, choice or score")
|
|
101
|
+
instructions = question["instructions"]
|
|
102
|
+
if not isinstance(instructions, (str, dict, list)):
|
|
103
|
+
raise DecisionValidationError("type", "questions", "structured instructions")
|
|
104
|
+
if isinstance(instructions, str) and not instructions.strip():
|
|
105
|
+
raise DecisionValidationError("value", "questions", "nonempty instructions")
|
|
106
|
+
criteria = question.get("criteria")
|
|
107
|
+
if kind == "choice":
|
|
108
|
+
if not isinstance(criteria, dict) or not 1 <= len(criteria) <= 255:
|
|
109
|
+
raise DecisionValidationError("value", "questions", "1..255 choice criteria")
|
|
110
|
+
if any(not isinstance(k, str) or not k.strip() for k in criteria):
|
|
111
|
+
raise DecisionValidationError("value", "questions", "nonempty option names")
|
|
112
|
+
descriptions = criteria.values()
|
|
113
|
+
elif kind == "score":
|
|
114
|
+
if not isinstance(criteria, list) or not 2 <= len(criteria) <= 10:
|
|
115
|
+
raise DecisionValidationError("value", "questions", "2..10 score levels")
|
|
116
|
+
descriptions = criteria
|
|
117
|
+
elif "criteria" in question:
|
|
118
|
+
if not isinstance(criteria, dict) or set(criteria) != {"true", "false"}:
|
|
119
|
+
raise DecisionValidationError("value", "questions", "true/false criteria")
|
|
120
|
+
descriptions = criteria.values()
|
|
121
|
+
else:
|
|
122
|
+
descriptions = ()
|
|
123
|
+
for description in descriptions:
|
|
124
|
+
if not isinstance(description, (str, dict, list)) and not (kind == "choice" and description is None):
|
|
125
|
+
raise DecisionValidationError("type", "questions", "structured criteria descriptions")
|
|
126
|
+
json_value(question, "questions")
|
|
127
|
+
return {**params, "provider_key_id": params.get("provider_key_id", "noauth:default")}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
@dataclass(frozen=True)
|
|
131
|
+
class NoulAnswer:
|
|
132
|
+
type: str
|
|
133
|
+
noul: float
|
|
134
|
+
confidence: None = None
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
@dataclass(frozen=True)
|
|
138
|
+
class ChoiceAnswer:
|
|
139
|
+
type: str
|
|
140
|
+
choice: str
|
|
141
|
+
probabilities: dict[str, float]
|
|
142
|
+
confidence: float | None
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
@dataclass(frozen=True)
|
|
146
|
+
class ScoreAnswer:
|
|
147
|
+
type: str
|
|
148
|
+
score: float
|
|
149
|
+
probabilities: dict[str, float]
|
|
150
|
+
legend: dict[str, Any]
|
|
151
|
+
confidence: float | None
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
DecisionAnswer: TypeAlias = NoulAnswer | ChoiceAnswer | ScoreAnswer
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def answer_from_dict(raw: Any, question: Mapping[str, Any] | None = None) -> DecisionAnswer:
|
|
158
|
+
"""Validate a whole native answer; never repair probabilities or round a score."""
|
|
159
|
+
if not isinstance(raw, dict):
|
|
160
|
+
raise ValueError("decision answer must be an object")
|
|
161
|
+
kind = raw.get("type")
|
|
162
|
+
if question is not None and kind != question["type"]:
|
|
163
|
+
raise ValueError("decision answer type differs from question")
|
|
164
|
+
confidence = raw.get("confidence")
|
|
165
|
+
if confidence is not None and not finite(confidence):
|
|
166
|
+
raise ValueError("invalid vendor confidence")
|
|
167
|
+
if kind == "noul":
|
|
168
|
+
if set(raw) - {"type", "noul", "confidence"} or not finite(raw.get("noul")) or confidence is not None:
|
|
169
|
+
raise ValueError("invalid noul answer")
|
|
170
|
+
return NoulAnswer("noul", raw["noul"])
|
|
171
|
+
if kind not in ("choice", "score"):
|
|
172
|
+
raise ValueError("unsupported decision answer type")
|
|
173
|
+
allowed = {"type", "choice", "probabilities", "confidence"} if kind == "choice" else {"type", "score", "probabilities", "legend", "confidence"}
|
|
174
|
+
if set(raw) - allowed:
|
|
175
|
+
raise ValueError("unknown decision answer fields")
|
|
176
|
+
probs = raw.get("probabilities")
|
|
177
|
+
if not isinstance(probs, dict) or not probs or any(not isinstance(k, str) or not finite(v) for k, v in probs.items()):
|
|
178
|
+
raise ValueError("invalid probability distribution")
|
|
179
|
+
if abs(sum(probs.values()) - 1) > (1e-3 if kind == "choice" else 1e-6):
|
|
180
|
+
raise ValueError("probabilities are not normalized")
|
|
181
|
+
if kind == "choice":
|
|
182
|
+
if question is not None and set(probs) != set(question["criteria"]):
|
|
183
|
+
raise ValueError("choice options differ from requested criteria")
|
|
184
|
+
choice = raw.get("choice")
|
|
185
|
+
if choice not in probs or probs[choice] < max(probs.values()):
|
|
186
|
+
raise ValueError("choice is not a maximal native option")
|
|
187
|
+
return ChoiceAnswer(kind, choice, dict(probs), confidence)
|
|
188
|
+
count = len(question["criteria"]) if question is not None else len(probs)
|
|
189
|
+
if set(probs) != {str(i) for i in range(count)} or not finite(raw.get("score"), 0, count - 1):
|
|
190
|
+
raise ValueError("invalid score levels or expectation")
|
|
191
|
+
expected = sum(i * probs[str(i)] for i in range(count))
|
|
192
|
+
if abs(raw["score"] - expected) > 1e-3:
|
|
193
|
+
raise ValueError("score differs from native expected level")
|
|
194
|
+
legend = {str(i): v for i, v in enumerate(question["criteria"])} if question is not None else raw.get("legend")
|
|
195
|
+
if not isinstance(legend, dict) or set(legend) != set(probs) or ("legend" in raw and raw["legend"] != legend):
|
|
196
|
+
raise ValueError("score legend differs from rubric")
|
|
197
|
+
return ScoreAnswer(kind, raw["score"], dict(probs), legend, confidence)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
@dataclass(frozen=True)
|
|
201
|
+
class DecisionResult:
|
|
202
|
+
request_id: str
|
|
203
|
+
audit_record_id: str
|
|
204
|
+
provider_id: str
|
|
205
|
+
requested_model_id: str
|
|
206
|
+
model_id: str
|
|
207
|
+
answers: dict[str, DecisionAnswer]
|
|
208
|
+
usage: dict[str, int | None]
|
|
209
|
+
cost: dict[str, Any]
|
|
210
|
+
latency_ms: float
|
|
211
|
+
|
|
212
|
+
@classmethod
|
|
213
|
+
def from_dict(cls, raw: Mapping[str, Any]) -> DecisionResult:
|
|
214
|
+
if set(raw) != set(cls.__dataclass_fields__):
|
|
215
|
+
raise ValueError("invalid DecisionResult fields")
|
|
216
|
+
data = dict(raw)
|
|
217
|
+
for key in ("request_id", "audit_record_id", "provider_id", "requested_model_id", "model_id"):
|
|
218
|
+
text(data[key], key)
|
|
219
|
+
if not finite(data["latency_ms"], 0, math.inf):
|
|
220
|
+
raise ValueError("invalid latency")
|
|
221
|
+
usage = data["usage"]
|
|
222
|
+
if not isinstance(usage, dict) or set(usage) != {"input_tokens", "output_tokens", "total_tokens"}:
|
|
223
|
+
raise ValueError("invalid usage fields")
|
|
224
|
+
if any(v is not None and (type(v) is not int or v < 0) for v in usage.values()):
|
|
225
|
+
raise ValueError("invalid usage counts")
|
|
226
|
+
if usage["input_tokens"] is not None and usage["output_tokens"] is not None and usage["total_tokens"] != usage["input_tokens"] + usage["output_tokens"]:
|
|
227
|
+
raise ValueError("invalid usage sum")
|
|
228
|
+
cost = data["cost"]
|
|
229
|
+
if not isinstance(cost, dict) or set(cost) != {"amount", "currency", "source", "as_of"} or cost["currency"] != "USD" or cost["source"] not in ("provider", "catalog", "unavailable"):
|
|
230
|
+
raise ValueError("invalid cost provenance")
|
|
231
|
+
if (cost["source"] == "unavailable" and cost["amount"] is not None) or (cost["source"] != "unavailable" and not finite(cost["amount"], 0, math.inf)):
|
|
232
|
+
raise ValueError("invalid cost amount")
|
|
233
|
+
if not isinstance(data["answers"], dict) or not data["answers"]:
|
|
234
|
+
raise ValueError("invalid answers")
|
|
235
|
+
data["answers"] = {k: answer_from_dict(v) for k, v in data["answers"].items()}
|
|
236
|
+
return cls(**data)
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
@dataclass(frozen=True)
|
|
240
|
+
class DecisionAuditReceipt:
|
|
241
|
+
request_id: str
|
|
242
|
+
decision_audit_id: str
|
|
243
|
+
audit_record_id: str
|
|
244
|
+
audit_id: str
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
@dataclass(frozen=True)
|
|
248
|
+
class ThresholdResult:
|
|
249
|
+
request_id: str
|
|
250
|
+
audit_record_id: str
|
|
251
|
+
question_id: str
|
|
252
|
+
target: str | bool | int
|
|
253
|
+
selected_probability: float
|
|
254
|
+
threshold: float
|
|
255
|
+
status: str
|
|
256
|
+
answer: DecisionAnswer
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def selected_probability(answer: DecisionAnswer, target: Any = None) -> tuple[Any, float]:
|
|
260
|
+
if isinstance(answer, ChoiceAnswer):
|
|
261
|
+
if target is not None:
|
|
262
|
+
raise ValueError("choice target must be omitted")
|
|
263
|
+
return answer.choice, answer.probabilities[answer.choice]
|
|
264
|
+
if isinstance(answer, NoulAnswer):
|
|
265
|
+
if type(target) is not bool:
|
|
266
|
+
raise ValueError("noul requires an explicit boolean target")
|
|
267
|
+
return target, answer.noul if target else 1 - answer.noul
|
|
268
|
+
if not isinstance(answer, ScoreAnswer) or type(target) is not int or str(target) not in answer.probabilities:
|
|
269
|
+
raise ValueError("score requires an explicit level index")
|
|
270
|
+
return target, answer.probabilities[str(target)]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|