Melika Kheirieh commited on
Commit
e45f1b1
·
1 Parent(s): 3ef53b4

feat(pipeline): attach executor result to FinalResult and expose real query output to API/UI

Browse files
Files changed (1) hide show
  1. nl2sql/pipeline.py +7 -0
nl2sql/pipeline.py CHANGED
@@ -27,6 +27,7 @@ class FinalResult:
27
  verified: Optional[bool]
28
  questions: Optional[List[str]]
29
  traces: List[dict]
 
30
 
31
 
32
  class Pipeline:
@@ -243,6 +244,7 @@ class Pipeline:
243
  t_all0 = time.perf_counter()
244
  traces: List[dict] = []
245
  details: List[str] = []
 
246
 
247
  def _fallback_trace(stage_name: str, dt_ms: float, ok: bool) -> None:
248
  traces.append(
@@ -417,6 +419,8 @@ class Pipeline:
417
  _fallback_trace("executor", dt, r_exec.ok)
418
  if not r_exec.ok and r_exec.error:
419
  details.extend(r_exec.error) # soft: keep for repair/verifier context
 
 
420
 
421
  # --- 6) verifier ---
422
  t0 = time.perf_counter()
@@ -488,6 +492,8 @@ class Pipeline:
488
  if r_exec2.error:
489
  details.extend(r_exec2.error)
490
  continue
 
 
491
 
492
  # verifier again
493
  t0 = time.perf_counter()
@@ -575,6 +581,7 @@ class Pipeline:
575
  verified=verified_final,
576
  questions=None,
577
  traces=self._normalize_traces(traces),
 
578
  )
579
 
580
  except Exception:
 
27
  verified: Optional[bool]
28
  questions: Optional[List[str]]
29
  traces: List[dict]
30
+ result: Optional[Dict[str, Any]] = None
31
 
32
 
33
  class Pipeline:
 
244
  t_all0 = time.perf_counter()
245
  traces: List[dict] = []
246
  details: List[str] = []
247
+ exec_result: Dict[str, Any] = {}
248
 
249
  def _fallback_trace(stage_name: str, dt_ms: float, ok: bool) -> None:
250
  traces.append(
 
419
  _fallback_trace("executor", dt, r_exec.ok)
420
  if not r_exec.ok and r_exec.error:
421
  details.extend(r_exec.error) # soft: keep for repair/verifier context
422
+ if r_exec.ok and isinstance(r_exec.data, dict):
423
+ exec_result = dict(r_exec.data)
424
 
425
  # --- 6) verifier ---
426
  t0 = time.perf_counter()
 
492
  if r_exec2.error:
493
  details.extend(r_exec2.error)
494
  continue
495
+ if r_exec2.ok and isinstance(r_exec2.data, dict):
496
+ exec_result = dict(r_exec2.data)
497
 
498
  # verifier again
499
  t0 = time.perf_counter()
 
581
  verified=verified_final,
582
  questions=None,
583
  traces=self._normalize_traces(traces),
584
+ result=exec_result or None,
585
  )
586
 
587
  except Exception: