@blueking/chat-helper 0.0.1-beta.33 → 0.0.1-beta.34
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/dist/agent/use-agent.ts.js +4 -1
- package/dist/http/fetch/index.ts.js +65 -16
- package/dist/http/index.d.ts +0 -1
- package/dist/http/module/index.d.ts +0 -1
- package/dist/http/module/message.d.ts +0 -1
- package/dist/http/module/message.ts.js +1 -4
- package/dist/index.d.ts +0 -3
- package/dist/message/use-message.d.ts +0 -2
- package/dist/message/use-message.ts.js +0 -10
- package/package.json +1 -1
|
@@ -154,7 +154,10 @@ import { MessageRole, MessageStatus } from '../message/index.ts.js';
|
|
|
154
154
|
url: url || 'chat_completion/',
|
|
155
155
|
method: 'POST',
|
|
156
156
|
data: {
|
|
157
|
-
session_code: sessionCode
|
|
157
|
+
session_code: sessionCode,
|
|
158
|
+
execute_kwargs: {
|
|
159
|
+
stream: true
|
|
160
|
+
}
|
|
158
161
|
},
|
|
159
162
|
controller: abortController,
|
|
160
163
|
onDone,
|
|
@@ -22,33 +22,82 @@
|
|
|
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
|
-
*/
|
|
26
|
-
|
|
25
|
+
*/ function _define_property(obj, key, value) {
|
|
26
|
+
if (key in obj) {
|
|
27
|
+
Object.defineProperty(obj, key, {
|
|
28
|
+
value: value,
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true
|
|
32
|
+
});
|
|
33
|
+
} else {
|
|
34
|
+
obj[key] = value;
|
|
35
|
+
}
|
|
36
|
+
return obj;
|
|
37
|
+
}
|
|
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 { FetchClient } from './fetch.ts.js';
|
|
54
|
+
/**
|
|
55
|
+
* 注册所有拦截器(内部 requestData 注入 + 用户自定义)
|
|
56
|
+
* 抽取为独立函数,避免 useFetch 和 reset 中重复逻辑
|
|
57
|
+
*/ function applyInterceptors(fetchClient, options) {
|
|
27
58
|
var _options_interceptors, _options_interceptors1;
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
59
|
+
const { headers: customHeaders, data: customData } = options.requestData;
|
|
60
|
+
if (customHeaders || customData) {
|
|
61
|
+
fetchClient.interceptors.request.use((config)=>{
|
|
62
|
+
if (customHeaders) {
|
|
63
|
+
const resolved = typeof customHeaders === 'function' ? customHeaders() : customHeaders;
|
|
64
|
+
const existing = typeof config.headers === 'function' ? config.headers() : config.headers || {};
|
|
65
|
+
config.headers = _object_spread({}, existing, resolved);
|
|
66
|
+
}
|
|
67
|
+
const method = (config.method || 'GET').toUpperCase();
|
|
68
|
+
const supportsBody = ![
|
|
69
|
+
'GET',
|
|
70
|
+
'HEAD'
|
|
71
|
+
].includes(method);
|
|
72
|
+
if (customData && supportsBody) {
|
|
73
|
+
const resolved = typeof customData === 'function' ? customData() : customData;
|
|
74
|
+
const existingData = typeof config.data === 'function' ? config.data() : config.data;
|
|
75
|
+
if (existingData && typeof existingData === 'object' && !Array.isArray(existingData)) {
|
|
76
|
+
config.data = _object_spread({}, resolved, existingData);
|
|
77
|
+
} else if (!existingData) {
|
|
78
|
+
config.data = resolved;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return config;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
32
84
|
if ((_options_interceptors = options.interceptors) === null || _options_interceptors === void 0 ? void 0 : _options_interceptors.request) {
|
|
33
85
|
fetchClient.interceptors.request.use(options.interceptors.request);
|
|
34
86
|
}
|
|
35
87
|
if ((_options_interceptors1 = options.interceptors) === null || _options_interceptors1 === void 0 ? void 0 : _options_interceptors1.response) {
|
|
36
88
|
fetchClient.interceptors.response.use(options.interceptors.response);
|
|
37
89
|
}
|
|
38
|
-
|
|
90
|
+
}
|
|
91
|
+
export const useFetch = (options)=>{
|
|
92
|
+
const fetchClient = new FetchClient({
|
|
93
|
+
baseURL: options.requestData.urlPrefix
|
|
94
|
+
});
|
|
95
|
+
applyInterceptors(fetchClient, options);
|
|
39
96
|
const reset = (newOptions)=>{
|
|
40
|
-
var _newOptions_interceptors, _newOptions_interceptors1;
|
|
41
|
-
// 更新 baseURL
|
|
42
97
|
fetchClient.defaults.baseURL = newOptions.requestData.urlPrefix;
|
|
43
|
-
// 清空并重新注册拦截器
|
|
44
98
|
fetchClient.interceptors.request.clear();
|
|
45
99
|
fetchClient.interceptors.response.clear();
|
|
46
|
-
|
|
47
|
-
fetchClient.interceptors.request.use(newOptions.interceptors.request);
|
|
48
|
-
}
|
|
49
|
-
if ((_newOptions_interceptors1 = newOptions.interceptors) === null || _newOptions_interceptors1 === void 0 ? void 0 : _newOptions_interceptors1.response) {
|
|
50
|
-
fetchClient.interceptors.response.use(newOptions.interceptors.response);
|
|
51
|
-
}
|
|
100
|
+
applyInterceptors(fetchClient, newOptions);
|
|
52
101
|
};
|
|
53
102
|
return {
|
|
54
103
|
fetchClient,
|
package/dist/http/index.d.ts
CHANGED
|
@@ -40,7 +40,6 @@ export declare const useHttp: (options: IUseChatHelperOptions) => {
|
|
|
40
40
|
batchDeleteMessages: (ids: string[], config?: import("./fetch").IRequestConfig) => Promise<number>;
|
|
41
41
|
shareMessages: (sessionCode: string, contentIds: string[], expiredAt?: number, config?: import("./fetch").IRequestConfig) => Promise<import("./module/message").IShareMessagesResponse>;
|
|
42
42
|
stopChat: (sessionCode: string, config?: import("./fetch").IRequestConfig) => Promise<void>;
|
|
43
|
-
getFlowAgentTaskInfo: (taskId: number, config?: import("./fetch").IRequestConfig) => Promise<unknown>;
|
|
44
43
|
getFlowAgentTaskNodeInfo: (taskId: number, nodeId: string, config?: import("./fetch").IRequestConfig) => Promise<import("..").IFlowAgentTaskNodeInfo>;
|
|
45
44
|
};
|
|
46
45
|
fetchClient: import("./fetch").FetchClient;
|
|
@@ -37,7 +37,6 @@ export declare const useModule: (fetchClient: FetchClient) => {
|
|
|
37
37
|
batchDeleteMessages: (ids: string[], config?: import("../fetch").IRequestConfig) => Promise<number>;
|
|
38
38
|
shareMessages: (sessionCode: string, contentIds: string[], expiredAt?: number, config?: import("../fetch").IRequestConfig) => Promise<import("./message").IShareMessagesResponse>;
|
|
39
39
|
stopChat: (sessionCode: string, config?: import("../fetch").IRequestConfig) => Promise<void>;
|
|
40
|
-
getFlowAgentTaskInfo: (taskId: number, config?: import("../fetch").IRequestConfig) => Promise<unknown>;
|
|
41
40
|
getFlowAgentTaskNodeInfo: (taskId: number, nodeId: string, config?: import("../fetch").IRequestConfig) => Promise<import("../..").IFlowAgentTaskNodeInfo>;
|
|
42
41
|
};
|
|
43
42
|
fetchClient: FetchClient;
|
|
@@ -26,6 +26,5 @@ export declare const useMessage: (fetchClient: FetchClient) => {
|
|
|
26
26
|
batchDeleteMessages: (ids: string[], config?: IRequestConfig) => Promise<number>;
|
|
27
27
|
shareMessages: (sessionCode: string, contentIds: string[], expiredAt?: number, config?: IRequestConfig) => Promise<IShareMessagesResponse>;
|
|
28
28
|
stopChat: (sessionCode: string, config?: IRequestConfig) => Promise<void>;
|
|
29
|
-
getFlowAgentTaskInfo: (taskId: number, config?: IRequestConfig) => Promise<unknown>;
|
|
30
29
|
getFlowAgentTaskNodeInfo: (taskId: number, nodeId: string, config?: IRequestConfig) => Promise<IFlowAgentTaskNodeInfo>;
|
|
31
30
|
};
|
|
@@ -82,10 +82,8 @@ import { transferMessage2MessageApi, transferMessageApi2Message } from '../trans
|
|
|
82
82
|
const stopChat = (sessionCode, config)=>fetchClient.post(`session_content/stop/`, {
|
|
83
83
|
session_code: sessionCode
|
|
84
84
|
}, config);
|
|
85
|
-
// 获取流程引擎任务信息
|
|
86
|
-
const getFlowAgentTaskInfo = (taskId, config)=>fetchClient.get(`flow_agent/${taskId}/task_info/`, undefined, config);
|
|
87
85
|
// 获取流程引擎任务节点详情
|
|
88
|
-
const getFlowAgentTaskNodeInfo = (taskId, nodeId, config)=>fetchClient.get(`flow_agent/${taskId}
|
|
86
|
+
const getFlowAgentTaskNodeInfo = (taskId, nodeId, config)=>fetchClient.get(`flow_agent/task_node_info/${taskId}/${nodeId}/`, undefined, config);
|
|
89
87
|
return {
|
|
90
88
|
getMessages,
|
|
91
89
|
plusMessage,
|
|
@@ -94,7 +92,6 @@ import { transferMessage2MessageApi, transferMessageApi2Message } from '../trans
|
|
|
94
92
|
batchDeleteMessages,
|
|
95
93
|
shareMessages,
|
|
96
94
|
stopChat,
|
|
97
|
-
getFlowAgentTaskInfo,
|
|
98
95
|
getFlowAgentTaskNodeInfo
|
|
99
96
|
};
|
|
100
97
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -3700,8 +3700,6 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
3700
3700
|
createAndPlusMessage: (message: import("./message").IMessage) => Promise<void>;
|
|
3701
3701
|
deleteMessages: (messages: import("./message").IMessage[]) => Promise<void>;
|
|
3702
3702
|
shareMessages: (sessionCode: string, messages: import("./message").IMessage[], expiredAt?: number) => Promise<import("./http/module/message").IShareMessagesResponse>;
|
|
3703
|
-
getFlowAgentTaskInfo: (taskId: number) => Promise<unknown>;
|
|
3704
|
-
getFlowAgentTaskNodeInfo: (taskId: number, nodeId: string) => Promise<import("./message").IFlowAgentTaskNodeInfo>;
|
|
3705
3703
|
reset: () => void;
|
|
3706
3704
|
};
|
|
3707
3705
|
http: {
|
|
@@ -3738,7 +3736,6 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
3738
3736
|
batchDeleteMessages: (ids: string[], config?: import("./http").IRequestConfig) => Promise<number>;
|
|
3739
3737
|
shareMessages: (sessionCode: string, contentIds: string[], expiredAt?: number, config?: import("./http").IRequestConfig) => Promise<import("./http/module/message").IShareMessagesResponse>;
|
|
3740
3738
|
stopChat: (sessionCode: string, config?: import("./http").IRequestConfig) => Promise<void>;
|
|
3741
|
-
getFlowAgentTaskInfo: (taskId: number, config?: import("./http").IRequestConfig) => Promise<unknown>;
|
|
3742
3739
|
getFlowAgentTaskNodeInfo: (taskId: number, nodeId: string, config?: import("./http").IRequestConfig) => Promise<import("./message").IFlowAgentTaskNodeInfo>;
|
|
3743
3740
|
};
|
|
3744
3741
|
fetchClient: import("./http").FetchClient;
|
|
@@ -994,8 +994,6 @@ export declare const useMessage: (mediator: IMediatorModule) => {
|
|
|
994
994
|
createAndPlusMessage: (message: IMessage) => Promise<void>;
|
|
995
995
|
deleteMessages: (messages: IMessage[]) => Promise<void>;
|
|
996
996
|
shareMessages: (sessionCode: string, messages: IMessage[], expiredAt?: number) => Promise<import("../http/module/message").IShareMessagesResponse>;
|
|
997
|
-
getFlowAgentTaskInfo: (taskId: number) => Promise<unknown>;
|
|
998
|
-
getFlowAgentTaskNodeInfo: (taskId: number, nodeId: string) => Promise<import("./type").IFlowAgentTaskNodeInfo>;
|
|
999
997
|
reset: () => void;
|
|
1000
998
|
};
|
|
1001
999
|
export type IMessageModule = ReturnType<typeof useMessage>;
|
|
@@ -262,14 +262,6 @@ import { MessageRole, MessageStatus } from './type.ts.js';
|
|
|
262
262
|
return _ref.apply(this, arguments);
|
|
263
263
|
};
|
|
264
264
|
}();
|
|
265
|
-
const getFlowAgentTaskInfo = (taskId)=>{
|
|
266
|
-
var _mediator_http;
|
|
267
|
-
return (_mediator_http = mediator.http) === null || _mediator_http === void 0 ? void 0 : _mediator_http.message.getFlowAgentTaskInfo(taskId);
|
|
268
|
-
};
|
|
269
|
-
const getFlowAgentTaskNodeInfo = (taskId, nodeId)=>{
|
|
270
|
-
var _mediator_http;
|
|
271
|
-
return (_mediator_http = mediator.http) === null || _mediator_http === void 0 ? void 0 : _mediator_http.message.getFlowAgentTaskNodeInfo(taskId, nodeId);
|
|
272
|
-
};
|
|
273
265
|
const reset = ()=>{
|
|
274
266
|
list.value = [];
|
|
275
267
|
isListLoading.value = false;
|
|
@@ -288,8 +280,6 @@ import { MessageRole, MessageStatus } from './type.ts.js';
|
|
|
288
280
|
createAndPlusMessage,
|
|
289
281
|
deleteMessages,
|
|
290
282
|
shareMessages,
|
|
291
|
-
getFlowAgentTaskInfo,
|
|
292
|
-
getFlowAgentTaskNodeInfo,
|
|
293
283
|
reset
|
|
294
284
|
};
|
|
295
285
|
};
|