File size: 1,434 Bytes
7ff7119
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""extract_subgraph — strukturált adatkinyerés egy doksiból.

A `prototype-agentic` extract.py minta egyszerűsített LangGraph megfelelője.

Topológia:

    START
      → extract_node               (regex/LLM extract → flatten_universal)
      → END

A quote_validator_node külön a parent pipeline_graph-ban fut, a Send fan-in
UTÁN, hogy az összes doksi extracted-jét együtt látjuk és risk-eket tudjunk
generálni.

A vision/chunked/single_call routing-ot a Fázis 5-ben bővítjük (ott jön a Claude
`with_structured_output` integráció). A Fázis 3-as dummy-extractor ezeket
egyetlen szinkron path-on csinálja.
"""

from __future__ import annotations

from typing import TypedDict

from langgraph.graph import END, START, StateGraph

from graph.states.pipeline_state import (
    Classification,
    ExtractedData,
    IngestedDocument,
)
from nodes.extract.extract_node import extract_node


class ExtractState(TypedDict, total=False):
    """A extract subgraph belső state-je."""

    ingested: IngestedDocument
    classification: Classification
    extracted: ExtractedData
    documents: list  # a parent reducer-be megy vissza


def build_extract_subgraph():
    """Compile-olt subgraph egyetlen doksi extract-jére."""
    graph = StateGraph(ExtractState)
    graph.add_node("extract", extract_node)
    graph.add_edge(START, "extract")
    graph.add_edge("extract", END)
    return graph.compile()