evalwire.langgraph¶
evalwire.langgraph
¶
LangGraph node isolation helpers (requires evalwire[langgraph] extra).
build_subgraph(nodes, state_cls, input_cls=None, *, name=None, checkpointer=None)
¶
Assemble a minimal linear StateGraph from a list of node callables.
Edges are added in declaration order:
START → nodes[0] → nodes[1] → … → END.
Parameters¶
nodes:
Ordered list of (node_name, node_callable) pairs.
state_cls:
LangGraph state dataclass for the graph.
input_cls:
Optional input-schema dataclass passed as input_schema=input_cls
to StateGraph.
name:
Optional graph name used for Phoenix tracing.
checkpointer:
Optional LangGraph checkpointer.
Returns¶
CompiledStateGraph
The compiled subgraph, ready for await graph.ainvoke(...).
Source code in src/evalwire/langgraph.py
invoke_node(node_fn, query, state_cls, *, message_field='messages', config=None)
async
¶
Directly call a single LangGraph node as a standalone async function.
Constructs a state_cls instance with a single HumanMessage placed
in message_field, calls await node_fn(state=state, config=config),
and returns the raw result.
Parameters¶
node_fn:
The node callable to invoke.
query:
The human message content to place in message_field.
state_cls:
LangGraph state dataclass used to build the input state.
message_field:
Name of the field on state_cls that holds the messages list.
config:
Optional RunnableConfig. A default empty config is used if None.
Returns¶
Any The raw return value of the node callable.