How to use @langchain/react

I just use @langchain/react@1.0.1 to develop frontend ,but when i use function submit ,i found that new submit need POST /threads/{threadId}/commands
POST /threads/{threadId}/stream/events

langgraph dev expose :/threads/{thread_id}/stream
/threads/{thread_id}/runs/stream
/threads/{thread_id}/runs/{run_id}/stream
/runs/stream

how could i start agent serve that meet the @langchain/react@1.0.1 locally

hi @whatCanIsay321

what is your @langchain/langgraph-cli version?
Run npm list @langchain/react @langchain/core langchain

I use python to develop my backend .my pip list as follow:
langgraph 1.1.10
langgraph-api 0.7.98
langgraph-checkpoint 4.0.1
langgraph-checkpoint-sqlite 3.0.3
langgraph-cli 0.4.21
langgraph-prebuilt 1.0.13
langgraph-runtime-inmem 0.27.3
langgraph-sdk 0.3.12
langsmith 0.7.32

when i use cmd langgraph dev to open agent serve . I found these interface:post/threads

  • post/threads/search

  • post/threads/count

  • post/threads/prune

  • get/threads/{thread_id}/state

  • post/threads/{thread_id}/state

  • get/threads/{thread_id}/state/{checkpoint_id}

  • post/threads/{thread_id}/state/checkpoint

  • get/threads/{thread_id}/history

  • post/threads/{thread_id}/history

  • post/threads/{thread_id}/copy

  • get/threads/{thread_id}

  • delete/threads/{thread_id}

  • patch/threads/{thread_id}

  • get/threads/{thread_id}/stream

but @langchain/react@1.0.1 submit need agent serve contain

POST /threads/{threadId}/commands
POST /threads/{threadId}/stream/events

hi @whatCanIsay321

If your backend is Python langgraph dev, @langchain/react@1.0.1 is not usable with it yet. The Python Agent Server does not expose POST /threads/{thread_id}/commands or POST /threads/{thread_id}/stream/events.

Use the legacy SDK hook instead:

npm install @langchain/langgraph-sdk
import { useStream } from "@langchain/langgraph-sdk/react";

const stream = useStream({
  apiUrl: "http://localhost:2024",
  assistantId: "agent",
});

Only use @langchain/react@1.x today if you serve the agent with the JS/TS @langchain/langgraph-api>=1.2.0 server. Do not try to fix this with paths - the protocols differ, not just the URLs.

okay! thank u :saluting_face:

hi @whatCanIsay321

let me know if it solves your problem :slight_smile: If so, please mark it solve for the other so they can make use of it. Thanks in advance :slight_smile: