@langchain/langgraph-sdk
Version:
Client library for interacting with the LangGraph API
1 lines • 1.18 kB
Source Map (JSON)
{"version":3,"file":"thread.cjs","names":[],"sources":["../../src/react/thread.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState, useRef, useCallback } from \"react\";\n\nexport const useControllableThreadId = (options?: {\n threadId?: string | null;\n onThreadId?: (threadId: string) => void;\n}): [string | null, (threadId: string) => void] => {\n const [localThreadId, _setLocalThreadId] = useState<string | null>(\n options?.threadId ?? null\n );\n\n const onThreadIdRef = useRef(options?.onThreadId);\n onThreadIdRef.current = options?.onThreadId;\n\n const setThreadId = useCallback((threadId: string) => {\n _setLocalThreadId(threadId);\n onThreadIdRef.current?.(threadId);\n }, []);\n\n if (!options || !(\"threadId\" in options)) {\n return [localThreadId, setThreadId];\n }\n\n return [options.threadId ?? null, setThreadId];\n};\n"],"mappings":";;;;;;AAIA,MAAa,2BAA2B,YAGW;CACjD,MAAM,CAAC,eAAe,yCACpB,SAAS,YAAY,KACtB;CAED,MAAM,kCAAuB,SAAS,WAAW;AACjD,eAAc,UAAU,SAAS;CAEjC,MAAM,sCAA2B,aAAqB;AACpD,oBAAkB,SAAS;AAC3B,gBAAc,UAAU,SAAS;IAChC,EAAE,CAAC;AAEN,KAAI,CAAC,WAAW,EAAE,cAAc,SAC9B,QAAO,CAAC,eAAe,YAAY;AAGrC,QAAO,CAAC,QAAQ,YAAY,MAAM,YAAY"}