@blueking/chat-helper 0.0.12-beta.11 → 0.0.12-beta.12
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/README.md +8 -2
- package/dist/agent/type.d.ts +69 -0
- package/dist/agent/type.ts.js +1 -1
- package/dist/agent/use-agent.d.ts +165 -7
- package/dist/agent/use-agent.ts.js +50 -11
- package/dist/event/ag-ui.d.ts +2 -0
- package/dist/event/ag-ui.ts.js +35 -3
- package/dist/event/type.d.ts +13 -2
- package/dist/event/type.ts.js +2 -0
- package/dist/http/index.d.ts +2 -0
- package/dist/http/module/agent.d.ts +2 -0
- package/dist/http/module/agent.ts.js +19 -2
- package/dist/http/module/index.d.ts +2 -0
- package/dist/http/module/message.ts.js +2 -2
- package/dist/http/module/session.d.ts +2 -1
- package/dist/http/module/session.ts.js +44 -7
- package/dist/http/transform/agent.d.ts +9 -1
- package/dist/http/transform/agent.ts.js +27 -0
- package/dist/http/transform/message.d.ts +6 -0
- package/dist/http/transform/message.ts.js +56 -0
- package/dist/index.d.ts +791 -6
- package/dist/message/type.d.ts +18 -3
- package/dist/message/type.ts.js +2 -0
- package/dist/message/use-message.d.ts +208 -0
- package/dist/session/type.d.ts +14 -0
- package/dist/session/use-session.d.ts +418 -1
- package/dist/session/use-session.ts.js +5 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1885,13 +1885,19 @@ A: 使用 `agent.chat` 的 `url` 和 `config` 参数:
|
|
|
1885
1885
|
// 使用不同的端点
|
|
1886
1886
|
agent.chat(userInput, sessionCode, 'custom_chat/');
|
|
1887
1887
|
|
|
1888
|
-
//
|
|
1888
|
+
// 添加自定义请求参数(如 temperature)
|
|
1889
1889
|
agent.chat(userInput, sessionCode, undefined, {
|
|
1890
1890
|
data: {
|
|
1891
1891
|
temperature: 0.8,
|
|
1892
|
-
model: 'gpt-4',
|
|
1893
1892
|
},
|
|
1894
1893
|
});
|
|
1894
|
+
|
|
1895
|
+
// 模型热切换:传入第 6 个参数 model(值为 llm_code,需在 GET llms/ 列表内)
|
|
1896
|
+
agent.chat(userInput, sessionCode, undefined, undefined, property, 'hy3-preview');
|
|
1897
|
+
|
|
1898
|
+
// 拉取可用模型列表
|
|
1899
|
+
const llmList = await agent.getLlms({ llm_type: 'chat.completion' });
|
|
1900
|
+
// agent.models 同步更新
|
|
1895
1901
|
```
|
|
1896
1902
|
|
|
1897
1903
|
### Q: 消息列表如何实现自动滚动到底部?
|
package/dist/agent/type.d.ts
CHANGED
|
@@ -126,3 +126,72 @@ export interface IAgentResources {
|
|
|
126
126
|
mcp?: IAgentResourceItem[];
|
|
127
127
|
tool?: IAgentResourceItem[];
|
|
128
128
|
}
|
|
129
|
+
/** 模型能力属性(后端 property 字段) */
|
|
130
|
+
export interface ILlmProperty {
|
|
131
|
+
agent_type?: string;
|
|
132
|
+
default?: boolean;
|
|
133
|
+
is_self_host?: boolean;
|
|
134
|
+
max_model_len?: number;
|
|
135
|
+
support_summary?: boolean;
|
|
136
|
+
support_thinking?: boolean;
|
|
137
|
+
support_thinking_quick?: boolean;
|
|
138
|
+
support_tools?: boolean;
|
|
139
|
+
support_vision?: boolean;
|
|
140
|
+
support_window?: boolean;
|
|
141
|
+
}
|
|
142
|
+
/** 可用模型列表查询参数 */
|
|
143
|
+
export interface ILlmListQuery {
|
|
144
|
+
/** 模糊搜索关键词,按 llm_name / description / base_model 匹配 */
|
|
145
|
+
fuzzy?: string;
|
|
146
|
+
/** 模型类型,不传时默认 chat.completion */
|
|
147
|
+
llm_type?: string;
|
|
148
|
+
/** 按模型支持的功能过滤,逗号分隔,如 tool_call,vision */
|
|
149
|
+
supports?: string;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* 可用模型项(对齐 plugin_api/llms/ 与 chat-x IModelOption)
|
|
153
|
+
* 字段以 snake_case 与后端保持一致,便于直接透传给 ModelSelector
|
|
154
|
+
*/
|
|
155
|
+
export interface ILlmItem {
|
|
156
|
+
/** 基础模型标识,如 hunyuan */
|
|
157
|
+
base_model?: string;
|
|
158
|
+
/** 模型描述 */
|
|
159
|
+
description?: string;
|
|
160
|
+
/** 是否禁用(前端扩展字段) */
|
|
161
|
+
disabled?: boolean;
|
|
162
|
+
/** 模型图标地址 */
|
|
163
|
+
icon?: string;
|
|
164
|
+
/** 模型主键 id */
|
|
165
|
+
id: number;
|
|
166
|
+
/** 模型编码(chat_completion 热切换传此值) */
|
|
167
|
+
llm_code: string;
|
|
168
|
+
/** 模型展示名(ModelSelector v-model 选中值) */
|
|
169
|
+
llm_name: string;
|
|
170
|
+
/** 模型类型,如 chat.completion */
|
|
171
|
+
llm_type: string;
|
|
172
|
+
/** 最大 token 数 */
|
|
173
|
+
max_token_size: number;
|
|
174
|
+
/** 模型能力属性 */
|
|
175
|
+
property: ILlmProperty;
|
|
176
|
+
/** 空间维度鉴权模式 */
|
|
177
|
+
space_auth_mode: string;
|
|
178
|
+
/** 标签名列表 */
|
|
179
|
+
tag_names?: string[];
|
|
180
|
+
/** 用户维度鉴权模式 */
|
|
181
|
+
user_auth_mode: string;
|
|
182
|
+
}
|
|
183
|
+
/** 后端 llms/ 原始响应项(字段可能缺省) */
|
|
184
|
+
export interface ILlmItemApi {
|
|
185
|
+
base_model?: string;
|
|
186
|
+
description?: string;
|
|
187
|
+
icon?: string;
|
|
188
|
+
id?: number;
|
|
189
|
+
llm_code: string;
|
|
190
|
+
llm_name: string;
|
|
191
|
+
llm_type?: string;
|
|
192
|
+
max_token_size?: number;
|
|
193
|
+
property?: ILlmProperty | null;
|
|
194
|
+
space_auth_mode?: string;
|
|
195
|
+
tag_names?: string[];
|
|
196
|
+
user_auth_mode?: string;
|
|
197
|
+
}
|
package/dist/agent/type.ts.js
CHANGED
|
@@ -22,4 +22,4 @@
|
|
|
22
22
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
|
23
23
|
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
24
24
|
* IN THE SOFTWARE.
|
|
25
|
-
*/ /**
|
|
25
|
+
*/ /** 后端 llms/ 原始响应项(字段可能缺省) */ export { };
|
|
@@ -3,7 +3,7 @@ import { MessageRole, MessageStatus, UserOperation } from '../message';
|
|
|
3
3
|
import type { IRequestConfig, ISSEProtocol } from '../http';
|
|
4
4
|
import type { IMediatorModule } from '../mediator';
|
|
5
5
|
import type { IMessageProperty, IUserMessage, IUserOperationPayload } from '../message/type';
|
|
6
|
-
import type { IAgentInfo } from './type';
|
|
6
|
+
import type { IAgentInfo, ILlmItem, ILlmListQuery } from './type';
|
|
7
7
|
/**
|
|
8
8
|
* Agent 模块
|
|
9
9
|
* @param options - 配置选项
|
|
@@ -70,6 +70,17 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
70
70
|
content?: ({
|
|
71
71
|
activityType: import("../message").ActivityType;
|
|
72
72
|
content: {
|
|
73
|
+
artifacts: {
|
|
74
|
+
name: string;
|
|
75
|
+
outputId: string;
|
|
76
|
+
size: number;
|
|
77
|
+
type: string;
|
|
78
|
+
previewUrl?: string;
|
|
79
|
+
url?: string;
|
|
80
|
+
}[];
|
|
81
|
+
runId: string;
|
|
82
|
+
status: "complete" | "empty";
|
|
83
|
+
} | {
|
|
73
84
|
nodes: Record<string, import("../event").IFlowAgentNode>;
|
|
74
85
|
task_id: string;
|
|
75
86
|
task_name: string;
|
|
@@ -87,6 +98,31 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
87
98
|
originFileUrl?: string;
|
|
88
99
|
url: string;
|
|
89
100
|
}[];
|
|
101
|
+
property?: {
|
|
102
|
+
[x: string]: unknown;
|
|
103
|
+
artifacts?: {
|
|
104
|
+
name: string;
|
|
105
|
+
outputId: string;
|
|
106
|
+
size: number;
|
|
107
|
+
type: string;
|
|
108
|
+
previewUrl?: string;
|
|
109
|
+
url?: string;
|
|
110
|
+
}[];
|
|
111
|
+
extra?: {
|
|
112
|
+
[x: string]: unknown;
|
|
113
|
+
cite?: string | {
|
|
114
|
+
data: {
|
|
115
|
+
key: string;
|
|
116
|
+
value: string;
|
|
117
|
+
}[];
|
|
118
|
+
title: string;
|
|
119
|
+
type: string;
|
|
120
|
+
};
|
|
121
|
+
command?: string;
|
|
122
|
+
context?: Array<Record<string, unknown>>;
|
|
123
|
+
resources?: Array<Record<string, unknown>>;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
90
126
|
role: MessageRole.Activity;
|
|
91
127
|
id?: string;
|
|
92
128
|
messageId?: string;
|
|
@@ -97,6 +133,14 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
97
133
|
content?: string;
|
|
98
134
|
property?: {
|
|
99
135
|
[x: string]: unknown;
|
|
136
|
+
artifacts?: {
|
|
137
|
+
name: string;
|
|
138
|
+
outputId: string;
|
|
139
|
+
size: number;
|
|
140
|
+
type: string;
|
|
141
|
+
previewUrl?: string;
|
|
142
|
+
url?: string;
|
|
143
|
+
}[];
|
|
100
144
|
extra?: {
|
|
101
145
|
[x: string]: unknown;
|
|
102
146
|
cite?: string | {
|
|
@@ -920,6 +964,14 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
920
964
|
})[];
|
|
921
965
|
property?: {
|
|
922
966
|
[x: string]: unknown;
|
|
967
|
+
artifacts?: {
|
|
968
|
+
name: string;
|
|
969
|
+
outputId: string;
|
|
970
|
+
size: number;
|
|
971
|
+
type: string;
|
|
972
|
+
previewUrl?: string;
|
|
973
|
+
url?: string;
|
|
974
|
+
}[];
|
|
923
975
|
extra?: {
|
|
924
976
|
[x: string]: unknown;
|
|
925
977
|
cite?: string | {
|
|
@@ -1006,6 +1058,17 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
1006
1058
|
content?: ({
|
|
1007
1059
|
activityType: import("../message").ActivityType;
|
|
1008
1060
|
content: {
|
|
1061
|
+
artifacts: {
|
|
1062
|
+
name: string;
|
|
1063
|
+
outputId: string;
|
|
1064
|
+
size: number;
|
|
1065
|
+
type: string;
|
|
1066
|
+
previewUrl?: string;
|
|
1067
|
+
url?: string;
|
|
1068
|
+
}[];
|
|
1069
|
+
runId: string;
|
|
1070
|
+
status: "complete" | "empty";
|
|
1071
|
+
} | {
|
|
1009
1072
|
nodes: Record<string, import("../event").IFlowAgentNode>;
|
|
1010
1073
|
task_id: string;
|
|
1011
1074
|
task_name: string;
|
|
@@ -1023,6 +1086,31 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
1023
1086
|
originFileUrl?: string;
|
|
1024
1087
|
url: string;
|
|
1025
1088
|
}[];
|
|
1089
|
+
property?: {
|
|
1090
|
+
[x: string]: unknown;
|
|
1091
|
+
artifacts?: {
|
|
1092
|
+
name: string;
|
|
1093
|
+
outputId: string;
|
|
1094
|
+
size: number;
|
|
1095
|
+
type: string;
|
|
1096
|
+
previewUrl?: string;
|
|
1097
|
+
url?: string;
|
|
1098
|
+
}[];
|
|
1099
|
+
extra?: {
|
|
1100
|
+
[x: string]: unknown;
|
|
1101
|
+
cite?: string | {
|
|
1102
|
+
data: {
|
|
1103
|
+
key: string;
|
|
1104
|
+
value: string;
|
|
1105
|
+
}[];
|
|
1106
|
+
title: string;
|
|
1107
|
+
type: string;
|
|
1108
|
+
};
|
|
1109
|
+
command?: string;
|
|
1110
|
+
context?: Array<Record<string, unknown>>;
|
|
1111
|
+
resources?: Array<Record<string, unknown>>;
|
|
1112
|
+
};
|
|
1113
|
+
};
|
|
1026
1114
|
role: MessageRole.Activity;
|
|
1027
1115
|
id?: string;
|
|
1028
1116
|
messageId?: string;
|
|
@@ -1033,6 +1121,14 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
1033
1121
|
content?: string;
|
|
1034
1122
|
property?: {
|
|
1035
1123
|
[x: string]: unknown;
|
|
1124
|
+
artifacts?: {
|
|
1125
|
+
name: string;
|
|
1126
|
+
outputId: string;
|
|
1127
|
+
size: number;
|
|
1128
|
+
type: string;
|
|
1129
|
+
previewUrl?: string;
|
|
1130
|
+
url?: string;
|
|
1131
|
+
}[];
|
|
1036
1132
|
extra?: {
|
|
1037
1133
|
[x: string]: unknown;
|
|
1038
1134
|
cite?: string | {
|
|
@@ -1856,6 +1952,14 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
1856
1952
|
})[];
|
|
1857
1953
|
property?: {
|
|
1858
1954
|
[x: string]: unknown;
|
|
1955
|
+
artifacts?: {
|
|
1956
|
+
name: string;
|
|
1957
|
+
outputId: string;
|
|
1958
|
+
size: number;
|
|
1959
|
+
type: string;
|
|
1960
|
+
previewUrl?: string;
|
|
1961
|
+
url?: string;
|
|
1962
|
+
}[];
|
|
1859
1963
|
extra?: {
|
|
1860
1964
|
[x: string]: unknown;
|
|
1861
1965
|
cite?: string | {
|
|
@@ -1885,19 +1989,73 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
|
|
|
1885
1989
|
}>;
|
|
1886
1990
|
isInfoLoading: import("vue").Ref<boolean, boolean>;
|
|
1887
1991
|
isChatting: import("vue").Ref<boolean, boolean>;
|
|
1888
|
-
|
|
1992
|
+
models: import("vue").Ref<{
|
|
1993
|
+
base_model?: string;
|
|
1994
|
+
description?: string;
|
|
1995
|
+
disabled?: boolean;
|
|
1996
|
+
icon?: string;
|
|
1997
|
+
id: number;
|
|
1998
|
+
llm_code: string;
|
|
1999
|
+
llm_name: string;
|
|
2000
|
+
llm_type: string;
|
|
2001
|
+
max_token_size: number;
|
|
2002
|
+
property: {
|
|
2003
|
+
agent_type?: string;
|
|
2004
|
+
default?: boolean;
|
|
2005
|
+
is_self_host?: boolean;
|
|
2006
|
+
max_model_len?: number;
|
|
2007
|
+
support_summary?: boolean;
|
|
2008
|
+
support_thinking?: boolean;
|
|
2009
|
+
support_thinking_quick?: boolean;
|
|
2010
|
+
support_tools?: boolean;
|
|
2011
|
+
support_vision?: boolean;
|
|
2012
|
+
support_window?: boolean;
|
|
2013
|
+
};
|
|
2014
|
+
space_auth_mode: string;
|
|
2015
|
+
tag_names?: string[];
|
|
2016
|
+
user_auth_mode: string;
|
|
2017
|
+
}[], ILlmItem[] | {
|
|
2018
|
+
base_model?: string;
|
|
2019
|
+
description?: string;
|
|
2020
|
+
disabled?: boolean;
|
|
2021
|
+
icon?: string;
|
|
2022
|
+
id: number;
|
|
2023
|
+
llm_code: string;
|
|
2024
|
+
llm_name: string;
|
|
2025
|
+
llm_type: string;
|
|
2026
|
+
max_token_size: number;
|
|
2027
|
+
property: {
|
|
2028
|
+
agent_type?: string;
|
|
2029
|
+
default?: boolean;
|
|
2030
|
+
is_self_host?: boolean;
|
|
2031
|
+
max_model_len?: number;
|
|
2032
|
+
support_summary?: boolean;
|
|
2033
|
+
support_thinking?: boolean;
|
|
2034
|
+
support_thinking_quick?: boolean;
|
|
2035
|
+
support_tools?: boolean;
|
|
2036
|
+
support_vision?: boolean;
|
|
2037
|
+
support_window?: boolean;
|
|
2038
|
+
};
|
|
2039
|
+
space_auth_mode: string;
|
|
2040
|
+
tag_names?: string[];
|
|
2041
|
+
user_auth_mode: string;
|
|
2042
|
+
}[]>;
|
|
2043
|
+
isModelsLoading: import("vue").Ref<boolean, boolean>;
|
|
2044
|
+
chat: (userInput: IUserMessage["content"], sessionCode: string, url?: string, config?: IRequestConfig, property?: IMessageProperty, model?: string) => Promise<void>;
|
|
1889
2045
|
handleRole: (data: IAgentInfo, sessionCode: string) => void;
|
|
1890
|
-
resendMessage: (messageId: string, sessionCode: string, newContent?: IUserMessage["content"], url?: string, config?: IRequestConfig) => Promise<void>;
|
|
1891
|
-
resumeStreamingChat: (sessionCode: string, url?: string, config?: IRequestConfig) => void;
|
|
2046
|
+
resendMessage: (messageId: string, sessionCode: string, newContent?: IUserMessage["content"], url?: string, config?: IRequestConfig, model?: string) => Promise<void>;
|
|
2047
|
+
resumeStreamingChat: (sessionCode: string, url?: string, config?: IRequestConfig, model?: string) => void;
|
|
1892
2048
|
abortChat: () => void;
|
|
1893
2049
|
stopChat: (sessionCode: string) => Promise<void>;
|
|
1894
2050
|
getAgentInfo: () => Promise<void>;
|
|
2051
|
+
getLlms: (params?: ILlmListQuery, config?: IRequestConfig) => Promise<ILlmItem[]>;
|
|
1895
2052
|
reset: (protocol: ISSEProtocol) => void;
|
|
1896
|
-
pollResumeSession: (sessionCode: string) => void;
|
|
2053
|
+
pollResumeSession: (sessionCode: string, model?: string) => void;
|
|
1897
2054
|
clearLongPollTimer: () => void;
|
|
1898
|
-
userOperationStreamRequest: (sessionCode: string, operation: UserOperation, payload: IUserOperationPayload, config?: IRequestConfig) => Promise<void>;
|
|
1899
|
-
streamRequest: ({ sessionCode, url, config, resume, input, lastMessageId, isReconnect, }: {
|
|
2055
|
+
userOperationStreamRequest: (sessionCode: string, operation: UserOperation, payload: IUserOperationPayload, config?: IRequestConfig, model?: string) => Promise<void>;
|
|
2056
|
+
streamRequest: ({ sessionCode, model, url, config, resume, input, lastMessageId, isReconnect, }: {
|
|
1900
2057
|
sessionCode: string;
|
|
2058
|
+
model?: string;
|
|
1901
2059
|
url?: string;
|
|
1902
2060
|
config?: IRequestConfig;
|
|
1903
2061
|
resume?: IResume;
|
|
@@ -120,6 +120,8 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
120
120
|
const info = ref(null);
|
|
121
121
|
const isInfoLoading = ref(false);
|
|
122
122
|
const isChatting = ref(false);
|
|
123
|
+
const models = ref([]);
|
|
124
|
+
const isModelsLoading = ref(false);
|
|
123
125
|
let usedProtocol = protocol || new AGUIProtocol();
|
|
124
126
|
let chatAbortController = null;
|
|
125
127
|
let resumeAbortController = null;
|
|
@@ -130,6 +132,27 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
130
132
|
let reconnectTimer = null;
|
|
131
133
|
let reconnectWaitResolve = null;
|
|
132
134
|
let activeStreamContext = null;
|
|
135
|
+
/**
|
|
136
|
+
* 获取可用模型列表,写入 models;失败时清空列表并抛出
|
|
137
|
+
*/ const getLlms = (params, config)=>{
|
|
138
|
+
var _mediator_http;
|
|
139
|
+
isModelsLoading.value = true;
|
|
140
|
+
const request = (_mediator_http = mediator.http) === null || _mediator_http === void 0 ? void 0 : _mediator_http.agent.getLlms(params, config);
|
|
141
|
+
if (!request) {
|
|
142
|
+
isModelsLoading.value = false;
|
|
143
|
+
models.value = [];
|
|
144
|
+
return Promise.resolve([]);
|
|
145
|
+
}
|
|
146
|
+
return request.then((res)=>{
|
|
147
|
+
models.value = res;
|
|
148
|
+
return res;
|
|
149
|
+
})['catch']((error)=>{
|
|
150
|
+
models.value = [];
|
|
151
|
+
throw error;
|
|
152
|
+
})['finally'](()=>{
|
|
153
|
+
isModelsLoading.value = false;
|
|
154
|
+
});
|
|
155
|
+
};
|
|
133
156
|
const getAgentInfo = ()=>{
|
|
134
157
|
var _mediator_http;
|
|
135
158
|
isInfoLoading.value = true;
|
|
@@ -158,17 +181,18 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
158
181
|
});
|
|
159
182
|
}
|
|
160
183
|
};
|
|
161
|
-
const userOperationStreamRequest = (sessionCode, operation, payload, config)=>{
|
|
184
|
+
const userOperationStreamRequest = (sessionCode, operation, payload, config, model)=>{
|
|
162
185
|
var _mediator_http;
|
|
163
186
|
return (_mediator_http = mediator.http) === null || _mediator_http === void 0 ? void 0 : _mediator_http.message.userOperation(sessionCode, operation, payload, config).then(()=>{
|
|
164
187
|
if (operation !== UserOperation.ApprovalCancel) {
|
|
165
188
|
streamRequest({
|
|
166
189
|
sessionCode,
|
|
167
|
-
config
|
|
190
|
+
config,
|
|
191
|
+
model
|
|
168
192
|
});
|
|
169
193
|
} else {
|
|
170
194
|
clearLongPollTimer();
|
|
171
|
-
pollResumeSession(sessionCode);
|
|
195
|
+
pollResumeSession(sessionCode, model);
|
|
172
196
|
}
|
|
173
197
|
});
|
|
174
198
|
};
|
|
@@ -259,6 +283,7 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
259
283
|
const ctx = activeStreamContext;
|
|
260
284
|
streamRequest({
|
|
261
285
|
sessionCode,
|
|
286
|
+
model: ctx === null || ctx === void 0 ? void 0 : ctx.model,
|
|
262
287
|
url: ctx === null || ctx === void 0 ? void 0 : ctx.url,
|
|
263
288
|
config: ctx === null || ctx === void 0 ? void 0 : ctx.config,
|
|
264
289
|
lastMessageId: lastMessageId !== undefined ? String(lastMessageId) : undefined,
|
|
@@ -271,13 +296,14 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
271
296
|
};
|
|
272
297
|
}();
|
|
273
298
|
const streamRequest = function() {
|
|
274
|
-
var _ref = _async_to_generator(function*({ sessionCode, url, config, resume, input, lastMessageId, isReconnect = false }) {
|
|
299
|
+
var _ref = _async_to_generator(function*({ sessionCode, model, url, config, resume, input, lastMessageId, isReconnect = false }) {
|
|
275
300
|
var _mediator_http;
|
|
276
301
|
if (!isReconnect) {
|
|
277
302
|
resetStreamReconnectState();
|
|
278
303
|
}
|
|
279
304
|
activeStreamContext = {
|
|
280
305
|
sessionCode,
|
|
306
|
+
model: model,
|
|
281
307
|
url,
|
|
282
308
|
config
|
|
283
309
|
};
|
|
@@ -388,6 +414,7 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
388
414
|
method: 'POST',
|
|
389
415
|
data: {
|
|
390
416
|
session_code: sessionCode,
|
|
417
|
+
model,
|
|
391
418
|
input,
|
|
392
419
|
execute_kwargs: {
|
|
393
420
|
stream: true,
|
|
@@ -416,8 +443,9 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
416
443
|
* @param url - 请求 URL(可选)
|
|
417
444
|
* @param config - 请求配置(可选)
|
|
418
445
|
* @param property - 消息属性,用于传递引用内容或快捷键相关信息(可选)
|
|
446
|
+
* @param model - 模型标识(可选)
|
|
419
447
|
*/ const chat = function() {
|
|
420
|
-
var _ref = _async_to_generator(function*(userInput, sessionCode, url, config, property) {
|
|
448
|
+
var _ref = _async_to_generator(function*(userInput, sessionCode, url, config, property, model) {
|
|
421
449
|
var _mediator_message;
|
|
422
450
|
// 先新增一个 message
|
|
423
451
|
yield (_mediator_message = mediator.message) === null || _mediator_message === void 0 ? void 0 : _mediator_message.createAndPlusMessage(_object_spread({
|
|
@@ -431,11 +459,12 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
431
459
|
// 发起聊天
|
|
432
460
|
streamRequest({
|
|
433
461
|
sessionCode,
|
|
462
|
+
model,
|
|
434
463
|
url,
|
|
435
464
|
config
|
|
436
465
|
});
|
|
437
466
|
});
|
|
438
|
-
return function chat(userInput, sessionCode, url, config, property) {
|
|
467
|
+
return function chat(userInput, sessionCode, url, config, property, model) {
|
|
439
468
|
return _ref.apply(this, arguments);
|
|
440
469
|
};
|
|
441
470
|
}();
|
|
@@ -445,13 +474,15 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
445
474
|
* @param sessionCode - 会话代码
|
|
446
475
|
* @param url - 请求 URL(可选)
|
|
447
476
|
* @param config - 请求配置(可选)
|
|
448
|
-
|
|
477
|
+
* @param model - 模型标识(可选)
|
|
478
|
+
*/ const resumeStreamingChat = (sessionCode, url, config, model)=>{
|
|
449
479
|
var _mediator_session_current_value, _mediator_session;
|
|
450
480
|
if (((_mediator_session = mediator.session) === null || _mediator_session === void 0 ? void 0 : (_mediator_session_current_value = _mediator_session.current.value) === null || _mediator_session_current_value === void 0 ? void 0 : _mediator_session_current_value.status) === SessionStatus.Running) {
|
|
451
481
|
var _mediator_message_list_value_at, _mediator_message;
|
|
452
482
|
const lastMessageId = (_mediator_message = mediator.message) === null || _mediator_message === void 0 ? void 0 : (_mediator_message_list_value_at = _mediator_message.list.value.at(-1)) === null || _mediator_message_list_value_at === void 0 ? void 0 : _mediator_message_list_value_at.id;
|
|
453
483
|
streamRequest({
|
|
454
484
|
sessionCode,
|
|
485
|
+
model,
|
|
455
486
|
url,
|
|
456
487
|
config,
|
|
457
488
|
lastMessageId
|
|
@@ -462,7 +493,7 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
462
493
|
* 轮询接口,判断是否可以继续聊天
|
|
463
494
|
* @param sessionCode - 会话编码
|
|
464
495
|
* @returns 是否可以继续聊天
|
|
465
|
-
*/ const pollResumeSession = (sessionCode)=>{
|
|
496
|
+
*/ const pollResumeSession = (sessionCode, model)=>{
|
|
466
497
|
var _mediator_message, _lastMessage_content_outcome, _lastMessage_content;
|
|
467
498
|
const lastMessage = (_mediator_message = mediator.message) === null || _mediator_message === void 0 ? void 0 : _mediator_message.list.value.at(-1);
|
|
468
499
|
const pendingApprovalInterrupt = (lastMessage === null || lastMessage === void 0 ? void 0 : (_lastMessage_content = lastMessage.content) === null || _lastMessage_content === void 0 ? void 0 : (_lastMessage_content_outcome = _lastMessage_content.outcome) === null || _lastMessage_content_outcome === void 0 ? void 0 : _lastMessage_content_outcome.type) === RunFinishedOutcomeType.Interrupt ? lastMessage.content.outcome.interrupts.find((interrupt)=>{
|
|
@@ -489,6 +520,7 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
489
520
|
// 可以继续聊天,重新发起聊天(携带 execute_kwargs.resume 通知后端恢复中断)
|
|
490
521
|
streamRequest({
|
|
491
522
|
sessionCode,
|
|
523
|
+
model,
|
|
492
524
|
resume: {
|
|
493
525
|
interruptId: pendingApprovalInterrupt.id,
|
|
494
526
|
status: ResumeStatus.Resolved
|
|
@@ -499,7 +531,7 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
499
531
|
var _mediator_session_current_value, _mediator_session_current, _mediator_session;
|
|
500
532
|
// 如果会话不匹配,则不继续轮询
|
|
501
533
|
if (sessionCode !== ((_mediator_session = mediator.session) === null || _mediator_session === void 0 ? void 0 : (_mediator_session_current = _mediator_session.current) === null || _mediator_session_current === void 0 ? void 0 : (_mediator_session_current_value = _mediator_session_current.value) === null || _mediator_session_current_value === void 0 ? void 0 : _mediator_session_current_value.sessionCode)) return;
|
|
502
|
-
pollResumeSession(sessionCode);
|
|
534
|
+
pollResumeSession(sessionCode, model);
|
|
503
535
|
}, 10000);
|
|
504
536
|
}
|
|
505
537
|
});
|
|
@@ -542,8 +574,9 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
542
574
|
* @param newContent - 新内容(可选,不传则使用原消息内容;支持多模态)
|
|
543
575
|
* @param url - 请求 URL(可选)
|
|
544
576
|
* @param config - 请求配置(可选)
|
|
577
|
+
* @param model - 模型标识(可选)
|
|
545
578
|
*/ const resendMessage = function() {
|
|
546
|
-
var _ref = _async_to_generator(function*(messageId, sessionCode, newContent, url, config) {
|
|
579
|
+
var _ref = _async_to_generator(function*(messageId, sessionCode, newContent, url, config, model) {
|
|
547
580
|
var _mediator_message, _mediator_message1, _mediator_message2;
|
|
548
581
|
const messages = ((_mediator_message = mediator.message) === null || _mediator_message === void 0 ? void 0 : _mediator_message.list.value) || [];
|
|
549
582
|
// 1. 找到目标用户消息
|
|
@@ -576,6 +609,7 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
576
609
|
// 6. 立即发起流式请求(不等待删除和创建的 API 完成)
|
|
577
610
|
streamRequest({
|
|
578
611
|
sessionCode,
|
|
612
|
+
model,
|
|
579
613
|
url,
|
|
580
614
|
config
|
|
581
615
|
});
|
|
@@ -587,7 +621,7 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
587
621
|
console.error('[resendMessage] API error:', error);
|
|
588
622
|
});
|
|
589
623
|
});
|
|
590
|
-
return function resendMessage(messageId, sessionCode, newContent, url, config) {
|
|
624
|
+
return function resendMessage(messageId, sessionCode, newContent, url, config, model) {
|
|
591
625
|
return _ref.apply(this, arguments);
|
|
592
626
|
};
|
|
593
627
|
}();
|
|
@@ -598,6 +632,8 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
598
632
|
info.value = null;
|
|
599
633
|
isInfoLoading.value = false;
|
|
600
634
|
isChatting.value = false;
|
|
635
|
+
models.value = [];
|
|
636
|
+
isModelsLoading.value = false;
|
|
601
637
|
activeStreamContext = null;
|
|
602
638
|
reconnectAttempt = 0;
|
|
603
639
|
runFinished = false;
|
|
@@ -606,6 +642,8 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
606
642
|
info,
|
|
607
643
|
isInfoLoading,
|
|
608
644
|
isChatting,
|
|
645
|
+
models,
|
|
646
|
+
isModelsLoading,
|
|
609
647
|
chat,
|
|
610
648
|
handleRole,
|
|
611
649
|
resendMessage,
|
|
@@ -613,6 +651,7 @@ const getReconnectDelayMs = (attempt)=>Math.min(RECONNECT_BASE_DELAY_MS * Math.p
|
|
|
613
651
|
abortChat,
|
|
614
652
|
stopChat,
|
|
615
653
|
getAgentInfo,
|
|
654
|
+
getLlms,
|
|
616
655
|
reset,
|
|
617
656
|
pollResumeSession,
|
|
618
657
|
clearLongPollTimer,
|
package/dist/event/ag-ui.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export declare class AGUIProtocol implements ISSEProtocol {
|
|
|
27
27
|
* 记录活动的完整状态
|
|
28
28
|
*/
|
|
29
29
|
handleActivitySnapshotEvent(event: IActivitySnapshotEvent): void;
|
|
30
|
+
handleArtifactsGeneratedCustomEvent(event: ICustomEvent): void;
|
|
30
31
|
/**
|
|
31
32
|
* 处理自定义事件
|
|
32
33
|
*/
|
|
@@ -51,6 +52,7 @@ export declare class AGUIProtocol implements ISSEProtocol {
|
|
|
51
52
|
* 自定义事件 处理流程编排任务更新
|
|
52
53
|
*/
|
|
53
54
|
handleFlowAgentUpdateCustomEvent(event: ICustomEvent): void;
|
|
55
|
+
handleInfoCustomEvent(event: ICustomEvent): void;
|
|
54
56
|
/**
|
|
55
57
|
* 自定义事件 处理意图识别结束
|
|
56
58
|
*/
|
package/dist/event/ag-ui.ts.js
CHANGED
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
}
|
|
36
36
|
return obj;
|
|
37
37
|
}
|
|
38
|
-
import { transferMessageApi2Message } from '../http/transform/index.ts.js';
|
|
38
|
+
import { mergeArtifactsActivityIntoMessages, transferMessageApi2Message } from '../http/transform/index.ts.js';
|
|
39
39
|
import { ActivityType, MessageRole, MessageStatus, MessageType } from '../message/index.ts.js';
|
|
40
40
|
import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } from './type.ts.js';
|
|
41
41
|
/**
|
|
@@ -50,18 +50,38 @@ import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } fro
|
|
|
50
50
|
* 处理活动快照事件
|
|
51
51
|
* 记录活动的完整状态
|
|
52
52
|
*/ handleActivitySnapshotEvent(event) {
|
|
53
|
-
|
|
53
|
+
if (event.activityType === ActivityType.Info) {
|
|
54
|
+
const message = this.messageModule.getMessageByMessageId(event.messageId);
|
|
55
|
+
if ((message === null || message === void 0 ? void 0 : message.role) === MessageRole.Info) {
|
|
56
|
+
message.content = event.content;
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
54
60
|
if (event.activityType === ActivityType.Interrupt) {
|
|
61
|
+
const message = this.messageModule.getCurrentLoadingMessage();
|
|
55
62
|
if ((message === null || message === void 0 ? void 0 : message.role) === MessageRole.Interrupt) {
|
|
56
63
|
message.content = event.content;
|
|
57
64
|
message.status = MessageStatus.Complete;
|
|
58
65
|
}
|
|
59
66
|
}
|
|
60
67
|
}
|
|
68
|
+
handleArtifactsGeneratedCustomEvent(event) {
|
|
69
|
+
const message = this.messageModule.list.value.findLast((item)=>item.role === MessageRole.Assistant);
|
|
70
|
+
if (message) {
|
|
71
|
+
var _message;
|
|
72
|
+
const value = event.value;
|
|
73
|
+
var _property;
|
|
74
|
+
(_property = (_message = message).property) !== null && _property !== void 0 ? _property : _message.property = {};
|
|
75
|
+
message.property.artifacts = value.artifacts;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
61
78
|
/**
|
|
62
79
|
* 处理自定义事件
|
|
63
80
|
*/ handleCustomEvent(event) {
|
|
64
81
|
switch(event.name){
|
|
82
|
+
case CustomEventName.ArtifactsGenerated:
|
|
83
|
+
this.handleArtifactsGeneratedCustomEvent(event);
|
|
84
|
+
break;
|
|
65
85
|
case CustomEventName.FlowAgentStart:
|
|
66
86
|
this.handleFlowAgentStartCustomEvent(event);
|
|
67
87
|
break;
|
|
@@ -98,6 +118,9 @@ import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } fro
|
|
|
98
118
|
case CustomEventName.FlowAgentUpdate:
|
|
99
119
|
this.handleFlowAgentUpdateCustomEvent(event);
|
|
100
120
|
break;
|
|
121
|
+
case CustomEventName.Info:
|
|
122
|
+
this.handleInfoCustomEvent(event);
|
|
123
|
+
break;
|
|
101
124
|
default:
|
|
102
125
|
break;
|
|
103
126
|
}
|
|
@@ -171,6 +194,15 @@ import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } fro
|
|
|
171
194
|
}
|
|
172
195
|
});
|
|
173
196
|
}
|
|
197
|
+
handleInfoCustomEvent(event) {
|
|
198
|
+
const value = event.value;
|
|
199
|
+
this.messageModule.plusMessage({
|
|
200
|
+
role: MessageRole.Info,
|
|
201
|
+
messageId: value.messageId,
|
|
202
|
+
content: value.content,
|
|
203
|
+
status: MessageStatus.Complete
|
|
204
|
+
});
|
|
205
|
+
}
|
|
174
206
|
/**
|
|
175
207
|
* 自定义事件 处理意图识别结束
|
|
176
208
|
*/ handleKnowledgeRagEndCustomEvent(_event) {
|
|
@@ -214,7 +246,7 @@ import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } fro
|
|
|
214
246
|
* 用于同步多端消息状态
|
|
215
247
|
*/ handleMessagesSnapshotEvent(event) {
|
|
216
248
|
if (event.messages && event.messages.length > 0) {
|
|
217
|
-
this.messageModule.list.value = event.messages.map(transferMessageApi2Message);
|
|
249
|
+
this.messageModule.list.value = mergeArtifactsActivityIntoMessages(event.messages.map(transferMessageApi2Message));
|
|
218
250
|
}
|
|
219
251
|
}
|
|
220
252
|
/**
|