@@ -242,3 +242,82 @@ def verify_trade_reasoning(
242242 client = CogDxClient (coupon = coupon , wallet = wallet )
243243 result = client .verify_before_trade (reasoning )
244244 return result .get ("approved" , False )
245+
246+ def submit_feedback (
247+ self ,
248+ endpoint : str ,
249+ agent_id : str ,
250+ accurate : bool ,
251+ confidence : Optional [float ] = None ,
252+ severity : Optional [int ] = None ,
253+ accuracy_score : Optional [float ] = None ,
254+ outcome : Optional [str ] = None ,
255+ reasoning : Optional [str ] = None ,
256+ diagnosis_id : Optional [str ] = None ,
257+ wallet : Optional [str ] = None
258+ ) -> Dict [str , Any ]:
259+ """
260+ Submit feedback on a diagnosis to improve detection and earn credits.
261+
262+ Binary core (required):
263+ - endpoint: Which endpoint was diagnosed
264+ - agent_id: Your agent identifier
265+ - accurate: Was the detection correct? (True/False)
266+
267+ Numerical enrichment (optional - increases signal + credits):
268+ - confidence: 0.0-1.0 - How sure are you about this feedback?
269+ - severity: 1-5 - If bias was real, how impactful?
270+ - accuracy_score: 0.0-1.0 - Partial credit (mostly right, slightly off)
271+
272+ Structured context (optional):
273+ - outcome: "win" | "loss" | "neutral" | "unknown"
274+ - reasoning: Why was detection right/wrong?
275+ - diagnosis_id: ID from original diagnosis
276+ - wallet: Earn credits to this wallet (0x...)
277+
278+ Returns:
279+ dict with:
280+ - received: bool
281+ - feedback_id: str
282+ - signal_strength: float (1.0-2.0x learning value)
283+ - credits: {awarded, new_balance, wallet} if wallet provided
284+ - network_contribution: impact on shared reality
285+ """
286+ try :
287+ payload = {
288+ "endpoint" : endpoint ,
289+ "agent_id" : agent_id ,
290+ "accurate" : accurate ,
291+ }
292+
293+ # Optional numerical enrichment
294+ if confidence is not None :
295+ payload ["confidence" ] = confidence
296+ if severity is not None :
297+ payload ["severity" ] = severity
298+ if accuracy_score is not None :
299+ payload ["accuracy_score" ] = accuracy_score
300+
301+ # Optional structured context
302+ if outcome :
303+ payload ["outcome" ] = outcome
304+ if reasoning :
305+ payload ["reasoning" ] = reasoning
306+ if diagnosis_id :
307+ payload ["diagnosis_id" ] = diagnosis_id
308+ if wallet :
309+ payload ["wallet" ] = wallet
310+ elif self .wallet :
311+ payload ["wallet" ] = self .wallet
312+
313+ response = requests .post (
314+ f"{ self .BASE_URL } /feedback" ,
315+ headers = self ._headers (),
316+ json = payload ,
317+ timeout = 30
318+ )
319+
320+ return response .json ()
321+
322+ except Exception as e :
323+ return {"error" : str (e ), "received" : False }
0 commit comments