docs[patch]: update links w/ new langgraph API ref (#26961)

Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
Vadym Barda 2024-10-03 19:52:01 -04:00 committed by GitHub
parent 47142eb6ee
commit 2715bed70e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -20,111 +20,53 @@ _LANGGRAPH_API_REFERENCE = "https://langchain-ai.github.io/langgraph/reference/"
code_block_re = re.compile(r"^(```\s?python\n)(.*?)(```)", re.DOTALL | re.MULTILINE) code_block_re = re.compile(r"^(```\s?python\n)(.*?)(```)", re.DOTALL | re.MULTILINE)
# (alias/re-exported modules, source module, class, docs namespace)
MANUAL_API_REFERENCES_LANGGRAPH = [ MANUAL_API_REFERENCES_LANGGRAPH = [
("langgraph.prebuilt", "create_react_agent"),
( (
"langgraph.prebuilt", ["langgraph.prebuilt"],
"ToolNode", "langgraph.prebuilt.chat_agent_executor",
"create_react_agent",
"prebuilt",
),
(["langgraph.prebuilt"], "langgraph.prebuilt.tool_node", "ToolNode", "prebuilt"),
(
["langgraph.prebuilt"],
"langgraph.prebuilt.tool_node",
"tools_condition",
"prebuilt",
), ),
( (
"langgraph.prebuilt", ["langgraph.prebuilt"],
"ToolExecutor", "langgraph.prebuilt.tool_node",
),
(
"langgraph.prebuilt",
"ToolInvocation",
),
("langgraph.prebuilt", "tools_condition"),
(
"langgraph.prebuilt",
"ValidationNode",
),
(
"langgraph.prebuilt",
"InjectedState", "InjectedState",
"prebuilt",
), ),
# Graph # Graph
( (["langgraph.graph"], "langgraph.graph.message", "add_messages", "graphs"),
"langgraph.graph", (["langgraph.graph"], "langgraph.graph.state", "StateGraph", "graphs"),
"StateGraph", (["langgraph.graph"], "langgraph.graph.state", "CompiledStateGraph", "graphs"),
), ([], "langgraph.types", "StreamMode", "types"),
( (["langgraph.graph"], "langgraph.constants", "START", "constants"),
"langgraph.graph.message", (["langgraph.graph"], "langgraph.constants", "END", "constants"),
"MessageGraph", (["langgraph.constants"], "langgraph.types", "Send", "types"),
), (["langgraph.constants"], "langgraph.types", "Interrupt", "types"),
("langgraph.graph.message", "add_messages"), ([], "langgraph.types", "RetryPolicy", "types"),
( ([], "langgraph.checkpoint.base", "Checkpoint", "checkpoints"),
"langgraph.graph.graph", ([], "langgraph.checkpoint.base", "CheckpointMetadata", "checkpoints"),
"CompiledGraph", ([], "langgraph.checkpoint.base", "BaseCheckpointSaver", "checkpoints"),
), ([], "langgraph.checkpoint.base", "SerializerProtocol", "checkpoints"),
( ([], "langgraph.checkpoint.serde.jsonplus", "JsonPlusSerializer", "checkpoints"),
"langgraph.types", ([], "langgraph.checkpoint.memory", "MemorySaver", "checkpoints"),
"StreamMode", ([], "langgraph.checkpoint.sqlite.aio", "AsyncSqliteSaver", "checkpoints"),
), ([], "langgraph.checkpoint.sqlite", "SqliteSaver", "checkpoints"),
( ([], "langgraph.checkpoint.postgres.aio", "AsyncPostgresSaver", "checkpoints"),
"langgraph.graph", ([], "langgraph.checkpoint.postgres", "PostgresSaver", "checkpoints"),
"START",
),
(
"langgraph.graph",
"END",
),
(
"langgraph.types",
"Send",
),
(
"langgraph.types",
"Interrupt",
),
(
"langgraph.types",
"RetryPolicy",
),
(
"langgraph.checkpoint.base",
"Checkpoint",
),
(
"langgraph.checkpoint.base",
"CheckpointMetadata",
),
(
"langgraph.checkpoint.base",
"BaseCheckpointSaver",
),
(
"langgraph.checkpoint.base",
"SerializerProtocol",
),
(
"langgraph.checkpoint.serde.jsonplus",
"JsonPlusSerializer",
),
(
"langgraph.checkpoint.memory",
"MemorySaver",
),
(
"langgraph.checkpoint.sqlite.aio",
"AsyncSqliteSaver",
),
(
"langgraph.checkpoint.sqlite",
"SqliteSaver",
),
(
"langgraph.checkpoint.postgres.aio",
"AsyncPostgresSaver",
),
(
"langgraph.checkpoint.postgres",
"PostgresSaver",
),
] ]
WELL_KNOWN_LANGGRAPH_OBJECTS = { WELL_KNOWN_LANGGRAPH_OBJECTS = {
(module_, class_) for module_, class_ in MANUAL_API_REFERENCES_LANGGRAPH (module_, class_): (source_module, namespace)
for (modules, source_module, class_, namespace) in MANUAL_API_REFERENCES_LANGGRAPH
for module_ in modules + [source_module]
} }
@ -308,34 +250,21 @@ def _get_imports(
+ ".html" + ".html"
) )
elif package_ecosystem == "langgraph": elif package_ecosystem == "langgraph":
if module.startswith("langgraph.checkpoint"): if (module, class_name) not in WELL_KNOWN_LANGGRAPH_OBJECTS:
namespace = "checkpoints"
elif module.startswith("langgraph.graph"):
namespace = "graphs"
elif module.startswith("langgraph.prebuilt"):
namespace = "prebuilt"
elif module.startswith("langgraph.errors"):
namespace = "errors"
else:
# Likely not documented yet # Likely not documented yet
# Unable to determine the namespace
continue continue
if module.startswith("langgraph.errors"): source_module, namespace = WELL_KNOWN_LANGGRAPH_OBJECTS[
# Has different URL structure than other modules (module, class_name)
url = ( ]
_LANGGRAPH_API_REFERENCE url = (
+ namespace _LANGGRAPH_API_REFERENCE
+ "/#langgraph.errors." + namespace
+ class_name # Uses the actual class name here. + "/#"
) + source_module
else: + "."
if (module, class_name) not in WELL_KNOWN_LANGGRAPH_OBJECTS: + class_name
# Likely not documented yet )
continue
url = (
_LANGGRAPH_API_REFERENCE + namespace + "/#" + class_name.lower()
)
else: else:
raise ValueError(f"Invalid package ecosystem: {package_ecosystem}") raise ValueError(f"Invalid package ecosystem: {package_ecosystem}")