@blueking/chat-helper 0.0.12-beta.10 → 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 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: 消息列表如何实现自动滚动到底部?
@@ -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
+ }
@@ -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
- */ /** @deprecated 后端已改为扁平列表 IAgentResourceItem[],不再使用分组结构 */ export { };
25
+ */ /** 后端 llms/ 原始响应项(字段可能缺省) */ export { };
@@ -1,9 +1,9 @@
1
- import { ApprovalInterruptTicketStatus, ResumeStatus, RunFinishedOutcomeType, type IResume } from '../event';
1
+ import { ApprovalInterruptTicketStatus, EventType, ResumeStatus, RunFinishedOutcomeType, type IResume } from '../event';
2
2
  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 | {
@@ -154,7 +198,7 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
154
198
  };
155
199
  runId: number;
156
200
  threadId: string;
157
- type: import("../event").EventType.RunFinished;
201
+ type: EventType.RunFinished;
158
202
  outcome?: {
159
203
  type: RunFinishedOutcomeType.Success;
160
204
  } | {
@@ -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 | {
@@ -1090,7 +1186,7 @@ export declare const useAgent: (mediator: IMediatorModule, protocol: ISSEProtoco
1090
1186
  };
1091
1187
  runId: number;
1092
1188
  threadId: string;
1093
- type: import("../event").EventType.RunFinished;
1189
+ type: EventType.RunFinished;
1094
1190
  outcome?: {
1095
1191
  type: RunFinishedOutcomeType.Success;
1096
1192
  } | {
@@ -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,24 +1989,80 @@ 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
- chat: (userInput: IUserMessage["content"], sessionCode: string, url?: string, config?: IRequestConfig, property?: IMessageProperty) => Promise<void>;
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, }: {
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;
1904
2062
  input?: string;
1905
2063
  lastMessageId?: string;
2064
+ /** 内部静默重连,不重置重连计数 */
2065
+ isReconnect?: boolean;
1906
2066
  }) => Promise<void>;
1907
2067
  };
1908
2068
  export type IAgentModule = ReturnType<typeof useAgent>;