@langgraph-js/sdk 1.1.1 → 1.1.2
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.
|
@@ -26,6 +26,13 @@ export type RenderMessage = Message & {
|
|
|
26
26
|
/** 渲染时的唯一 id,聚合而来*/
|
|
27
27
|
unique_id?: string;
|
|
28
28
|
};
|
|
29
|
+
export type SendMessageOptions = {
|
|
30
|
+
extraParams?: Record<string, any>;
|
|
31
|
+
_debug?: {
|
|
32
|
+
streamResponse?: any;
|
|
33
|
+
};
|
|
34
|
+
command?: Command;
|
|
35
|
+
};
|
|
29
36
|
export interface LangGraphClientConfig {
|
|
30
37
|
apiUrl?: string;
|
|
31
38
|
apiKey?: string;
|
|
@@ -81,13 +88,7 @@ export declare class LangGraphClient extends Client {
|
|
|
81
88
|
run_id: string;
|
|
82
89
|
};
|
|
83
90
|
cancelRun(): void;
|
|
84
|
-
sendMessage(input: string | Message[], { extraParams, _debug, command }?:
|
|
85
|
-
extraParams?: Record<string, any>;
|
|
86
|
-
_debug?: {
|
|
87
|
-
streamResponse?: any;
|
|
88
|
-
};
|
|
89
|
-
command?: Command;
|
|
90
|
-
}): Promise<any[]>;
|
|
91
|
+
sendMessage(input: string | Message[], { extraParams, _debug, command }?: SendMessageOptions): Promise<any[]>;
|
|
91
92
|
private runFETool;
|
|
92
93
|
private callFETool;
|
|
93
94
|
/** 恢复消息,当中断流时使用 */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LangGraphClient, LangGraphClientConfig, RenderMessage } from "../LangGraphClient";
|
|
1
|
+
import { LangGraphClient, LangGraphClientConfig, RenderMessage, SendMessageOptions } from "../LangGraphClient";
|
|
2
2
|
import { Message, Thread } from "@langchain/langgraph-sdk";
|
|
3
3
|
export declare const formatTime: (date: Date) => string;
|
|
4
4
|
export declare const formatTokens: (tokens: number) => string;
|
|
@@ -22,7 +22,7 @@ export declare const createChatStore: (initClientName: string, config: LangGraph
|
|
|
22
22
|
};
|
|
23
23
|
mutations: {
|
|
24
24
|
initClient: () => Promise<void>;
|
|
25
|
-
sendMessage: () => Promise<void>;
|
|
25
|
+
sendMessage: (message?: Message[], extraData?: SendMessageOptions) => Promise<void>;
|
|
26
26
|
interruptMessage: () => void;
|
|
27
27
|
toggleToolCollapse: (toolId: string) => void;
|
|
28
28
|
toggleHistoryVisible: () => void;
|
|
@@ -59,13 +59,13 @@ export const createChatStore = (initClientName, config, context = {}) => {
|
|
|
59
59
|
newClient.graphState = {};
|
|
60
60
|
client.set(newClient);
|
|
61
61
|
};
|
|
62
|
-
const sendMessage = async () => {
|
|
62
|
+
const sendMessage = async (message, extraData) => {
|
|
63
63
|
var _a;
|
|
64
|
-
if (!userInput.get().trim() || loading.get() || !client.get())
|
|
64
|
+
if ((!userInput.get().trim() && !(message === null || message === void 0 ? void 0 : message.length)) || loading.get() || !client.get())
|
|
65
65
|
return;
|
|
66
66
|
loading.set(true);
|
|
67
67
|
inChatError.set(null);
|
|
68
|
-
await ((_a = client.get()) === null || _a === void 0 ? void 0 : _a.sendMessage(userInput.get()));
|
|
68
|
+
await ((_a = client.get()) === null || _a === void 0 ? void 0 : _a.sendMessage(message || userInput.get(), extraData));
|
|
69
69
|
userInput.set("");
|
|
70
70
|
loading.set(false);
|
|
71
71
|
};
|
package/package.json
CHANGED
package/src/LangGraphClient.ts
CHANGED
|
@@ -27,7 +27,11 @@ export type RenderMessage = Message & {
|
|
|
27
27
|
/** 渲染时的唯一 id,聚合而来*/
|
|
28
28
|
unique_id?: string;
|
|
29
29
|
};
|
|
30
|
-
|
|
30
|
+
export type SendMessageOptions = {
|
|
31
|
+
extraParams?: Record<string, any>;
|
|
32
|
+
_debug?: { streamResponse?: any };
|
|
33
|
+
command?: Command;
|
|
34
|
+
};
|
|
31
35
|
export interface LangGraphClientConfig {
|
|
32
36
|
apiUrl?: string;
|
|
33
37
|
apiKey?: string;
|
|
@@ -311,7 +315,7 @@ export class LangGraphClient extends Client {
|
|
|
311
315
|
this.runs.cancel(this.currentThread!.thread_id, this.currentRun.run_id);
|
|
312
316
|
}
|
|
313
317
|
}
|
|
314
|
-
async sendMessage(input: string | Message[], { extraParams, _debug, command }:
|
|
318
|
+
async sendMessage(input: string | Message[], { extraParams, _debug, command }: SendMessageOptions = {}) {
|
|
315
319
|
if (!this.currentAssistant) {
|
|
316
320
|
throw new Error("Thread or Assistant not initialized");
|
|
317
321
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { atom } from "nanostores";
|
|
2
|
-
import { LangGraphClient, LangGraphClientConfig, RenderMessage } from "../LangGraphClient";
|
|
2
|
+
import { LangGraphClient, LangGraphClientConfig, RenderMessage, SendMessageOptions } from "../LangGraphClient";
|
|
3
3
|
import { Message, Thread } from "@langchain/langgraph-sdk";
|
|
4
4
|
export const formatTime = (date: Date) => {
|
|
5
5
|
return date.toLocaleTimeString("en-US");
|
|
@@ -64,13 +64,13 @@ export const createChatStore = (
|
|
|
64
64
|
client.set(newClient);
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
const sendMessage = async () => {
|
|
68
|
-
if (!userInput.get().trim() || loading.get() || !client.get()) return;
|
|
67
|
+
const sendMessage = async (message?: Message[], extraData?: SendMessageOptions) => {
|
|
68
|
+
if ((!userInput.get().trim() && !message?.length) || loading.get() || !client.get()) return;
|
|
69
69
|
|
|
70
70
|
loading.set(true);
|
|
71
71
|
inChatError.set(null);
|
|
72
72
|
|
|
73
|
-
await client.get()?.sendMessage(userInput.get());
|
|
73
|
+
await client.get()?.sendMessage(message || userInput.get(), extraData);
|
|
74
74
|
|
|
75
75
|
userInput.set("");
|
|
76
76
|
loading.set(false);
|