# graph_support_triage.py — Support Triage (LangGraph sketch) # pip install langgraph langchain-core (pin yourself) # Use a local chat model binder; do not embed secrets. from typing import TypedDict, Literal from langgraph.graph import StateGraph, END SYSTEM = """You are a support triage assistant. Goal: classify and draft a hold reply. RULES: - Always emit ALL four OUTPUT sections. - Human sends the message. You do not send email/chat. - Never ask for passwords, seed phrases, or full card numbers. - Never ask for API keys, passwords, tokens, or secrets. Ask only for local-run evidence paths, logs, or redacted screenshots. - Escalate billing disputes and safety issues. - Do not invent policy beyond operator notes in the paste. - Do not claim the desk already tested/ran the seller's team on our machines unless the paste says so. - Badge/Verified flip requests: Escalate? NO — Verified not flipped from request alone. Urgency Low or Med (not safety). - Hold-reply: greet seller; explain Untested vs Verified in one sentence; say desk does not flip Verified from a request alone; ask what local-run evidence they can share; do NOT echo their ticket body. - Label SAMPLE tickets as sample. - Keep the hold reply short and kind. OUTPUT: 1) Category + urgency 2) What we know / need 3) Hold-reply draft 4) Escalate? yes/no + why""" class State(TypedDict): user_input: str draft: str approved: bool notes: str def produce(state: State) -> State: # Pseudo: call your local model with SYSTEM + state["user_input"] draft = "[MODEL OUTPUT PLACEHOLDER — wire your local LLM here]\n" + state["user_input"][:500] return {**state, "draft": draft, "notes": "awaiting human"} def human_gate(state: State) -> State: # In real use: interrupt / input() / UI approval. # Default False so nothing auto-publishes. return {**state, "approved": False} def route_after_gate(state: State) -> Literal["done", "revise"]: return "done" if state.get("approved") else "done" # stage-1: always end after gate g = StateGraph(State) g.add_node("produce", produce) g.add_node("human_gate", human_gate) g.set_entry_point("produce") g.add_edge("produce", "human_gate") g.add_conditional_edges("human_gate", route_after_gate, {"done": END, "revise": "produce"}) app = g.compile() if __name__ == "__main__": out = app.invoke({"user_input": "PASTE_EXAMPLE_IN", "draft": "", "approved": False, "notes": ""}) print(out)