@blueking/chat-helper 0.0.12-beta.9 → 0.0.13-dev.1
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 +21 -7
- package/dist/agent/type.d.ts +82 -0
- package/dist/agent/type.ts.js +5 -1
- package/dist/agent/use-agent.d.ts +229 -10
- package/dist/agent/use-agent.ts.js +365 -25
- package/dist/event/ag-ui.d.ts +4 -1
- package/dist/event/ag-ui.ts.js +76 -6
- package/dist/event/type.d.ts +14 -2
- package/dist/event/type.ts.js +2 -0
- package/dist/http/fetch/fetch.spec.d.ts +1 -0
- package/dist/http/fetch/fetch.ts.js +106 -22
- package/dist/http/index.d.ts +11 -5
- 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 +11 -5
- package/dist/http/module/message.d.ts +1 -1
- package/dist/http/module/message.ts.js +4 -3
- package/dist/http/module/session.d.ts +10 -5
- package/dist/http/module/session.ts.js +60 -3
- package/dist/http/transform/agent.d.ts +9 -1
- package/dist/http/transform/agent.spec.d.ts +1 -0
- package/dist/http/transform/agent.ts.js +29 -0
- package/dist/http/transform/message.spec.d.ts +1 -0
- package/dist/http/transform/message.ts.js +19 -5
- package/dist/index.d.ts +1194 -16
- package/dist/message/type.d.ts +35 -3
- package/dist/message/type.ts.js +16 -0
- package/dist/message/use-message.d.ts +316 -0
- package/dist/session/index.d.ts +1 -0
- package/dist/session/index.ts.js +2 -1
- package/dist/session/pv-file-upload.d.ts +7 -0
- package/dist/session/pv-file-upload.spec.d.ts +1 -0
- package/dist/session/pv-file-upload.ts.js +64 -0
- package/dist/session/type.d.ts +57 -0
- package/dist/session/use-session.d.ts +644 -6
- package/dist/session/use-session.spec.d.ts +1 -0
- package/dist/session/use-session.ts.js +117 -10
- package/package.json +4 -2
package/dist/event/ag-ui.ts.js
CHANGED
|
@@ -35,9 +35,24 @@
|
|
|
35
35
|
}
|
|
36
36
|
return obj;
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
function _object_spread(target) {
|
|
39
|
+
for(var i = 1; i < arguments.length; i++){
|
|
40
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
41
|
+
var ownKeys = Object.keys(source);
|
|
42
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
43
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
44
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
ownKeys.forEach(function(key) {
|
|
48
|
+
_define_property(target, key, source[key]);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return target;
|
|
52
|
+
}
|
|
53
|
+
import { ActivityType, MessageRole, MessageStatus, MessageType, formatEventTimestampToCreatedAt } from '../message/index.ts.js';
|
|
40
54
|
import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } from './type.ts.js';
|
|
55
|
+
import { transferMessageApi2Message } from '../http/transform/index.ts.js';
|
|
41
56
|
/**
|
|
42
57
|
* AGUI 协议
|
|
43
58
|
* @param message - 消息模块
|
|
@@ -50,18 +65,38 @@ import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } fro
|
|
|
50
65
|
* 处理活动快照事件
|
|
51
66
|
* 记录活动的完整状态
|
|
52
67
|
*/ handleActivitySnapshotEvent(event) {
|
|
53
|
-
|
|
68
|
+
if (event.activityType === ActivityType.Info) {
|
|
69
|
+
const message = this.messageModule.getMessageByMessageId(event.messageId);
|
|
70
|
+
if ((message === null || message === void 0 ? void 0 : message.role) === MessageRole.Info) {
|
|
71
|
+
message.content = event.content;
|
|
72
|
+
}
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
54
75
|
if (event.activityType === ActivityType.Interrupt) {
|
|
76
|
+
const message = this.messageModule.getCurrentLoadingMessage();
|
|
55
77
|
if ((message === null || message === void 0 ? void 0 : message.role) === MessageRole.Interrupt) {
|
|
56
78
|
message.content = event.content;
|
|
57
79
|
message.status = MessageStatus.Complete;
|
|
58
80
|
}
|
|
59
81
|
}
|
|
60
82
|
}
|
|
83
|
+
handleArtifactsGeneratedCustomEvent(event) {
|
|
84
|
+
const message = this.messageModule.list.value.findLast((item)=>item.role === MessageRole.Assistant);
|
|
85
|
+
if (message) {
|
|
86
|
+
var _message;
|
|
87
|
+
const value = event.value;
|
|
88
|
+
var _property;
|
|
89
|
+
(_property = (_message = message).property) !== null && _property !== void 0 ? _property : _message.property = {};
|
|
90
|
+
message.property.artifacts = value.artifacts;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
61
93
|
/**
|
|
62
94
|
* 处理自定义事件
|
|
63
95
|
*/ handleCustomEvent(event) {
|
|
64
96
|
switch(event.name){
|
|
97
|
+
case CustomEventName.ArtifactsGenerated:
|
|
98
|
+
this.handleArtifactsGeneratedCustomEvent(event);
|
|
99
|
+
break;
|
|
65
100
|
case CustomEventName.FlowAgentStart:
|
|
66
101
|
this.handleFlowAgentStartCustomEvent(event);
|
|
67
102
|
break;
|
|
@@ -98,6 +133,9 @@ import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } fro
|
|
|
98
133
|
case CustomEventName.FlowAgentUpdate:
|
|
99
134
|
this.handleFlowAgentUpdateCustomEvent(event);
|
|
100
135
|
break;
|
|
136
|
+
case CustomEventName.Info:
|
|
137
|
+
this.handleInfoCustomEvent(event);
|
|
138
|
+
break;
|
|
101
139
|
default:
|
|
102
140
|
break;
|
|
103
141
|
}
|
|
@@ -171,6 +209,15 @@ import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } fro
|
|
|
171
209
|
}
|
|
172
210
|
});
|
|
173
211
|
}
|
|
212
|
+
handleInfoCustomEvent(event) {
|
|
213
|
+
const value = event.value;
|
|
214
|
+
this.messageModule.plusMessage({
|
|
215
|
+
role: MessageRole.Info,
|
|
216
|
+
messageId: value.messageId,
|
|
217
|
+
content: value.content,
|
|
218
|
+
status: MessageStatus.Complete
|
|
219
|
+
});
|
|
220
|
+
}
|
|
174
221
|
/**
|
|
175
222
|
* 自定义事件 处理意图识别结束
|
|
176
223
|
*/ handleKnowledgeRagEndCustomEvent(_event) {
|
|
@@ -211,7 +258,7 @@ import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } fro
|
|
|
211
258
|
}
|
|
212
259
|
/**
|
|
213
260
|
* 处理消息快照事件
|
|
214
|
-
*
|
|
261
|
+
* 用于同步多端消息状态;chat_completion 首帧会全量返回历史消息(含 created_at)
|
|
215
262
|
*/ handleMessagesSnapshotEvent(event) {
|
|
216
263
|
if (event.messages && event.messages.length > 0) {
|
|
217
264
|
this.messageModule.list.value = event.messages.map(transferMessageApi2Message);
|
|
@@ -253,17 +300,24 @@ import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } fro
|
|
|
253
300
|
* 处理运行完成事件
|
|
254
301
|
*/ handleRunFinishedEvent(event) {
|
|
255
302
|
var _event_outcome, _event_outcome1;
|
|
303
|
+
const createdAt = formatEventTimestampToCreatedAt(event.timestamp);
|
|
256
304
|
const message = this.messageModule.getCurrentLoadingMessage();
|
|
257
305
|
if (message) {
|
|
258
306
|
message.status = MessageStatus.Complete;
|
|
259
307
|
}
|
|
308
|
+
// 本轮流式消息在落库前没有 createdAt,用 RUN_FINISHED.timestamp 转成 ISO 后补上;已有时间的历史消息不覆盖
|
|
309
|
+
if (createdAt) {
|
|
310
|
+
applyCreatedAtToCurrentRun(this.messageModule.list.value, createdAt);
|
|
311
|
+
}
|
|
260
312
|
// 如果是中断消息,则创建一个中断消息
|
|
261
313
|
if (((_event_outcome = event.outcome) === null || _event_outcome === void 0 ? void 0 : _event_outcome.type) === RunFinishedOutcomeType.Interrupt) {
|
|
262
|
-
this.messageModule.plusMessage({
|
|
314
|
+
this.messageModule.plusMessage(_object_spread({
|
|
263
315
|
role: MessageRole.Interrupt,
|
|
264
316
|
content: event,
|
|
265
317
|
status: MessageStatus.Pending
|
|
266
|
-
}
|
|
318
|
+
}, createdAt ? {
|
|
319
|
+
createdAt
|
|
320
|
+
} : {}));
|
|
267
321
|
}
|
|
268
322
|
// 二次返回,直接更新消息内容
|
|
269
323
|
if (((_event_outcome1 = event.outcome) === null || _event_outcome1 === void 0 ? void 0 : _event_outcome1.type) === RunFinishedOutcomeType.Success && (message === null || message === void 0 ? void 0 : message.role) === MessageRole.Interrupt) {
|
|
@@ -349,7 +403,14 @@ import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } fro
|
|
|
349
403
|
}
|
|
350
404
|
/**
|
|
351
405
|
* 处理文本消息开始事件
|
|
406
|
+
* 断线续传时会重放缓存事件:同 messageId 已存在则重置内容,避免重复气泡/文本翻倍
|
|
352
407
|
*/ handleTextMessageStartEvent(event) {
|
|
408
|
+
const existing = this.messageModule.getMessageByMessageId(event.messageId);
|
|
409
|
+
if (existing) {
|
|
410
|
+
existing.content = '';
|
|
411
|
+
existing.status = MessageStatus.Streaming;
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
353
414
|
this.messageModule.plusMessage({
|
|
354
415
|
role: event.role,
|
|
355
416
|
content: '',
|
|
@@ -580,3 +641,12 @@ import { CustomEventName, EventType, FlowTaskState, RunFinishedOutcomeType } fro
|
|
|
580
641
|
this.onStartCallback = params === null || params === void 0 ? void 0 : params.onStart;
|
|
581
642
|
}
|
|
582
643
|
}
|
|
644
|
+
/** 从列表尾部向前,给本轮尚未带时间的消息补 createdAt,遇到已有时间的历史消息即停 */ function applyCreatedAtToCurrentRun(messages, createdAt) {
|
|
645
|
+
for(let index = messages.length - 1; index >= 0; index--){
|
|
646
|
+
const item = messages[index];
|
|
647
|
+
if (item.createdAt) {
|
|
648
|
+
break;
|
|
649
|
+
}
|
|
650
|
+
item.createdAt = createdAt;
|
|
651
|
+
}
|
|
652
|
+
}
|
package/dist/event/type.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { type IMessageApi, type MessageRole, type MessageStatus } from '../message/type';
|
|
1
|
+
import { type IMessageApi, type IMessageArtifact, type MessageRole, type MessageStatus } from '../message/type';
|
|
2
2
|
import type { JSONSchema4 } from 'json-schema';
|
|
3
3
|
export declare enum CustomEventName {
|
|
4
|
+
ArtifactsGenerated = "artifacts_generated",
|
|
4
5
|
FlowAgentEnd = "flow_agent_end",
|
|
5
6
|
FlowAgentResult = "flow_agent_result",
|
|
6
7
|
FlowAgentStart = "flow_agent_start",
|
|
7
8
|
FlowAgentUpdate = "flow_agent_update",
|
|
8
9
|
FlowAgentRestart = "flow_agent_restart",
|
|
10
|
+
Info = "info",
|
|
9
11
|
KnowledgeRagEnd = "knowledge_rag_end",
|
|
10
12
|
KnowledgeRagResult = "knowledge_rag_result",
|
|
11
13
|
KnowledgeRagStart = "knowledge_rag_start",
|
|
@@ -114,7 +116,13 @@ export interface IActivitySnapshotEvent extends IBaseEvent {
|
|
|
114
116
|
replace?: boolean;
|
|
115
117
|
type: EventType.ActivitySnapshot;
|
|
116
118
|
}
|
|
119
|
+
export interface IArtifactsGeneratedCustomValue {
|
|
120
|
+
artifacts: IMessageArtifact[];
|
|
121
|
+
runId: string;
|
|
122
|
+
status: 'complete' | 'empty';
|
|
123
|
+
}
|
|
117
124
|
export interface IBaseEvent {
|
|
125
|
+
/** 事件时间,毫秒时间戳;RUN_FINISHED 会转成 ISO 字符串写入消息 createdAt */
|
|
118
126
|
timestamp?: number;
|
|
119
127
|
type: EventType;
|
|
120
128
|
}
|
|
@@ -125,7 +133,7 @@ export interface IBaseEvent {
|
|
|
125
133
|
export interface ICustomEvent extends IBaseEvent {
|
|
126
134
|
name: CustomEventName;
|
|
127
135
|
type: EventType.Custom;
|
|
128
|
-
value: IFlowAgentEndCustomValue | IFlowAgentResultCustomValue | IFlowAgentStartCustomValue | IFlowAgentRestartCustomValue | IKnowledgeRagResultCustomValue | IKnowledgeRagTextContentCustomValue | IReferenceDocumentCustomValue | ITempMessageCustomValue | IApprovalResultCustomValue;
|
|
136
|
+
value: IArtifactsGeneratedCustomValue | IFlowAgentEndCustomValue | IFlowAgentResultCustomValue | IFlowAgentStartCustomValue | IFlowAgentRestartCustomValue | IInfoCustomValue | IKnowledgeRagResultCustomValue | IKnowledgeRagTextContentCustomValue | IReferenceDocumentCustomValue | ITempMessageCustomValue | IApprovalResultCustomValue;
|
|
129
137
|
}
|
|
130
138
|
export type IEvent = IActivityDeltaEvent | IActivitySnapshotEvent | ICustomEvent | IMessagesSnapshotEvent | IRawEvent | IRunErrorEvent | IRunFinishedEvent | IRunStartedEvent | IStateDeltaEvent | IStateSnapshotEvent | IStepFinishedEvent | IStepStartedEvent | ITextMessageChunkEvent | ITextMessageContentEvent | ITextMessageEndEvent | ITextMessageStartEvent | IThinkingEndEvent | IThinkingStartEvent | IThinkingTextMessageContentEvent | IThinkingTextMessageEndEvent | IThinkingTextMessageStartEvent | IToolCallArgsEvent | IToolCallChunkEvent | IToolCallEndEvent | IToolCallResultEvent | IToolCallStartEvent;
|
|
131
139
|
export type IFlowAgentEndCustomValue = {
|
|
@@ -152,6 +160,10 @@ export type IFlowAgentStartCustomValue = {
|
|
|
152
160
|
task_id: string;
|
|
153
161
|
}[];
|
|
154
162
|
export type IFlowAgentRestartCustomValue = IFlowAgentStartCustomValue;
|
|
163
|
+
export interface IInfoCustomValue {
|
|
164
|
+
content: string;
|
|
165
|
+
messageId: string;
|
|
166
|
+
}
|
|
155
167
|
export type IKnowledgeRagResultCustomValue = IReferenceDocumentCustomValue;
|
|
156
168
|
export interface IKnowledgeRagTextContentCustomValue {
|
|
157
169
|
cover: boolean;
|
package/dist/event/type.ts.js
CHANGED
|
@@ -24,11 +24,13 @@
|
|
|
24
24
|
* IN THE SOFTWARE.
|
|
25
25
|
*/ export var CustomEventName;
|
|
26
26
|
(function(CustomEventName) {
|
|
27
|
+
CustomEventName["ArtifactsGenerated"] = "artifacts_generated";
|
|
27
28
|
CustomEventName["FlowAgentEnd"] = "flow_agent_end";
|
|
28
29
|
CustomEventName["FlowAgentResult"] = "flow_agent_result";
|
|
29
30
|
CustomEventName["FlowAgentStart"] = "flow_agent_start";
|
|
30
31
|
CustomEventName["FlowAgentUpdate"] = "flow_agent_update";
|
|
31
32
|
CustomEventName["FlowAgentRestart"] = "flow_agent_restart";
|
|
33
|
+
CustomEventName["Info"] = "info";
|
|
32
34
|
CustomEventName["KnowledgeRagEnd"] = "knowledge_rag_end";
|
|
33
35
|
CustomEventName["KnowledgeRagResult"] = "knowledge_rag_result";
|
|
34
36
|
CustomEventName["KnowledgeRagStart"] = "knowledge_rag_start";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -240,6 +240,10 @@ export class FetchClient {
|
|
|
240
240
|
if (isStream && !headers.has('Accept')) {
|
|
241
241
|
headers.set('Accept', 'text/event-stream');
|
|
242
242
|
}
|
|
243
|
+
// multipart 必须由浏览器带 boundary;默认 application/json 会破坏 FormData
|
|
244
|
+
if (body instanceof FormData) {
|
|
245
|
+
headers.delete('Content-Type');
|
|
246
|
+
}
|
|
243
247
|
if (body !== undefined && body !== null) {
|
|
244
248
|
var _headers_get;
|
|
245
249
|
if (requestConfig.transformRequest) {
|
|
@@ -276,7 +280,12 @@ export class FetchClient {
|
|
|
276
280
|
var _this = this;
|
|
277
281
|
return _async_to_generator(function*() {
|
|
278
282
|
const { url, fetchConfig, requestConfig, controller } = _this.prepareRequest(config);
|
|
279
|
-
|
|
283
|
+
// 超时与用户主动取消共用同一个 AbortController,需靠此标记区分
|
|
284
|
+
let timedOut = false;
|
|
285
|
+
const timeoutId = requestConfig.timeout && requestConfig.timeout > 0 ? setTimeout(()=>{
|
|
286
|
+
timedOut = true;
|
|
287
|
+
controller.abort();
|
|
288
|
+
}, requestConfig.timeout) : undefined;
|
|
280
289
|
try {
|
|
281
290
|
const fetchResponse = yield fetch(url, fetchConfig);
|
|
282
291
|
if (timeoutId) {
|
|
@@ -319,9 +328,8 @@ export class FetchClient {
|
|
|
319
328
|
};
|
|
320
329
|
const validateStatus = requestConfig.validateStatus || _this.defaults.validateStatus;
|
|
321
330
|
if (!validateStatus(fetchResponse.status)) {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
throw createError(message, requestConfig, `ERR_BAD_RESPONSE`, response);
|
|
331
|
+
const { code, message } = resolveErrorPayload(response.data, `Request failed with status code ${fetchResponse.status}`);
|
|
332
|
+
throw createError(message, requestConfig, code, response);
|
|
325
333
|
}
|
|
326
334
|
let finalResponse = response;
|
|
327
335
|
_this.interceptors.response.forEach((interceptor)=>{
|
|
@@ -341,23 +349,28 @@ export class FetchClient {
|
|
|
341
349
|
}
|
|
342
350
|
// 检查业务状态码(区别于 HTTP 状态码)
|
|
343
351
|
const apiResponse = finalResponse.data;
|
|
352
|
+
// 无响应体(如 204 或空 body)时没有业务码可校验,直接放行
|
|
353
|
+
if (!apiResponse) {
|
|
354
|
+
return undefined;
|
|
355
|
+
}
|
|
344
356
|
if (![
|
|
345
357
|
0,
|
|
346
358
|
'success'
|
|
347
359
|
].includes(apiResponse.code)) {
|
|
348
|
-
|
|
360
|
+
const { code, message } = resolveErrorPayload(apiResponse, `Request failed with code ${apiResponse.code}`);
|
|
361
|
+
throw createError(message, requestConfig, code, finalResponse);
|
|
349
362
|
}
|
|
350
363
|
return apiResponse.data;
|
|
351
364
|
} catch (error) {
|
|
352
365
|
if (timeoutId) {
|
|
353
366
|
clearTimeout(timeoutId);
|
|
354
367
|
}
|
|
355
|
-
//
|
|
356
|
-
if (error instanceof Error && error.name === 'AbortError') {
|
|
368
|
+
// 用户手动取消请求;超时同样表现为 AbortError,需作为异常上报
|
|
369
|
+
if (error instanceof Error && error.name === 'AbortError' && !timedOut) {
|
|
357
370
|
console.warn('User canceled request', error.message);
|
|
358
371
|
return;
|
|
359
372
|
}
|
|
360
|
-
const requestError = error.isAxiosError === true ? error : createError(error.message, requestConfig, error.code, undefined);
|
|
373
|
+
const requestError = timedOut ? createError(`timeout of ${requestConfig.timeout}ms exceeded`, requestConfig, 'ECONNABORTED', undefined) : error.isAxiosError === true ? error : createError(error.message, requestConfig, error.code, undefined);
|
|
361
374
|
_this.dispatchError(requestError);
|
|
362
375
|
throw _this.applyResponseErrorInterceptors(requestError);
|
|
363
376
|
}
|
|
@@ -390,33 +403,44 @@ export class FetchClient {
|
|
|
390
403
|
const wrappedConfig = _object_spread_props(_object_spread({}, config), {
|
|
391
404
|
onError: wrappedOnError
|
|
392
405
|
});
|
|
393
|
-
const { url, fetchConfig, requestConfig } = _this.prepareRequest(wrappedConfig, true);
|
|
406
|
+
const { url, fetchConfig, requestConfig, controller } = _this.prepareRequest(wrappedConfig, true);
|
|
407
|
+
let reader;
|
|
408
|
+
const cancelReaderOnAbort = ()=>{
|
|
409
|
+
// pipeThrough(TextDecoderStream) 后,仅 abort fetch signal 在部分环境下不会立刻打断 reader.read()
|
|
410
|
+
void (reader === null || reader === void 0 ? void 0 : reader.cancel().catch(()=>{}));
|
|
411
|
+
};
|
|
394
412
|
try {
|
|
395
413
|
var _wrappedConfig_onStart, _fetchResponse_body;
|
|
396
414
|
const fetchResponse = yield fetch(url, fetchConfig);
|
|
397
415
|
const validateStatus = requestConfig.validateStatus || _this.defaults.validateStatus;
|
|
398
416
|
if (!validateStatus(fetchResponse.status)) {
|
|
399
|
-
let
|
|
417
|
+
let errorData = null;
|
|
400
418
|
try {
|
|
401
|
-
|
|
402
|
-
const errorData = yield fetchResponse.json();
|
|
403
|
-
if (errorData === null || errorData === void 0 ? void 0 : (_errorData_error = errorData.error) === null || _errorData_error === void 0 ? void 0 : _errorData_error.message) {
|
|
404
|
-
message = errorData.error.message;
|
|
405
|
-
}
|
|
419
|
+
errorData = yield fetchResponse.json();
|
|
406
420
|
} catch (_error) {
|
|
407
|
-
|
|
421
|
+
errorData = null;
|
|
408
422
|
}
|
|
409
|
-
const
|
|
423
|
+
const { code, message } = resolveErrorPayload(errorData, `Request failed with status code ${fetchResponse.status}`);
|
|
424
|
+
const error = createError(message, requestConfig, code, undefined);
|
|
410
425
|
wrappedOnError(error);
|
|
411
426
|
return;
|
|
412
427
|
}
|
|
413
428
|
(_wrappedConfig_onStart = wrappedConfig.onStart) === null || _wrappedConfig_onStart === void 0 ? void 0 : _wrappedConfig_onStart.call(wrappedConfig);
|
|
414
|
-
|
|
429
|
+
reader = (_fetchResponse_body = fetchResponse.body) === null || _fetchResponse_body === void 0 ? void 0 : _fetchResponse_body.pipeThrough(new window.TextDecoderStream()).getReader();
|
|
415
430
|
if (!reader) {
|
|
416
431
|
const error = new Error('IResponse body is not readable');
|
|
417
432
|
wrappedOnError(error);
|
|
418
433
|
return;
|
|
419
434
|
}
|
|
435
|
+
controller.signal.addEventListener('abort', cancelReaderOnAbort, {
|
|
436
|
+
once: true
|
|
437
|
+
});
|
|
438
|
+
if (controller.signal.aborted) {
|
|
439
|
+
var _wrappedConfig_onDone;
|
|
440
|
+
cancelReaderOnAbort();
|
|
441
|
+
(_wrappedConfig_onDone = wrappedConfig.onDone) === null || _wrappedConfig_onDone === void 0 ? void 0 : _wrappedConfig_onDone.call(wrappedConfig);
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
420
444
|
// 缓存跨行分片数据
|
|
421
445
|
let temp = '';
|
|
422
446
|
const isJson = (str)=>{
|
|
@@ -431,8 +455,8 @@ export class FetchClient {
|
|
|
431
455
|
while(true){
|
|
432
456
|
const { value, done } = yield reader.read();
|
|
433
457
|
if (done) {
|
|
434
|
-
var
|
|
435
|
-
(
|
|
458
|
+
var _wrappedConfig_onDone1;
|
|
459
|
+
(_wrappedConfig_onDone1 = wrappedConfig.onDone) === null || _wrappedConfig_onDone1 === void 0 ? void 0 : _wrappedConfig_onDone1.call(wrappedConfig);
|
|
436
460
|
break;
|
|
437
461
|
}
|
|
438
462
|
const values = (temp + value.toString()).split('\n');
|
|
@@ -451,13 +475,15 @@ export class FetchClient {
|
|
|
451
475
|
} catch (error) {
|
|
452
476
|
if (error instanceof Error) {
|
|
453
477
|
if (error.name === 'AbortError') {
|
|
454
|
-
var
|
|
455
|
-
(
|
|
478
|
+
var _wrappedConfig_onDone2;
|
|
479
|
+
(_wrappedConfig_onDone2 = wrappedConfig.onDone) === null || _wrappedConfig_onDone2 === void 0 ? void 0 : _wrappedConfig_onDone2.call(wrappedConfig);
|
|
456
480
|
return;
|
|
457
481
|
}
|
|
458
482
|
wrappedOnError(error);
|
|
459
483
|
}
|
|
460
484
|
throw error;
|
|
485
|
+
} finally{
|
|
486
|
+
controller.signal.removeEventListener('abort', cancelReaderOnAbort);
|
|
461
487
|
}
|
|
462
488
|
})();
|
|
463
489
|
}
|
|
@@ -503,6 +529,64 @@ function buildURL(url, params) {
|
|
|
503
529
|
}
|
|
504
530
|
return url;
|
|
505
531
|
}
|
|
532
|
+
/**
|
|
533
|
+
* 从错误响应体中解析业务错误信息
|
|
534
|
+
*
|
|
535
|
+
* 后端错误体存在多种形态,需逐一兼容:
|
|
536
|
+
* - 新版网关 / aidev 插件:`{ error: { code, message, data } }`
|
|
537
|
+
* - 旧版蓝鲸标准(如 blueapps 登录态失效):`{ result, code, message, data }`
|
|
538
|
+
* - DRF 原生异常:`{ detail }`
|
|
539
|
+
*/ function resolveErrorPayload(body, fallbackMessage) {
|
|
540
|
+
var _record_error;
|
|
541
|
+
const fallbackCode = 'ERR_BAD_RESPONSE';
|
|
542
|
+
if (!body || typeof body !== 'object') {
|
|
543
|
+
return {
|
|
544
|
+
code: fallbackCode,
|
|
545
|
+
message: fallbackMessage
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
const record = body;
|
|
549
|
+
if ((_record_error = record.error) === null || _record_error === void 0 ? void 0 : _record_error.message) {
|
|
550
|
+
var _record_error_code;
|
|
551
|
+
return {
|
|
552
|
+
code: (_record_error_code = record.error.code) !== null && _record_error_code !== void 0 ? _record_error_code : fallbackCode,
|
|
553
|
+
data: record.error.data,
|
|
554
|
+
message: stringifyErrorMessage(record.error.message, fallbackMessage)
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
if (record.message) {
|
|
558
|
+
var _record_code;
|
|
559
|
+
return {
|
|
560
|
+
code: (_record_code = record.code) !== null && _record_code !== void 0 ? _record_code : fallbackCode,
|
|
561
|
+
data: record.data,
|
|
562
|
+
message: stringifyErrorMessage(record.message, fallbackMessage)
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
if (record.detail) {
|
|
566
|
+
var _record_code1;
|
|
567
|
+
return {
|
|
568
|
+
code: (_record_code1 = record.code) !== null && _record_code1 !== void 0 ? _record_code1 : fallbackCode,
|
|
569
|
+
data: record.data,
|
|
570
|
+
message: stringifyErrorMessage(record.detail, fallbackMessage)
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
var _record_code2;
|
|
574
|
+
return {
|
|
575
|
+
code: (_record_code2 = record.code) !== null && _record_code2 !== void 0 ? _record_code2 : fallbackCode,
|
|
576
|
+
data: record.data,
|
|
577
|
+
message: fallbackMessage
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
/** 错误 message 可能是字符串以外的结构(如字段校验字典),统一转成可读文案 */ function stringifyErrorMessage(message, fallbackMessage) {
|
|
581
|
+
if (typeof message === 'string') {
|
|
582
|
+
return message || fallbackMessage;
|
|
583
|
+
}
|
|
584
|
+
try {
|
|
585
|
+
return JSON.stringify(message) || fallbackMessage;
|
|
586
|
+
} catch (_error) {
|
|
587
|
+
return fallbackMessage;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
506
590
|
function createError(message, config, code, response) {
|
|
507
591
|
const error = new Error(message);
|
|
508
592
|
error.config = config;
|
package/dist/http/index.d.ts
CHANGED
|
@@ -12,10 +12,16 @@ export declare const useHttp: (options: IUseChatHelperOptions) => {
|
|
|
12
12
|
onError: (handler: import("./fetch").GlobalErrorHandler, options?: import("./fetch").ErrorHandlerOptions) => void;
|
|
13
13
|
agent: {
|
|
14
14
|
getAgentInfo: (config?: import("./fetch").IRequestConfig) => Promise<import("..").IAgentInfo>;
|
|
15
|
+
getLlms: (params?: import("..").ILlmListQuery, config?: import("./fetch").IRequestConfig) => Promise<import("..").ILlmItem[]>;
|
|
15
16
|
};
|
|
16
17
|
session: {
|
|
17
18
|
clearSession: (sessionCode: string, config?: import("./fetch").IRequestConfig) => Promise<unknown>;
|
|
18
|
-
getSessions: (config?: import("./fetch").IRequestConfig) => Promise<
|
|
19
|
+
getSessions: (params?: import("..").ISessionListParams, config?: import("./fetch").IRequestConfig) => Promise<{
|
|
20
|
+
page: number;
|
|
21
|
+
numPages: number;
|
|
22
|
+
count: number;
|
|
23
|
+
results: import("..").ISession<unknown, unknown>[];
|
|
24
|
+
}>;
|
|
19
25
|
plusSession: (data: import("..").ISession, config?: import("./fetch").IRequestConfig) => Promise<import("..").ISession<unknown, unknown>>;
|
|
20
26
|
modifySession: (data: import("..").ISession, config?: import("./fetch").IRequestConfig) => Promise<import("..").ISession<unknown, unknown>>;
|
|
21
27
|
deleteSession: (sessionCode: string, config?: import("./fetch").IRequestConfig) => Promise<unknown>;
|
|
@@ -30,13 +36,13 @@ export declare const useHttp: (options: IUseChatHelperOptions) => {
|
|
|
30
36
|
}>;
|
|
31
37
|
getSessionFeedbackReasons: (rate: number, config?: import("./fetch").IRequestConfig) => Promise<string[]>;
|
|
32
38
|
renameSession: (sessionCode: string, config?: import("./fetch").IRequestConfig) => Promise<import("..").ISession<unknown, unknown>>;
|
|
33
|
-
uploadFile: (sessionCode: string, file: File, config?: import("./fetch").IRequestConfig) => Promise<
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
uploadFile: (sessionCode: string, file: File, config?: import("./fetch").IRequestConfig) => Promise<import("..").ILegacyUploadFileResult>;
|
|
40
|
+
uploadPvFiles: (sessionCode: string, files: File[], config?: import("./fetch").IRequestConfig) => Promise<import("..").IPvFileUploadResult>;
|
|
41
|
+
getPvFileDownloadUrl: (sessionCode: string, path: string, options?: import("..").GetPvFileDownloadUrlOptions, config?: import("./fetch").IRequestConfig) => Promise<import("..").IPvFileDownloadUrlResult>;
|
|
36
42
|
isResumeSession: (sessionCode: string, config?: import("./fetch").IRequestConfig) => Promise<boolean>;
|
|
37
43
|
};
|
|
38
44
|
message: {
|
|
39
|
-
getMessages: (sessionCode: string, limit?: number, config?: import("./fetch").IRequestConfig) => Promise<import("..").IMessage[]>;
|
|
45
|
+
getMessages: (sessionCode: string, limit?: number, config?: import("./fetch").IRequestConfig, fuzzy?: string) => Promise<import("..").IMessage[]>;
|
|
40
46
|
plusMessage: (data: import("..").IMessage, config?: import("./fetch").IRequestConfig) => Promise<import("..").IActivityMessage | import("..").IAssistantMessage | import("..").IDeveloperMessage | import("..").IInterruptMessage | import("..").IGuideMessage | import("..").IHiddenAssistantMessage | import("..").IHiddenGuideMessage | import("..").IHiddenMessage | import("..").IHiddenSystemMessage | import("..").IHiddenUserMessage | import("..").IInfoMessage | import("..").IPauseMessage | import("..").IPlaceholderMessage | import("..").IReasoningMessage | import("..").ISystemMessage | import("..").ITemplateAssistantMessage | import("..").ITemplateGuideMessage | import("..").ITemplateHiddenMessage | import("..").ITemplateSystemMessage | import("..").ITemplateUserMessage | import("..").IToolMessage | import("..").IUserMessage>;
|
|
41
47
|
modifyMessage: (data: import("..").IMessage, config?: import("./fetch").IRequestConfig) => Promise<import("..").IActivityMessage | import("..").IAssistantMessage | import("..").IDeveloperMessage | import("..").IInterruptMessage | import("..").IGuideMessage | import("..").IHiddenAssistantMessage | import("..").IHiddenGuideMessage | import("..").IHiddenMessage | import("..").IHiddenSystemMessage | import("..").IHiddenUserMessage | import("..").IInfoMessage | import("..").IPauseMessage | import("..").IPlaceholderMessage | import("..").IReasoningMessage | import("..").ISystemMessage | import("..").ITemplateAssistantMessage | import("..").ITemplateGuideMessage | import("..").ITemplateHiddenMessage | import("..").ITemplateSystemMessage | import("..").ITemplateUserMessage | import("..").IToolMessage | import("..").IUserMessage>;
|
|
42
48
|
deleteMessage: (id: string, config?: import("./fetch").IRequestConfig) => Promise<import("..").IMessage>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ILlmItem, ILlmListQuery } from '../../agent/type';
|
|
1
2
|
import type { FetchClient, IRequestConfig } from '../fetch';
|
|
2
3
|
/**
|
|
3
4
|
* agent 相关 http 接口
|
|
@@ -6,4 +7,5 @@ import type { FetchClient, IRequestConfig } from '../fetch';
|
|
|
6
7
|
*/
|
|
7
8
|
export declare const useAgent: (fetchClient: FetchClient) => {
|
|
8
9
|
getAgentInfo: (config?: IRequestConfig) => Promise<import("../../agent/type").IAgentInfo>;
|
|
10
|
+
getLlms: (params?: ILlmListQuery, config?: IRequestConfig) => Promise<ILlmItem[]>;
|
|
9
11
|
};
|
|
@@ -22,7 +22,7 @@
|
|
|
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
|
-
*/ import { transferAgentInfoApi2AgentInfo } from '../transform/agent.ts.js';
|
|
25
|
+
*/ import { transferAgentInfoApi2AgentInfo, transferLlmListApi2LlmItems } from '../transform/agent.ts.js';
|
|
26
26
|
/**
|
|
27
27
|
* agent 相关 http 接口
|
|
28
28
|
* @param fetchClient - 请求客户端
|
|
@@ -30,7 +30,24 @@
|
|
|
30
30
|
*/ export const useAgent = (fetchClient)=>{
|
|
31
31
|
// 获取 agent 信息
|
|
32
32
|
const getAgentInfo = (config)=>fetchClient.get('agent/info/', undefined, config).then(transferAgentInfoApi2AgentInfo);
|
|
33
|
+
/**
|
|
34
|
+
* 获取当前空间可用模型列表(公开 + 空间授权 + 用户权限交集)
|
|
35
|
+
* @param params 查询参数;未传 llm_type 时默认 chat.completion
|
|
36
|
+
*/ const getLlms = (params, config)=>{
|
|
37
|
+
var _params_llm_type;
|
|
38
|
+
const query = {
|
|
39
|
+
llm_type: (_params_llm_type = params === null || params === void 0 ? void 0 : params.llm_type) !== null && _params_llm_type !== void 0 ? _params_llm_type : 'chat.completion'
|
|
40
|
+
};
|
|
41
|
+
if (params === null || params === void 0 ? void 0 : params.fuzzy) {
|
|
42
|
+
query.fuzzy = params.fuzzy;
|
|
43
|
+
}
|
|
44
|
+
if (params === null || params === void 0 ? void 0 : params.supports) {
|
|
45
|
+
query.supports = params.supports;
|
|
46
|
+
}
|
|
47
|
+
return fetchClient.get('llms/', query, config).then(transferLlmListApi2LlmItems);
|
|
48
|
+
};
|
|
33
49
|
return {
|
|
34
|
-
getAgentInfo
|
|
50
|
+
getAgentInfo,
|
|
51
|
+
getLlms
|
|
35
52
|
};
|
|
36
53
|
};
|
|
@@ -7,10 +7,16 @@ import type { FetchClient } from '../fetch';
|
|
|
7
7
|
export declare const useModule: (fetchClient: FetchClient) => {
|
|
8
8
|
agent: {
|
|
9
9
|
getAgentInfo: (config?: import("../fetch").IRequestConfig) => Promise<import("../..").IAgentInfo>;
|
|
10
|
+
getLlms: (params?: import("../..").ILlmListQuery, config?: import("../fetch").IRequestConfig) => Promise<import("../..").ILlmItem[]>;
|
|
10
11
|
};
|
|
11
12
|
session: {
|
|
12
13
|
clearSession: (sessionCode: string, config?: import("../fetch").IRequestConfig) => Promise<unknown>;
|
|
13
|
-
getSessions: (config?: import("../fetch").IRequestConfig) => Promise<
|
|
14
|
+
getSessions: (params?: import("../..").ISessionListParams, config?: import("../fetch").IRequestConfig) => Promise<{
|
|
15
|
+
page: number;
|
|
16
|
+
numPages: number;
|
|
17
|
+
count: number;
|
|
18
|
+
results: import("../..").ISession<unknown, unknown>[];
|
|
19
|
+
}>;
|
|
14
20
|
plusSession: (data: import("../..").ISession, config?: import("../fetch").IRequestConfig) => Promise<import("../..").ISession<unknown, unknown>>;
|
|
15
21
|
modifySession: (data: import("../..").ISession, config?: import("../fetch").IRequestConfig) => Promise<import("../..").ISession<unknown, unknown>>;
|
|
16
22
|
deleteSession: (sessionCode: string, config?: import("../fetch").IRequestConfig) => Promise<unknown>;
|
|
@@ -25,13 +31,13 @@ export declare const useModule: (fetchClient: FetchClient) => {
|
|
|
25
31
|
}>;
|
|
26
32
|
getSessionFeedbackReasons: (rate: number, config?: import("../fetch").IRequestConfig) => Promise<string[]>;
|
|
27
33
|
renameSession: (sessionCode: string, config?: import("../fetch").IRequestConfig) => Promise<import("../..").ISession<unknown, unknown>>;
|
|
28
|
-
uploadFile: (sessionCode: string, file: File, config?: import("../fetch").IRequestConfig) => Promise<
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
uploadFile: (sessionCode: string, file: File, config?: import("../fetch").IRequestConfig) => Promise<import("../..").ILegacyUploadFileResult>;
|
|
35
|
+
uploadPvFiles: (sessionCode: string, files: File[], config?: import("../fetch").IRequestConfig) => Promise<import("../..").IPvFileUploadResult>;
|
|
36
|
+
getPvFileDownloadUrl: (sessionCode: string, path: string, options?: import("../..").GetPvFileDownloadUrlOptions, config?: import("../fetch").IRequestConfig) => Promise<import("../..").IPvFileDownloadUrlResult>;
|
|
31
37
|
isResumeSession: (sessionCode: string, config?: import("../fetch").IRequestConfig) => Promise<boolean>;
|
|
32
38
|
};
|
|
33
39
|
message: {
|
|
34
|
-
getMessages: (sessionCode: string, limit?: number, config?: import("../fetch").IRequestConfig) => Promise<import("../..").IMessage[]>;
|
|
40
|
+
getMessages: (sessionCode: string, limit?: number, config?: import("../fetch").IRequestConfig, fuzzy?: string) => Promise<import("../..").IMessage[]>;
|
|
35
41
|
plusMessage: (data: import("../..").IMessage, config?: import("../fetch").IRequestConfig) => Promise<import("../..").IActivityMessage | import("../..").IAssistantMessage | import("../..").IDeveloperMessage | import("../..").IInterruptMessage | import("../..").IGuideMessage | import("../..").IHiddenAssistantMessage | import("../..").IHiddenGuideMessage | import("../..").IHiddenMessage | import("../..").IHiddenSystemMessage | import("../..").IHiddenUserMessage | import("../..").IInfoMessage | import("../..").IPauseMessage | import("../..").IPlaceholderMessage | import("../..").IReasoningMessage | import("../..").ISystemMessage | import("../..").ITemplateAssistantMessage | import("../..").ITemplateGuideMessage | import("../..").ITemplateHiddenMessage | import("../..").ITemplateSystemMessage | import("../..").ITemplateUserMessage | import("../..").IToolMessage | import("../..").IUserMessage>;
|
|
36
42
|
modifyMessage: (data: import("../..").IMessage, config?: import("../fetch").IRequestConfig) => Promise<import("../..").IActivityMessage | import("../..").IAssistantMessage | import("../..").IDeveloperMessage | import("../..").IInterruptMessage | import("../..").IGuideMessage | import("../..").IHiddenAssistantMessage | import("../..").IHiddenGuideMessage | import("../..").IHiddenMessage | import("../..").IHiddenSystemMessage | import("../..").IHiddenUserMessage | import("../..").IInfoMessage | import("../..").IPauseMessage | import("../..").IPlaceholderMessage | import("../..").IReasoningMessage | import("../..").ISystemMessage | import("../..").ITemplateAssistantMessage | import("../..").ITemplateGuideMessage | import("../..").ITemplateHiddenMessage | import("../..").ITemplateSystemMessage | import("../..").ITemplateUserMessage | import("../..").IToolMessage | import("../..").IUserMessage>;
|
|
37
43
|
deleteMessage: (id: string, config?: import("../fetch").IRequestConfig) => Promise<import("../..").IMessage>;
|
|
@@ -19,7 +19,7 @@ export interface IShareMessagesResponse {
|
|
|
19
19
|
* @returns message 相关 http 接口
|
|
20
20
|
*/
|
|
21
21
|
export declare const useMessage: (fetchClient: FetchClient) => {
|
|
22
|
-
getMessages: (sessionCode: string, limit?: number, config?: IRequestConfig) => Promise<IMessage[]>;
|
|
22
|
+
getMessages: (sessionCode: string, limit?: number, config?: IRequestConfig, fuzzy?: string) => Promise<IMessage[]>;
|
|
23
23
|
plusMessage: (data: IMessage, config?: IRequestConfig) => Promise<import("../../message/type").IActivityMessage | import("../../message/type").IAssistantMessage | import("../../message/type").IDeveloperMessage | import("../../message/type").IInterruptMessage | import("../../message/type").IGuideMessage | import("../../message/type").IHiddenAssistantMessage | import("../../message/type").IHiddenGuideMessage | import("../../message/type").IHiddenMessage | import("../../message/type").IHiddenSystemMessage | import("../../message/type").IHiddenUserMessage | import("../../message/type").IInfoMessage | import("../../message/type").IPauseMessage | import("../../message/type").IPlaceholderMessage | import("../../message/type").IReasoningMessage | import("../../message/type").ISystemMessage | import("../../message/type").ITemplateAssistantMessage | import("../../message/type").ITemplateGuideMessage | import("../../message/type").ITemplateHiddenMessage | import("../../message/type").ITemplateSystemMessage | import("../../message/type").ITemplateUserMessage | import("../../message/type").IToolMessage | import("../../message/type").IUserMessage>;
|
|
24
24
|
modifyMessage: (data: IMessage, config?: IRequestConfig) => Promise<import("../../message/type").IActivityMessage | import("../../message/type").IAssistantMessage | import("../../message/type").IDeveloperMessage | import("../../message/type").IInterruptMessage | import("../../message/type").IGuideMessage | import("../../message/type").IHiddenAssistantMessage | import("../../message/type").IHiddenGuideMessage | import("../../message/type").IHiddenMessage | import("../../message/type").IHiddenSystemMessage | import("../../message/type").IHiddenUserMessage | import("../../message/type").IInfoMessage | import("../../message/type").IPauseMessage | import("../../message/type").IPlaceholderMessage | import("../../message/type").IReasoningMessage | import("../../message/type").ISystemMessage | import("../../message/type").ITemplateAssistantMessage | import("../../message/type").ITemplateGuideMessage | import("../../message/type").ITemplateHiddenMessage | import("../../message/type").ITemplateSystemMessage | import("../../message/type").ITemplateUserMessage | import("../../message/type").IToolMessage | import("../../message/type").IUserMessage>;
|
|
25
25
|
deleteMessage: (id: string, config?: IRequestConfig) => Promise<IMessage>;
|
|
@@ -56,10 +56,11 @@ import { transferMessage2MessageApi, transferMessageApi2Message } from '../trans
|
|
|
56
56
|
* @param fetchClient - 请求客户端
|
|
57
57
|
* @returns message 相关 http 接口
|
|
58
58
|
*/ export const useMessage = (fetchClient)=>{
|
|
59
|
-
//
|
|
60
|
-
const getMessages = (sessionCode, limit, config)=>fetchClient.get(`session_content/content/`, {
|
|
59
|
+
// 获取会话内容列表(fuzzy 置于末尾,避免影响既有 limit/config 调用)
|
|
60
|
+
const getMessages = (sessionCode, limit, config, fuzzy)=>fetchClient.get(`session_content/content/`, {
|
|
61
61
|
session_code: sessionCode,
|
|
62
|
-
limit
|
|
62
|
+
limit,
|
|
63
|
+
fuzzy
|
|
63
64
|
}, config).then((res)=>res.map(transferMessageApi2Message));
|
|
64
65
|
// 新增会话内容
|
|
65
66
|
const plusMessage = (data, config)=>fetchClient.post(`session_content/`, transferMessage2MessageApi(data), config).then(transferMessageApi2Message);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ISession, ISessionFeedback } from '../../session/type';
|
|
1
|
+
import type { GetPvFileDownloadUrlOptions, ILegacyUploadFileResult, IPvFileDownloadUrlResult, IPvFileUploadResult, ISession, ISessionFeedback, ISessionListParams } from '../../session/type';
|
|
2
2
|
import type { FetchClient, IRequestConfig } from '../fetch';
|
|
3
3
|
/**
|
|
4
4
|
* session 相关 http 接口
|
|
@@ -7,7 +7,12 @@ import type { FetchClient, IRequestConfig } from '../fetch';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const useSession: (fetchClient: FetchClient) => {
|
|
9
9
|
clearSession: (sessionCode: string, config?: IRequestConfig) => Promise<unknown>;
|
|
10
|
-
getSessions: (config?: IRequestConfig) => Promise<
|
|
10
|
+
getSessions: (params?: ISessionListParams, config?: IRequestConfig) => Promise<{
|
|
11
|
+
page: number;
|
|
12
|
+
numPages: number;
|
|
13
|
+
count: number;
|
|
14
|
+
results: ISession<unknown, unknown>[];
|
|
15
|
+
}>;
|
|
11
16
|
plusSession: (data: ISession, config?: IRequestConfig) => Promise<ISession<unknown, unknown>>;
|
|
12
17
|
modifySession: (data: ISession, config?: IRequestConfig) => Promise<ISession<unknown, unknown>>;
|
|
13
18
|
deleteSession: (sessionCode: string, config?: IRequestConfig) => Promise<unknown>;
|
|
@@ -22,8 +27,8 @@ export declare const useSession: (fetchClient: FetchClient) => {
|
|
|
22
27
|
}>;
|
|
23
28
|
getSessionFeedbackReasons: (rate: number, config?: IRequestConfig) => Promise<string[]>;
|
|
24
29
|
renameSession: (sessionCode: string, config?: IRequestConfig) => Promise<ISession<unknown, unknown>>;
|
|
25
|
-
uploadFile: (sessionCode: string, file: File, config?: IRequestConfig) => Promise<
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
uploadFile: (sessionCode: string, file: File, config?: IRequestConfig) => Promise<ILegacyUploadFileResult>;
|
|
31
|
+
uploadPvFiles: (sessionCode: string, files: File[], config?: IRequestConfig) => Promise<IPvFileUploadResult>;
|
|
32
|
+
getPvFileDownloadUrl: (sessionCode: string, path: string, options?: GetPvFileDownloadUrlOptions, config?: IRequestConfig) => Promise<IPvFileDownloadUrlResult>;
|
|
28
33
|
isResumeSession: (sessionCode: string, config?: IRequestConfig) => Promise<boolean>;
|
|
29
34
|
};
|