nat.plugins.langchain.langgraph_workflow#
Attributes#
Classes#
Input model for the LangGraph wrapper. |
|
Output model for the LangGraph wrapper. |
|
Configuration model for the LangGraph wrapper. |
|
Function for the LangGraph wrapper. |
Functions#
|
Module Contents#
- GraphDefType#
- logger#
- class LanggraphWrapperInput(/, **data: Any)#
Bases:
pydantic.BaseModelInput model for the LangGraph wrapper.
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- model_config#
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class LanggraphWrapperOutput(/, **data: Any)#
Bases:
pydantic.BaseModelOutput model for the LangGraph wrapper.
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- model_config#
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class LanggraphWrapperConfig#
Bases:
nat.data_models.function.FunctionBaseConfigConfiguration model for the LangGraph wrapper.
- model_config#
- class LanggraphWrapperFunction(
- *,
- config: LanggraphWrapperConfig,
- description: str | None = None,
- graph: langgraph.graph.state.CompiledStateGraph,
Bases:
nat.builder.function.Function[LanggraphWrapperInput,LanggraphWrapperOutput,LanggraphWrapperOutput]Function for the LangGraph wrapper.
Initialize the LangGraph wrapper function.
- Args:
config: The configuration for the LangGraph wrapper. description: The description of the LangGraph wrapper. graph: The graph to wrap.
- _graph#
- async _ainvoke(value: LanggraphWrapperInput) LanggraphWrapperOutput#
- async _astream(
- value: LanggraphWrapperInput,
- static _parse_stream_output(output: dict) LanggraphWrapperOutput#
Unwrap node-keyed dicts that LangGraph astream() yields.
- static convert_to_str(value: LanggraphWrapperOutput) str#
Convert the output to a string.
- static convert_chat_request( ) LanggraphWrapperInput#
Convert a ChatRequest to LanggraphWrapperInput.
- static convert_str(value: str) LanggraphWrapperInput#
Convert a plain text string to LanggraphWrapperInput.
- static convert_to_chat_response(
- value: LanggraphWrapperOutput,
Convert LanggraphWrapperOutput to ChatResponse.
- static convert_to_chat_response_chunk(
- value: LanggraphWrapperOutput,
Convert LanggraphWrapperOutput to ChatResponseChunk.
- async register(
- config: LanggraphWrapperConfig,
- b: nat.builder.builder.Builder,