File size: 1,014 Bytes
e5bcce8
bc2a98e
e5bcce8
 
 
 
 
 
 
 
 
 
 
 
bc2a98e
 
 
e5bcce8
 
 
 
 
 
 
 
 
 
 
 
bc2a98e
 
 
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
"""Screening workflow assembly for the MOF six-step pipeline."""
from agent import nodes
from agent.state import ScreeningState


class SimpleScreeningApp:
    """Small invoke-compatible workflow used when LangGraph is unavailable."""

    def invoke(self, state: ScreeningState) -> ScreeningState:
        current: ScreeningState = dict(state)
        for node in (nodes.ingest_cif, nodes.six_step_screening_agent):
            update = node(current)
            current.update(update)
        return current


def build_graph():
    try:
        from langgraph.graph import END, StateGraph

        g = StateGraph(ScreeningState)
        g.add_node("ingest_cif", nodes.ingest_cif)
        g.add_node("six_step_screening", nodes.six_step_screening_agent)
        g.set_entry_point("ingest_cif")
        g.add_edge("ingest_cif", "six_step_screening")
        g.add_edge("six_step_screening", END)
        return g.compile()
    except Exception:
        return SimpleScreeningApp()


screening_app = build_graph()