Refactor DeerFlow to use Gateway's LangGraph-compatible API

- Updated documentation and comments to reflect the transition from LangGraph Server to Gateway.
- Changed default URLs in ChannelManager and tests to point to Gateway.
- Removed references to LangGraph Server in deployment scripts and configurations.
- Updated Nginx configuration to route API traffic to Gateway.
- Adjusted frontend configurations to utilize Gateway's API.
- Removed LangGraph service from Docker Compose files, consolidating services under Gateway.
- Added regression tests to ensure Gateway integration works as expected.

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
JeffJiang
2026-04-26 20:38:34 +08:00
parent 653b7ae17a
commit 7bf618de67
20 changed files with 177 additions and 474 deletions
-7
View File
@@ -14,10 +14,3 @@
# Only set these if you need to connect to backend services directly
# NEXT_PUBLIC_BACKEND_BASE_URL="http://localhost:8001"
# NEXT_PUBLIC_LANGGRAPH_BASE_URL="http://localhost:2024"
# LangGraph API base URL
# Default: /api/langgraph (uses langgraph dev server via nginx)
# Set to /api/langgraph-compat to use the experimental Gateway-backed runtime
# Requires: SKIP_LANGGRAPH_SERVER=1 in serve.sh (optional, saves resources)
# NEXT_PUBLIC_LANGGRAPH_BASE_URL=/api/langgraph-compat
+4 -8
View File
@@ -23,10 +23,6 @@ const config = {
devIndicators: false,
async rewrites() {
const rewrites = [];
const langgraphURL = getInternalServiceURL(
"DEER_FLOW_INTERNAL_LANGGRAPH_BASE_URL",
"http://127.0.0.1:2024",
);
const gatewayURL = getInternalServiceURL(
"DEER_FLOW_INTERNAL_GATEWAY_BASE_URL",
"http://127.0.0.1:8001",
@@ -35,11 +31,11 @@ const config = {
if (!process.env.NEXT_PUBLIC_LANGGRAPH_BASE_URL) {
rewrites.push({
source: "/api/langgraph",
destination: langgraphURL,
destination: `${gatewayURL}/api`,
});
rewrites.push({
source: "/api/langgraph/:path*",
destination: `${langgraphURL}/:path*`,
destination: `${gatewayURL}/api/:path*`,
});
}
@@ -66,8 +62,8 @@ const config = {
// their own NEXT_PUBLIC_* env var toggle.
//
// NOTE: this must come AFTER the /api/langgraph rewrite above so that
// LangGraph routes are matched first when NEXT_PUBLIC_LANGGRAPH_BASE_URL
// is unset.
// LangGraph-compatible routes keep their public prefix while Gateway
// receives its native /api/* paths.
rewrites.push({
source: "/api/:path*",
destination: `${gatewayURL}/api/:path*`,
+5 -3
View File
@@ -13,8 +13,8 @@ import { sanitizeRunStreamOptions } from "./stream-mode";
*
* Reading the cookie per-request (rather than baking it into the SDK's
* ``defaultHeaders`` at construction) handles login / logout / password
* change cookie rotation transparently. Both the ``/langgraph-compat/*``
* SDK path and the direct REST endpoints in ``fetcher.ts:fetchWithAuth``
* change cookie rotation transparently. Both the ``/api/langgraph/*`` SDK
* path and the direct REST endpoints in ``fetcher.ts:fetchWithAuth``
* share :func:`readCsrfCookie` and :const:`STATE_CHANGING_METHODS` so
* the contract stays in lockstep.
*/
@@ -32,8 +32,10 @@ function injectCsrfHeader(_url: URL, init: RequestInit): RequestInit {
}
function createCompatibleClient(isMock?: boolean): LangGraphClient {
const apiUrl = getLangGraphBaseURL(isMock);
console.log(`Creating API client with base URL: ${apiUrl}`);
const client = new LangGraphClient({
apiUrl: getLangGraphBaseURL(isMock),
apiUrl,
onRequest: injectCsrfHeader,
});
+4
View File
@@ -19,6 +19,10 @@ export function getBackendBaseURL() {
}
export function getLangGraphBaseURL(isMock?: boolean) {
console.log(
"env.NEXT_PUBLIC_LANGGRAPH_BASE_URL",
env.NEXT_PUBLIC_LANGGRAPH_BASE_URL,
);
if (env.NEXT_PUBLIC_LANGGRAPH_BASE_URL) {
return new URL(
env.NEXT_PUBLIC_LANGGRAPH_BASE_URL,