File size: 904 Bytes
f8734b3
bcfaa84
 
b48a433
bcfaa84
b6b7990
c2d02ae
 
b48a433
 
 
f8734b3
bcfaa84
 
b6b7990
c2d02ae
 
b48a433
 
 
bcfaa84
 
 
 
b48a433
bcfaa84
 
 
 
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
from langgraph.graph import StateGraph

def build_graph():
    graph = StateGraph(dict)

    def llm_step(state):
        question = state.get("question")
        if not question:
            raise ValueError("State is missing 'question'")
        # This is where you integrate your LLM call.
        llm_output = f"Dummy answer to: {question}"
        state["llm_output"] = llm_output
        return state

    def formatter_step(state):
        llm_output = state.get("llm_output")
        if not llm_output:
            raise ValueError("State is missing 'llm_output'")
        # For now, we just pass it through.
        state["final_answer"] = llm_output.strip()
        return state

    graph.add_node("llm", llm_step)
    graph.add_node("formatter", formatter_step)
    graph.set_entry_point("llm")
    graph.add_edge("llm", "formatter")
    graph.set_finish_point("formatter")

    return graph