@blueking/chat-helper 0.0.4 → 0.0.6
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 +10 -0
- package/dist/http/fetch/fetch.d.ts +6 -4
- package/dist/http/fetch/fetch.ts.js +3 -3
- package/dist/http/fetch/index.d.ts +3 -0
- package/dist/http/fetch/index.ts.js +42 -27
- package/dist/http/fetch/resolve-request-value.d.ts +16 -0
- package/dist/http/fetch/resolve-request-value.ts.js +38 -0
- package/dist/http/transform/session.ts.js +6 -6
- package/dist/index.d.ts +4 -4
- package/dist/session/type.d.ts +2 -2
- package/dist/session/use-session.d.ts +4 -4
- package/dist/type.d.ts +5 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -357,10 +357,20 @@ useChatHelper({
|
|
|
357
357
|
Authorization: `Bearer ${getToken()}`,
|
|
358
358
|
'X-Request-ID': generateRequestId(),
|
|
359
359
|
}),
|
|
360
|
+
|
|
361
|
+
// 也支持 Vue ref / computed(每次请求读取最新值)
|
|
362
|
+
// headers: computed(() => ({ Authorization: `Bearer ${token.value}` })),
|
|
363
|
+
// data: ref({ app_id: currentAppId.value }),
|
|
360
364
|
},
|
|
361
365
|
});
|
|
362
366
|
```
|
|
363
367
|
|
|
368
|
+
**响应式写法说明**:
|
|
369
|
+
|
|
370
|
+
- `headers` / `data` 支持:普通对象、零参函数、`ref`、`computed`,以及「函数返回 ref/computed」。
|
|
371
|
+
- 每次发起 HTTP 请求前都会重新解析,修改 `.value` 或替换外层 ref 后,后续请求自动使用新值。
|
|
372
|
+
- `data` 对 POST/PUT/PATCH/DELETE 合并进请求体;对 GET/HEAD/OPTIONS 合并进 query(`params`),不会写入 body。
|
|
373
|
+
|
|
364
374
|
### interceptors(可选)
|
|
365
375
|
|
|
366
376
|
配置请求和响应拦截器,用于统一处理请求和响应。
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { MaybeRequestValue, RequestHeaders } from './resolve-request-value';
|
|
2
|
+
export type { MaybeRequestValue, RequestData, RequestHeaders } from './resolve-request-value';
|
|
1
3
|
export interface ApiResponse<T = unknown> {
|
|
2
4
|
code: number | string;
|
|
3
5
|
data: T;
|
|
@@ -8,10 +10,10 @@ export interface IRequestConfig {
|
|
|
8
10
|
baseURL?: string;
|
|
9
11
|
controller?: AbortController;
|
|
10
12
|
credentials?: 'include' | 'omit' | 'same-origin';
|
|
11
|
-
/**
|
|
12
|
-
data?:
|
|
13
|
-
/**
|
|
14
|
-
headers?:
|
|
13
|
+
/** 请求体;支持对象/函数/ref 延迟求值(在 `prepareRequest` 中解析) */
|
|
14
|
+
data?: MaybeRequestValue<unknown>;
|
|
15
|
+
/** 请求头;支持对象/函数/ref 延迟求值,便于动态注入(如 token) */
|
|
16
|
+
headers?: MaybeRequestValue<RequestHeaders>;
|
|
15
17
|
method?: string;
|
|
16
18
|
mode?: 'cors' | 'no-cors' | 'same-origin';
|
|
17
19
|
params?: Record<string, unknown>;
|
|
@@ -22,8 +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
|
-
*/
|
|
26
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
25
|
+
*/ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
27
26
|
try {
|
|
28
27
|
var info = gen[key](arg);
|
|
29
28
|
var value = info.value;
|
|
@@ -104,6 +103,7 @@ function _object_spread_props(target, source) {
|
|
|
104
103
|
}
|
|
105
104
|
return target;
|
|
106
105
|
}
|
|
106
|
+
import { resolveRequestValue } from './resolve-request-value.ts.js';
|
|
107
107
|
class InterceptorManager {
|
|
108
108
|
clear() {
|
|
109
109
|
this.handlers = [];
|
|
@@ -463,7 +463,7 @@ function createError(message, config, code, response) {
|
|
|
463
463
|
return error;
|
|
464
464
|
}
|
|
465
465
|
function getValue(value) {
|
|
466
|
-
return
|
|
466
|
+
return resolveRequestValue(value);
|
|
467
467
|
}
|
|
468
468
|
/** 排除 AbortController、Headers 等类实例,只对普通对象深度合并 */ function isPlainObject(value) {
|
|
469
469
|
if (!value || typeof value !== 'object') return false;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { FetchClient } from './fetch';
|
|
2
2
|
import type { IUseChatHelperOptions } from '../../type';
|
|
3
|
+
export { FetchClient } from './fetch';
|
|
3
4
|
export type * from './fetch';
|
|
5
|
+
export type { MaybeRequestValue, RequestData, RequestHeaders } from './resolve-request-value';
|
|
6
|
+
export { resolveRequestValue } from './resolve-request-value';
|
|
4
7
|
export declare const useFetch: (options: IUseChatHelperOptions) => {
|
|
5
8
|
fetchClient: FetchClient;
|
|
6
9
|
reset: (newOptions: IUseChatHelperOptions) => void;
|
|
@@ -75,60 +75,75 @@ function _object_spread_props(target, source) {
|
|
|
75
75
|
return target;
|
|
76
76
|
}
|
|
77
77
|
import { FetchClient } from './fetch.ts.js';
|
|
78
|
-
|
|
78
|
+
import { resolveRequestValue } from './resolve-request-value.ts.js';
|
|
79
|
+
export { FetchClient } from './fetch.ts.js';
|
|
80
|
+
export { resolveRequestValue } from './resolve-request-value.ts.js';
|
|
81
|
+
/** 使用请求体的 HTTP 方法 */ const BODY_METHODS = new Set([
|
|
79
82
|
'POST',
|
|
80
83
|
'PUT',
|
|
81
84
|
'PATCH',
|
|
82
85
|
'DELETE'
|
|
83
86
|
]);
|
|
87
|
+
/** 无请求体、通过 query 传参的 HTTP 方法 */ const QUERY_METHODS = new Set([
|
|
88
|
+
'GET',
|
|
89
|
+
'HEAD',
|
|
90
|
+
'OPTIONS'
|
|
91
|
+
]);
|
|
84
92
|
/** 排除 FormData / Blob / ArrayBuffer 等,只对普通对象展开合并 */ function isPlainObject(value) {
|
|
85
93
|
if (!value || typeof value !== 'object') return false;
|
|
86
94
|
const proto = Object.getPrototypeOf(value);
|
|
87
95
|
return proto === Object.prototype || proto === null;
|
|
88
96
|
}
|
|
89
|
-
/** 解析「函数 | 值」两种形式,支持延迟求值(如响应式 token) */ function resolveValue(value) {
|
|
90
|
-
return typeof value === 'function' ? value() : value;
|
|
91
|
-
}
|
|
92
97
|
/**
|
|
93
98
|
* 注册全局默认请求配置拦截器,将 `requestData.headers/data` 自动合并到每次请求。
|
|
94
|
-
* - `headers`
|
|
99
|
+
* - `headers` 注入所有请求
|
|
100
|
+
* - `data` 对 POST/PUT/PATCH/DELETE 合并进 body;对 GET/HEAD/OPTIONS 合并进 query(params)
|
|
95
101
|
* - 优先级最低(单次 IRequestConfig > 用户拦截器 > 本拦截器)。
|
|
96
102
|
*/ function registerRequestDataInterceptor(client, opts) {
|
|
97
103
|
const { headers: extraHeadersFn, data: extraDataFn } = opts.requestData;
|
|
98
104
|
if (!extraHeadersFn && !extraDataFn) return;
|
|
99
105
|
client.interceptors.request.use((config)=>{
|
|
100
106
|
let result = config;
|
|
107
|
+
var _config_method;
|
|
108
|
+
const method = ((_config_method = config.method) !== null && _config_method !== void 0 ? _config_method : 'GET').toUpperCase();
|
|
101
109
|
if (extraHeadersFn) {
|
|
102
|
-
const extra =
|
|
110
|
+
const extra = resolveRequestValue(extraHeadersFn);
|
|
103
111
|
if (extra && Object.keys(extra).length > 0) {
|
|
104
|
-
var
|
|
105
|
-
const existing = (
|
|
112
|
+
var _resolveRequestValue;
|
|
113
|
+
const existing = (_resolveRequestValue = resolveRequestValue(config.headers)) !== null && _resolveRequestValue !== void 0 ? _resolveRequestValue : {};
|
|
106
114
|
result = _object_spread_props(_object_spread({}, result), {
|
|
107
115
|
headers: _object_spread({}, existing, extra)
|
|
108
116
|
});
|
|
109
117
|
}
|
|
110
118
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if (extraDataFn && BODY_METHODS.has(method)) {
|
|
114
|
-
const extra = resolveValue(extraDataFn);
|
|
119
|
+
if (extraDataFn) {
|
|
120
|
+
const extra = resolveRequestValue(extraDataFn);
|
|
115
121
|
if (extra && Object.keys(extra).length > 0) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
if (BODY_METHODS.has(method)) {
|
|
123
|
+
const existing = resolveRequestValue(config.data);
|
|
124
|
+
if (existing == null) {
|
|
125
|
+
// body 为空(如 clearSession POST undefined):直接用 extra 作为 body
|
|
126
|
+
result = _object_spread_props(_object_spread({}, result), {
|
|
127
|
+
data: extra
|
|
128
|
+
});
|
|
129
|
+
} else if (isPlainObject(existing)) {
|
|
130
|
+
// body 是普通对象:浅合并,extra 字段优先级更低(existing 已有同名字段时保留)
|
|
131
|
+
result = _object_spread_props(_object_spread({}, result), {
|
|
132
|
+
data: _object_spread({}, extra, existing)
|
|
133
|
+
});
|
|
134
|
+
} else {
|
|
135
|
+
// body 是 FormData / Blob / string 等:跳过注入,避免破坏原始 body
|
|
136
|
+
console.warn('[chat-helper] requestData.data 无法注入:当前请求体不是普通对象(FormData/Blob/string 等),已跳过合并。', {
|
|
137
|
+
method,
|
|
138
|
+
existingType: typeof existing
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
} else if (QUERY_METHODS.has(method)) {
|
|
142
|
+
var _config_params;
|
|
143
|
+
const existingParams = (_config_params = config.params) !== null && _config_params !== void 0 ? _config_params : {};
|
|
144
|
+
// query 浅合并,extra 优先级更低(单次请求的 params 同名字段优先)
|
|
124
145
|
result = _object_spread_props(_object_spread({}, result), {
|
|
125
|
-
|
|
126
|
-
});
|
|
127
|
-
} else {
|
|
128
|
-
// body 是 FormData / Blob / string 等:跳过注入,避免破坏原始 body
|
|
129
|
-
console.warn('[chat-helper] requestData.data 无法注入:当前请求体不是普通对象(FormData/Blob/string 等),已跳过合并。', {
|
|
130
|
-
method,
|
|
131
|
-
existingType: typeof existing
|
|
146
|
+
params: _object_spread({}, extra, existingParams)
|
|
132
147
|
});
|
|
133
148
|
}
|
|
134
149
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** 请求头键值对 */
|
|
2
|
+
export type RequestHeaders = Record<string, string>;
|
|
3
|
+
/** 请求体附加数据键值对 */
|
|
4
|
+
export type RequestData = Record<string, unknown>;
|
|
5
|
+
/**
|
|
6
|
+
* 支持延迟求值的请求配置值:
|
|
7
|
+
* - 普通对象
|
|
8
|
+
* - 零参函数(可返回对象、ref、computed)
|
|
9
|
+
* - Ref / ComputedRef / MaybeRef
|
|
10
|
+
*/
|
|
11
|
+
export type MaybeRequestValue<T> = T | (() => MaybeRequestValue<T>);
|
|
12
|
+
/**
|
|
13
|
+
* 解析请求配置值,在每次请求前调用以读取最新值。
|
|
14
|
+
* 递归展开函数、ref、computed,直到得到最终对象或原始值。
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveRequestValue<T>(value: MaybeRequestValue<T> | undefined): T | undefined;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Tencent is pleased to support the open source community by making
|
|
3
|
+
* 蓝鲸智云PaaS平台 (BlueKing PaaS) available.
|
|
4
|
+
*
|
|
5
|
+
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
|
6
|
+
*
|
|
7
|
+
* 蓝鲸智云PaaS平台 (BlueKing PaaS) is licensed under the MIT License.
|
|
8
|
+
*/ import { isRef, unref } from 'vue';
|
|
9
|
+
function isVueRef(value) {
|
|
10
|
+
return isRef(value);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 解析请求配置值,在每次请求前调用以读取最新值。
|
|
14
|
+
* 递归展开函数、ref、computed,直到得到最终对象或原始值。
|
|
15
|
+
*/ export function resolveRequestValue(value) {
|
|
16
|
+
if (value === undefined || value === null) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
let current = value;
|
|
20
|
+
const maxDepth = 32;
|
|
21
|
+
let depth = 0;
|
|
22
|
+
while(depth < maxDepth){
|
|
23
|
+
depth += 1;
|
|
24
|
+
if (typeof current === 'function') {
|
|
25
|
+
current = current();
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (isVueRef(current)) {
|
|
29
|
+
current = unref(current);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
if (depth >= maxDepth) {
|
|
35
|
+
console.warn('[chat-helper] resolveRequestValue: exceeded max unwrap depth');
|
|
36
|
+
}
|
|
37
|
+
return current;
|
|
38
|
+
}
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* @param data API 返回的 session 数据
|
|
28
28
|
* @returns 前端使用的 session 数据
|
|
29
29
|
*/ export const transferSessionApi2Session = (data)=>{
|
|
30
|
-
var _data_session_property, _data_session_property1;
|
|
30
|
+
var _data_session_property, _data_session_property1, _data_session_property2;
|
|
31
31
|
return {
|
|
32
32
|
sessionCode: data.session_code,
|
|
33
33
|
sessionContentCount: data.session_content_count,
|
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
isTemporary: data.is_temporary,
|
|
36
36
|
model: data.model,
|
|
37
37
|
comment: data.comment,
|
|
38
|
-
labels: data.labels,
|
|
39
38
|
rate: data.rate,
|
|
40
39
|
updatedAt: data.updated_at,
|
|
41
40
|
createdAt: data.created_at,
|
|
@@ -47,7 +46,8 @@
|
|
|
47
46
|
} : undefined,
|
|
48
47
|
sessionProperty: {
|
|
49
48
|
isAutoClear: (_data_session_property = data.session_property) === null || _data_session_property === void 0 ? void 0 : _data_session_property.is_auto_clear,
|
|
50
|
-
isAutoCalcPrompt: (_data_session_property1 = data.session_property) === null || _data_session_property1 === void 0 ? void 0 : _data_session_property1.is_auto_clac_prompt
|
|
49
|
+
isAutoCalcPrompt: (_data_session_property1 = data.session_property) === null || _data_session_property1 === void 0 ? void 0 : _data_session_property1.is_auto_clac_prompt,
|
|
50
|
+
labels: (_data_session_property2 = data.session_property) === null || _data_session_property2 === void 0 ? void 0 : _data_session_property2.labels
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
53
|
};
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
* @param data 前端使用的 session 数据
|
|
57
57
|
* @returns API 使用的 session 数据
|
|
58
58
|
*/ export const transferSession2SessionApi = (data)=>{
|
|
59
|
-
var _data_sessionProperty, _data_sessionProperty1;
|
|
59
|
+
var _data_sessionProperty, _data_sessionProperty1, _data_sessionProperty2;
|
|
60
60
|
return {
|
|
61
61
|
session_code: data.sessionCode,
|
|
62
62
|
session_content_count: data.sessionContentCount,
|
|
@@ -64,7 +64,6 @@
|
|
|
64
64
|
is_temporary: data.isTemporary,
|
|
65
65
|
model: data.model,
|
|
66
66
|
comment: data.comment,
|
|
67
|
-
labels: data.labels,
|
|
68
67
|
rate: data.rate,
|
|
69
68
|
updated_at: data.updatedAt,
|
|
70
69
|
created_at: data.createdAt,
|
|
@@ -76,7 +75,8 @@
|
|
|
76
75
|
} : undefined,
|
|
77
76
|
session_property: {
|
|
78
77
|
is_auto_clear: (_data_sessionProperty = data.sessionProperty) === null || _data_sessionProperty === void 0 ? void 0 : _data_sessionProperty.isAutoClear,
|
|
79
|
-
is_auto_clac_prompt: (_data_sessionProperty1 = data.sessionProperty) === null || _data_sessionProperty1 === void 0 ? void 0 : _data_sessionProperty1.isAutoCalcPrompt
|
|
78
|
+
is_auto_clac_prompt: (_data_sessionProperty1 = data.sessionProperty) === null || _data_sessionProperty1 === void 0 ? void 0 : _data_sessionProperty1.isAutoCalcPrompt,
|
|
79
|
+
labels: (_data_sessionProperty2 = data.sessionProperty) === null || _data_sessionProperty2 === void 0 ? void 0 : _data_sessionProperty2.labels
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -628,7 +628,6 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
628
628
|
comment?: string;
|
|
629
629
|
createdAt?: string;
|
|
630
630
|
isTemporary?: boolean;
|
|
631
|
-
labels?: string[];
|
|
632
631
|
model?: string;
|
|
633
632
|
rate?: number;
|
|
634
633
|
sessionCode: string;
|
|
@@ -1136,13 +1135,13 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
1136
1135
|
sessionProperty?: {
|
|
1137
1136
|
isAutoCalcPrompt?: boolean;
|
|
1138
1137
|
isAutoClear?: boolean;
|
|
1138
|
+
labels?: string[];
|
|
1139
1139
|
};
|
|
1140
1140
|
}[], import("./session").ISession<unknown, unknown>[] | {
|
|
1141
1141
|
anchorPathResources?: unknown;
|
|
1142
1142
|
comment?: string;
|
|
1143
1143
|
createdAt?: string;
|
|
1144
1144
|
isTemporary?: boolean;
|
|
1145
|
-
labels?: string[];
|
|
1146
1145
|
model?: string;
|
|
1147
1146
|
rate?: number;
|
|
1148
1147
|
sessionCode: string;
|
|
@@ -1650,6 +1649,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
1650
1649
|
sessionProperty?: {
|
|
1651
1650
|
isAutoCalcPrompt?: boolean;
|
|
1652
1651
|
isAutoClear?: boolean;
|
|
1652
|
+
labels?: string[];
|
|
1653
1653
|
};
|
|
1654
1654
|
}[]>;
|
|
1655
1655
|
current: import("vue").Ref<{
|
|
@@ -1657,7 +1657,6 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
1657
1657
|
comment?: string;
|
|
1658
1658
|
createdAt?: string;
|
|
1659
1659
|
isTemporary?: boolean;
|
|
1660
|
-
labels?: string[];
|
|
1661
1660
|
model?: string;
|
|
1662
1661
|
rate?: number;
|
|
1663
1662
|
sessionCode: string;
|
|
@@ -2165,13 +2164,13 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
2165
2164
|
sessionProperty?: {
|
|
2166
2165
|
isAutoCalcPrompt?: boolean;
|
|
2167
2166
|
isAutoClear?: boolean;
|
|
2167
|
+
labels?: string[];
|
|
2168
2168
|
};
|
|
2169
2169
|
}, import("./session").ISession<unknown, unknown> | {
|
|
2170
2170
|
anchorPathResources?: unknown;
|
|
2171
2171
|
comment?: string;
|
|
2172
2172
|
createdAt?: string;
|
|
2173
2173
|
isTemporary?: boolean;
|
|
2174
|
-
labels?: string[];
|
|
2175
2174
|
model?: string;
|
|
2176
2175
|
rate?: number;
|
|
2177
2176
|
sessionCode: string;
|
|
@@ -2679,6 +2678,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
|
|
|
2679
2678
|
sessionProperty?: {
|
|
2680
2679
|
isAutoCalcPrompt?: boolean;
|
|
2681
2680
|
isAutoClear?: boolean;
|
|
2681
|
+
labels?: string[];
|
|
2682
2682
|
};
|
|
2683
2683
|
}>;
|
|
2684
2684
|
isCurrentLoading: import("vue").Ref<boolean, boolean>;
|
package/dist/session/type.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ export interface ISession<ITool = unknown, IAnchorPathResources = unknown> {
|
|
|
4
4
|
comment?: string;
|
|
5
5
|
createdAt?: string;
|
|
6
6
|
isTemporary?: boolean;
|
|
7
|
-
labels?: string[];
|
|
8
7
|
model?: string;
|
|
9
8
|
rate?: number;
|
|
10
9
|
sessionCode: string;
|
|
@@ -25,6 +24,7 @@ export interface ISession<ITool = unknown, IAnchorPathResources = unknown> {
|
|
|
25
24
|
sessionProperty?: {
|
|
26
25
|
isAutoCalcPrompt?: boolean;
|
|
27
26
|
isAutoClear?: boolean;
|
|
27
|
+
labels?: string[];
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
export interface ISessionApi<IToolApi = unknown, IAnchorPathResourcesApi = unknown> {
|
|
@@ -32,7 +32,6 @@ export interface ISessionApi<IToolApi = unknown, IAnchorPathResourcesApi = unkno
|
|
|
32
32
|
comment?: string;
|
|
33
33
|
created_at?: string;
|
|
34
34
|
is_temporary?: boolean;
|
|
35
|
-
labels?: string[];
|
|
36
35
|
model?: string;
|
|
37
36
|
rate?: number;
|
|
38
37
|
session_code: string;
|
|
@@ -53,6 +52,7 @@ export interface ISessionApi<IToolApi = unknown, IAnchorPathResourcesApi = unkno
|
|
|
53
52
|
session_property?: {
|
|
54
53
|
is_auto_clac_prompt?: boolean;
|
|
55
54
|
is_auto_clear?: boolean;
|
|
55
|
+
labels?: string[];
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
export interface ISessionFeedback {
|
|
@@ -11,7 +11,6 @@ export declare const useSession: (mediator: IMediatorModule) => {
|
|
|
11
11
|
comment?: string;
|
|
12
12
|
createdAt?: string;
|
|
13
13
|
isTemporary?: boolean;
|
|
14
|
-
labels?: string[];
|
|
15
14
|
model?: string;
|
|
16
15
|
rate?: number;
|
|
17
16
|
sessionCode: string;
|
|
@@ -519,13 +518,13 @@ export declare const useSession: (mediator: IMediatorModule) => {
|
|
|
519
518
|
sessionProperty?: {
|
|
520
519
|
isAutoCalcPrompt?: boolean;
|
|
521
520
|
isAutoClear?: boolean;
|
|
521
|
+
labels?: string[];
|
|
522
522
|
};
|
|
523
523
|
}[], ISession<unknown, unknown>[] | {
|
|
524
524
|
anchorPathResources?: unknown;
|
|
525
525
|
comment?: string;
|
|
526
526
|
createdAt?: string;
|
|
527
527
|
isTemporary?: boolean;
|
|
528
|
-
labels?: string[];
|
|
529
528
|
model?: string;
|
|
530
529
|
rate?: number;
|
|
531
530
|
sessionCode: string;
|
|
@@ -1033,6 +1032,7 @@ export declare const useSession: (mediator: IMediatorModule) => {
|
|
|
1033
1032
|
sessionProperty?: {
|
|
1034
1033
|
isAutoCalcPrompt?: boolean;
|
|
1035
1034
|
isAutoClear?: boolean;
|
|
1035
|
+
labels?: string[];
|
|
1036
1036
|
};
|
|
1037
1037
|
}[]>;
|
|
1038
1038
|
current: import("vue").Ref<{
|
|
@@ -1040,7 +1040,6 @@ export declare const useSession: (mediator: IMediatorModule) => {
|
|
|
1040
1040
|
comment?: string;
|
|
1041
1041
|
createdAt?: string;
|
|
1042
1042
|
isTemporary?: boolean;
|
|
1043
|
-
labels?: string[];
|
|
1044
1043
|
model?: string;
|
|
1045
1044
|
rate?: number;
|
|
1046
1045
|
sessionCode: string;
|
|
@@ -1548,13 +1547,13 @@ export declare const useSession: (mediator: IMediatorModule) => {
|
|
|
1548
1547
|
sessionProperty?: {
|
|
1549
1548
|
isAutoCalcPrompt?: boolean;
|
|
1550
1549
|
isAutoClear?: boolean;
|
|
1550
|
+
labels?: string[];
|
|
1551
1551
|
};
|
|
1552
1552
|
}, ISession<unknown, unknown> | {
|
|
1553
1553
|
anchorPathResources?: unknown;
|
|
1554
1554
|
comment?: string;
|
|
1555
1555
|
createdAt?: string;
|
|
1556
1556
|
isTemporary?: boolean;
|
|
1557
|
-
labels?: string[];
|
|
1558
1557
|
model?: string;
|
|
1559
1558
|
rate?: number;
|
|
1560
1559
|
sessionCode: string;
|
|
@@ -2062,6 +2061,7 @@ export declare const useSession: (mediator: IMediatorModule) => {
|
|
|
2062
2061
|
sessionProperty?: {
|
|
2063
2062
|
isAutoCalcPrompt?: boolean;
|
|
2064
2063
|
isAutoClear?: boolean;
|
|
2064
|
+
labels?: string[];
|
|
2065
2065
|
};
|
|
2066
2066
|
}>;
|
|
2067
2067
|
isCurrentLoading: import("vue").Ref<boolean, boolean>;
|
package/dist/type.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { IRequestConfig, ISSEProtocol } from './http/fetch';
|
|
2
2
|
import type { IResponse } from './http/fetch';
|
|
3
|
+
import type { MaybeRequestValue, RequestData, RequestHeaders } from './http/fetch/resolve-request-value';
|
|
4
|
+
export type { MaybeRequestValue, RequestData, RequestHeaders } from './http/fetch/resolve-request-value';
|
|
3
5
|
export interface IUseChatHelperOptions {
|
|
4
6
|
protocol?: ISSEProtocol;
|
|
5
7
|
/** 自定义拦截器,优先级高于内置 requestData 拦截器 */
|
|
@@ -7,10 +9,10 @@ export interface IUseChatHelperOptions {
|
|
|
7
9
|
request?: (config: IRequestConfig) => IRequestConfig;
|
|
8
10
|
response?: (response: IResponse) => IResponse;
|
|
9
11
|
};
|
|
10
|
-
/**
|
|
12
|
+
/** 全局默认请求配置,通过内置拦截器自动合并到每次请求(支持对象/函数/ref 延迟求值) */
|
|
11
13
|
requestData: {
|
|
12
|
-
data?:
|
|
13
|
-
headers?:
|
|
14
|
+
data?: MaybeRequestValue<RequestData>;
|
|
15
|
+
headers?: MaybeRequestValue<RequestHeaders>;
|
|
14
16
|
urlPrefix: string;
|
|
15
17
|
};
|
|
16
18
|
}
|