Spaces:
Runtime error

File size: 1,142 Bytes
c0e3412
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Phase IV: External Convergence."""

from __future__ import annotations

import time

from ..core import ConvergenceProtocol
from ..types import PhaseOutput, RunConfig, SolutionState


def run(state: SolutionState, config: RunConfig) -> tuple[SolutionState, PhaseOutput]:
    t0 = time.perf_counter()
    conv = ConvergenceProtocol()
    external = {"external_synthesis": "", "responses": {}, "confidence": 0.0}
    if config.external_enabled:
        # Pass blocks for topic extraction
        context = {
            "problem": state.problem,
            "blocks": state.blocks,
            "building_height": state.building_height,
        }
        external = conv.convene_meeting(context)
    dt = time.perf_counter() - t0
    state.extra["external"] = external
    return (
        state,
        PhaseOutput(
            name="phase4_external_convergence",
            input={"external_enabled": config.external_enabled, "blocks_count": len(state.blocks)},
            output={"confidence": external.get("confidence", 0.0), "external_synthesis": external.get("external_synthesis", "")},
            duration_sec=dt,
        ),
    )