-
Notifications
You must be signed in to change notification settings - Fork 566
docs: add guide for choosing between Graph and Functional APIs #1225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Mintlify preview ID generated: preview-mdrxyl-1761933163-3caa308 |
|
Mintlify preview ID generated: preview-mdrxyl-1761935042-5451e86 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new conceptual guide comparing LangGraph's Graph API and Functional API to help users choose the appropriate approach for their use case.
Key Changes
- Adds comprehensive guide explaining when to use Graph API vs Functional API
- Includes practical code examples demonstrating different use cases for each API
- Provides migration guidance between the two approaches
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/oss/langgraph/choosing-apis.mdx | New conceptual guide with decision criteria, detailed comparisons, code examples, and migration strategies for choosing between LangGraph's Graph and Functional APIs |
| src/docs.json | Adds new guide to both Python and JavaScript navigation under "LangGraph APIs" section |
| # Graph API: Clear visualization of decision paths | ||
| from langgraph.graph import StateGraph | ||
| from typing import TypedDict | ||
|
|
||
| class AgentState(TypedDict): | ||
| messages: list | ||
| current_tool: str | ||
| retry_count: int | ||
|
|
||
| def should_continue(state): | ||
| if state["retry_count"] > 3: | ||
| return "end" | ||
| elif state["current_tool"] == "search": | ||
| return "process_search" | ||
| else: | ||
| return "call_llm" | ||
|
|
||
| workflow = StateGraph(AgentState) | ||
| workflow.add_node("call_llm", call_llm_node) | ||
| workflow.add_node("process_search", search_node) | ||
| workflow.add_conditional_edges("call_llm", should_continue) |
Copilot
AI
Nov 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This document contains only Python code examples but is referenced in both Python and JavaScript navigation paths. According to the custom coding guidelines (CodingGuidelineID: 1000000), files in /oss/ that contain language-specific content should use custom language fences (:::python and :::js) to generate language-specific outputs. All code blocks should be wrapped with :::python and ::: fences, and corresponding JavaScript/TypeScript examples should be added within :::js and ::: fences. This will ensure the build pipeline creates appropriate versions for both languages.
| { | ||
| "group": "LangGraph APIs", | ||
| "pages": [ | ||
| "oss/python/langgraph/choosing-apis", |
Copilot
AI
Nov 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file path references a language-specific directory (oss/python/langgraph/choosing-apis) but the actual file is located at src/oss/langgraph/choosing-apis.mdx without language-specific subdirectories. According to the build pipeline, files in /oss/langgraph/ with custom language fences are automatically processed to create language-specific outputs at paths like /oss/python/langgraph/ and /oss/javascript/langgraph/. Ensure the source file uses the custom language fences so the build pipeline can generate the correct language-specific versions.
| { | ||
| "group": "LangGraph APIs", | ||
| "pages": [ | ||
| "oss/javascript/langgraph/choosing-apis", |
Copilot
AI
Nov 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file path references a language-specific directory (oss/javascript/langgraph/choosing-apis) but the actual file is located at src/oss/langgraph/choosing-apis.mdx without language-specific subdirectories. According to the build pipeline, files in /oss/langgraph/ with custom language fences are automatically processed to create language-specific outputs at paths like /oss/python/langgraph/ and /oss/javascript/langgraph/. Ensure the source file uses the custom language fences so the build pipeline can generate the correct language-specific versions.
Closes #915