添加工具调用解析和聊天工具操作处理
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import { create } from "zustand";
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Chat Tool Action Store */
|
||||
/* Decouples chat tool calls from map/panel execution. */
|
||||
/* Chat dispatches actions → map/panel components subscribe & react. */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
export type ChatToolAction =
|
||||
| { type: "locate_nodes"; ids: string[] }
|
||||
| { type: "locate_pipes"; ids: string[] }
|
||||
| {
|
||||
type: "view_history";
|
||||
featureInfos: [string, string][];
|
||||
dataType: "realtime" | "scheme" | "none";
|
||||
startTime?: string;
|
||||
endTime?: string;
|
||||
}
|
||||
| {
|
||||
type: "view_scada";
|
||||
featureInfos: [string, string][];
|
||||
startTime?: string;
|
||||
endTime?: string;
|
||||
}
|
||||
| {
|
||||
type: "show_chart";
|
||||
title?: string;
|
||||
chartType?: "line" | "bar" | "pie";
|
||||
xData?: string[];
|
||||
series?: Array<{ name: string; data: number[]; type?: "line" | "bar" }>;
|
||||
xAxisName?: string;
|
||||
yAxisName?: string;
|
||||
};
|
||||
|
||||
interface ChatToolState {
|
||||
/** Most recent dispatched action (null until first dispatch). */
|
||||
lastAction: ChatToolAction | null;
|
||||
/** Monotonically increasing counter – lets subscribers detect new actions. */
|
||||
actionSeq: number;
|
||||
/** Dispatch a tool action from the chat. */
|
||||
dispatch: (action: ChatToolAction) => void;
|
||||
}
|
||||
|
||||
export const useChatToolStore = create<ChatToolState>((set) => ({
|
||||
lastAction: null,
|
||||
actionSeq: 0,
|
||||
dispatch: (action) =>
|
||||
set((state) => ({
|
||||
lastAction: action,
|
||||
actionSeq: state.actionSeq + 1,
|
||||
})),
|
||||
}));
|
||||
Reference in New Issue
Block a user