@langgraph-js/sdk 4.3.5 → 4.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LangGraphClient.js +1 -1
- package/dist/react/ChatContext.d.ts +1 -0
- package/dist/react/ChatContext.js +5 -4
- package/dist/solid/ChatContext.d.ts +1 -0
- package/dist/solid/ChatContext.js +9 -6
- package/dist/vue/ChatContext.d.ts +10 -0
- package/dist/vue/ChatContext.js +7 -2
- package/package.json +1 -1
- package/src/LangGraphClient.ts +1 -1
- package/src/react/ChatContext.ts +6 -3
- package/src/solid/ChatContext.ts +7 -5
- package/src/vue/ChatContext.ts +8 -2
package/dist/LangGraphClient.js
CHANGED
|
@@ -390,7 +390,7 @@ export class LangGraphClient extends EventEmitter {
|
|
|
390
390
|
additional_kwargs: {},
|
|
391
391
|
};
|
|
392
392
|
// json 校验
|
|
393
|
-
return this.callFETool(toolMessage, tool.args);
|
|
393
|
+
return this.callFETool(toolMessage, tool.args).catch((e) => console.warn(e));
|
|
394
394
|
});
|
|
395
395
|
console.log("batch call tools", result.length);
|
|
396
396
|
// 只有当卡住流程时,才改变状态为 interrupted
|
|
@@ -9,7 +9,7 @@ export const useChat = () => {
|
|
|
9
9
|
}
|
|
10
10
|
return context;
|
|
11
11
|
};
|
|
12
|
-
export const ChatProvider = ({ children, defaultAgent = "", apiUrl = "http://localhost:8123", defaultHeaders, withCredentials = false, showHistory = false, showGraph = false, fallbackToAvailableAssistants = false, autoRestoreLastSession = false, onInitError, client, legacyMode = false, }) => {
|
|
12
|
+
export const ChatProvider = ({ children, defaultAgent = "", apiUrl = "http://localhost:8123", defaultHeaders, withCredentials = false, fetch, showHistory = false, showGraph = false, fallbackToAvailableAssistants = false, autoRestoreLastSession = false, onInitError, client, legacyMode = false, }) => {
|
|
13
13
|
// 使用 useMemo 稳定 defaultHeaders 的引用
|
|
14
14
|
const stableHeaders = useMemo(() => defaultHeaders || {}, [defaultHeaders]);
|
|
15
15
|
// 使用 useRef 保存 onInitError 的最新引用
|
|
@@ -18,12 +18,13 @@ export const ChatProvider = ({ children, defaultAgent = "", apiUrl = "http://loc
|
|
|
18
18
|
onInitErrorRef.current = onInitError;
|
|
19
19
|
}, [onInitError]);
|
|
20
20
|
const store = useMemo(() => {
|
|
21
|
+
const baseFetch = fetch || globalThis.fetch;
|
|
21
22
|
const F = withCredentials
|
|
22
23
|
? (url, options) => {
|
|
23
24
|
options.credentials = "include";
|
|
24
|
-
return
|
|
25
|
+
return baseFetch(url, options);
|
|
25
26
|
}
|
|
26
|
-
:
|
|
27
|
+
: baseFetch;
|
|
27
28
|
const config = {
|
|
28
29
|
apiUrl,
|
|
29
30
|
defaultHeaders: stableHeaders,
|
|
@@ -42,7 +43,7 @@ export const ChatProvider = ({ children, defaultAgent = "", apiUrl = "http://loc
|
|
|
42
43
|
fallbackToAvailableAssistants,
|
|
43
44
|
autoRestoreLastSession,
|
|
44
45
|
});
|
|
45
|
-
}, [defaultAgent, apiUrl, stableHeaders, withCredentials, showHistory, showGraph, fallbackToAvailableAssistants, autoRestoreLastSession]);
|
|
46
|
+
}, [defaultAgent, apiUrl, stableHeaders, withCredentials, fetch, showHistory, showGraph, fallbackToAvailableAssistants, autoRestoreLastSession]);
|
|
46
47
|
const unionStore = useUnionStore(store, useStore);
|
|
47
48
|
// 使用 ref 标记是否已初始化
|
|
48
49
|
const initializedRef = useRef(false);
|
|
@@ -26,12 +26,15 @@ export const ChatProvider = (props) => {
|
|
|
26
26
|
// 使用 createMemo 稳定 defaultHeaders 的引用
|
|
27
27
|
const stableHeaders = createMemo(() => props.defaultHeaders || {});
|
|
28
28
|
// 使用 createMemo 创建 fetch 函数
|
|
29
|
-
const F = createMemo(() =>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
const F = createMemo(() => {
|
|
30
|
+
const baseFetch = props.fetch || globalThis.fetch;
|
|
31
|
+
return props.withCredentials
|
|
32
|
+
? (url, options) => {
|
|
33
|
+
options.credentials = "include";
|
|
34
|
+
return baseFetch(url, options);
|
|
35
|
+
}
|
|
36
|
+
: baseFetch;
|
|
37
|
+
});
|
|
35
38
|
const store = createMemo(() => {
|
|
36
39
|
const config = {
|
|
37
40
|
apiUrl: props.apiUrl || "http://localhost:8123",
|
|
@@ -30,6 +30,7 @@ export interface ChatProviderProps {
|
|
|
30
30
|
apiUrl?: string;
|
|
31
31
|
defaultHeaders?: Record<string, string>;
|
|
32
32
|
withCredentials?: boolean;
|
|
33
|
+
fetch?: typeof fetch;
|
|
33
34
|
showHistory?: boolean;
|
|
34
35
|
showGraph?: boolean;
|
|
35
36
|
fallbackToAvailableAssistants?: boolean;
|
|
@@ -129,6 +130,10 @@ export declare const ChatProvider: import("vue").DefineComponent<import("vue").E
|
|
|
129
130
|
type: PropType<boolean>;
|
|
130
131
|
default: boolean;
|
|
131
132
|
};
|
|
133
|
+
fetch: {
|
|
134
|
+
type: PropType<typeof fetch>;
|
|
135
|
+
default: undefined;
|
|
136
|
+
};
|
|
132
137
|
showHistory: {
|
|
133
138
|
type: PropType<boolean>;
|
|
134
139
|
default: boolean;
|
|
@@ -164,6 +169,10 @@ export declare const ChatProvider: import("vue").DefineComponent<import("vue").E
|
|
|
164
169
|
type: PropType<boolean>;
|
|
165
170
|
default: boolean;
|
|
166
171
|
};
|
|
172
|
+
fetch: {
|
|
173
|
+
type: PropType<typeof fetch>;
|
|
174
|
+
default: undefined;
|
|
175
|
+
};
|
|
167
176
|
showHistory: {
|
|
168
177
|
type: PropType<boolean>;
|
|
169
178
|
default: boolean;
|
|
@@ -187,6 +196,7 @@ export declare const ChatProvider: import("vue").DefineComponent<import("vue").E
|
|
|
187
196
|
showHistory: boolean;
|
|
188
197
|
defaultAgent: string;
|
|
189
198
|
withCredentials: boolean;
|
|
199
|
+
fetch: typeof fetch;
|
|
190
200
|
autoRestoreLastSession: boolean;
|
|
191
201
|
onInitError: (error: any, currentAgent: string) => void;
|
|
192
202
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
package/dist/vue/ChatContext.js
CHANGED
|
@@ -32,12 +32,13 @@ export const useChat = () => {
|
|
|
32
32
|
* @en Chat Provider Hook, used directly in setup
|
|
33
33
|
*/
|
|
34
34
|
export const useChatProvider = (props) => {
|
|
35
|
+
const baseFetch = props.fetch || globalThis.fetch;
|
|
35
36
|
const F = props.withCredentials
|
|
36
37
|
? (url, options) => {
|
|
37
38
|
options.credentials = "include";
|
|
38
|
-
return
|
|
39
|
+
return baseFetch(url, options);
|
|
39
40
|
}
|
|
40
|
-
:
|
|
41
|
+
: baseFetch;
|
|
41
42
|
const store = createChatStore(props.defaultAgent || "", {
|
|
42
43
|
apiUrl: props.apiUrl,
|
|
43
44
|
defaultHeaders: props.defaultHeaders,
|
|
@@ -92,6 +93,10 @@ export const ChatProvider = defineComponent({
|
|
|
92
93
|
type: Boolean,
|
|
93
94
|
default: false,
|
|
94
95
|
},
|
|
96
|
+
fetch: {
|
|
97
|
+
type: Function,
|
|
98
|
+
default: undefined,
|
|
99
|
+
},
|
|
95
100
|
showHistory: {
|
|
96
101
|
type: Boolean,
|
|
97
102
|
default: false,
|
package/package.json
CHANGED
package/src/LangGraphClient.ts
CHANGED
|
@@ -510,7 +510,7 @@ export class LangGraphClient<TStateType = unknown> extends EventEmitter<LangGrap
|
|
|
510
510
|
additional_kwargs: {},
|
|
511
511
|
};
|
|
512
512
|
// json 校验
|
|
513
|
-
return this.callFETool(toolMessage, tool.args);
|
|
513
|
+
return this.callFETool(toolMessage, tool.args).catch((e) => console.warn(e));
|
|
514
514
|
});
|
|
515
515
|
console.log("batch call tools", result.length);
|
|
516
516
|
// 只有当卡住流程时,才改变状态为 interrupted
|
package/src/react/ChatContext.ts
CHANGED
|
@@ -20,6 +20,7 @@ interface ChatProviderProps {
|
|
|
20
20
|
apiUrl?: string;
|
|
21
21
|
defaultHeaders?: Record<string, string>;
|
|
22
22
|
withCredentials?: boolean;
|
|
23
|
+
fetch?: typeof fetch;
|
|
23
24
|
showHistory?: boolean;
|
|
24
25
|
showGraph?: boolean;
|
|
25
26
|
fallbackToAvailableAssistants?: boolean;
|
|
@@ -36,6 +37,7 @@ export const ChatProvider: React.FC<ChatProviderProps> = ({
|
|
|
36
37
|
apiUrl = "http://localhost:8123",
|
|
37
38
|
defaultHeaders,
|
|
38
39
|
withCredentials = false,
|
|
40
|
+
fetch,
|
|
39
41
|
showHistory = false,
|
|
40
42
|
showGraph = false,
|
|
41
43
|
fallbackToAvailableAssistants = false,
|
|
@@ -54,12 +56,13 @@ export const ChatProvider: React.FC<ChatProviderProps> = ({
|
|
|
54
56
|
}, [onInitError]);
|
|
55
57
|
|
|
56
58
|
const store = useMemo(() => {
|
|
59
|
+
const baseFetch = fetch || globalThis.fetch;
|
|
57
60
|
const F = withCredentials
|
|
58
61
|
? (url: string, options: RequestInit) => {
|
|
59
62
|
options.credentials = "include";
|
|
60
|
-
return
|
|
63
|
+
return baseFetch(url, options);
|
|
61
64
|
}
|
|
62
|
-
:
|
|
65
|
+
: baseFetch;
|
|
63
66
|
|
|
64
67
|
const config = {
|
|
65
68
|
apiUrl,
|
|
@@ -78,7 +81,7 @@ export const ChatProvider: React.FC<ChatProviderProps> = ({
|
|
|
78
81
|
fallbackToAvailableAssistants,
|
|
79
82
|
autoRestoreLastSession,
|
|
80
83
|
});
|
|
81
|
-
}, [defaultAgent, apiUrl, stableHeaders, withCredentials, showHistory, showGraph, fallbackToAvailableAssistants, autoRestoreLastSession]);
|
|
84
|
+
}, [defaultAgent, apiUrl, stableHeaders, withCredentials, fetch, showHistory, showGraph, fallbackToAvailableAssistants, autoRestoreLastSession]);
|
|
82
85
|
|
|
83
86
|
const unionStore = useUnionStore(store, useStore);
|
|
84
87
|
|
package/src/solid/ChatContext.ts
CHANGED
|
@@ -20,6 +20,7 @@ interface ChatProviderProps {
|
|
|
20
20
|
apiUrl?: string;
|
|
21
21
|
defaultHeaders?: Record<string, string>;
|
|
22
22
|
withCredentials?: boolean;
|
|
23
|
+
fetch?: typeof fetch;
|
|
23
24
|
showHistory?: boolean;
|
|
24
25
|
showGraph?: boolean;
|
|
25
26
|
fallbackToAvailableAssistants?: boolean;
|
|
@@ -62,14 +63,15 @@ export const ChatProvider = (props: ChatProviderProps) => {
|
|
|
62
63
|
const stableHeaders = createMemo(() => props.defaultHeaders || {});
|
|
63
64
|
|
|
64
65
|
// 使用 createMemo 创建 fetch 函数
|
|
65
|
-
const F = createMemo(() =>
|
|
66
|
-
props.
|
|
66
|
+
const F = createMemo(() => {
|
|
67
|
+
const baseFetch = props.fetch || globalThis.fetch;
|
|
68
|
+
return props.withCredentials
|
|
67
69
|
? (url: string, options: RequestInit) => {
|
|
68
70
|
options.credentials = "include";
|
|
69
|
-
return
|
|
71
|
+
return baseFetch(url, options);
|
|
70
72
|
}
|
|
71
|
-
:
|
|
72
|
-
);
|
|
73
|
+
: baseFetch;
|
|
74
|
+
});
|
|
73
75
|
|
|
74
76
|
const store = createMemo(() => {
|
|
75
77
|
const config = {
|
package/src/vue/ChatContext.ts
CHANGED
|
@@ -52,6 +52,7 @@ export interface ChatProviderProps {
|
|
|
52
52
|
apiUrl?: string;
|
|
53
53
|
defaultHeaders?: Record<string, string>;
|
|
54
54
|
withCredentials?: boolean;
|
|
55
|
+
fetch?: typeof fetch;
|
|
55
56
|
showHistory?: boolean;
|
|
56
57
|
showGraph?: boolean;
|
|
57
58
|
fallbackToAvailableAssistants?: boolean;
|
|
@@ -67,12 +68,13 @@ export interface ChatProviderProps {
|
|
|
67
68
|
* @en Chat Provider Hook, used directly in setup
|
|
68
69
|
*/
|
|
69
70
|
export const useChatProvider = (props: ChatProviderProps) => {
|
|
71
|
+
const baseFetch = props.fetch || globalThis.fetch;
|
|
70
72
|
const F = props.withCredentials
|
|
71
73
|
? (url: string, options: RequestInit) => {
|
|
72
74
|
options.credentials = "include";
|
|
73
|
-
return
|
|
75
|
+
return baseFetch(url, options);
|
|
74
76
|
}
|
|
75
|
-
:
|
|
77
|
+
: baseFetch;
|
|
76
78
|
|
|
77
79
|
const store = createChatStore(
|
|
78
80
|
props.defaultAgent || "",
|
|
@@ -137,6 +139,10 @@ export const ChatProvider = defineComponent({
|
|
|
137
139
|
type: Boolean as PropType<boolean>,
|
|
138
140
|
default: false,
|
|
139
141
|
},
|
|
142
|
+
fetch: {
|
|
143
|
+
type: Function as PropType<typeof fetch>,
|
|
144
|
+
default: undefined,
|
|
145
|
+
},
|
|
140
146
|
showHistory: {
|
|
141
147
|
type: Boolean as PropType<boolean>,
|
|
142
148
|
default: false,
|