@tombcato/ai-selector-core 0.1.3 → 0.1.9
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/index.d.ts +15 -15
- package/dist/index.js +5387 -315
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +14 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +7 -3
- package/src/api.ts +6 -2
- package/src/index.ts +4 -1
- package/src/providers.ts +1 -1
- package/src/storage.ts +60 -3
- package/src/strategies.ts +70 -35
- package/src/types.ts +0 -12
package/dist/index.d.ts
CHANGED
|
@@ -63,17 +63,8 @@ export declare interface CustomProviderDefinition {
|
|
|
63
63
|
models?: Model[];
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
/**
|
|
67
|
-
export declare
|
|
68
|
-
name: string;
|
|
69
|
-
baseUrl: string;
|
|
70
|
-
needsApiKey: boolean;
|
|
71
|
-
apiFormat: ApiFormat;
|
|
72
|
-
supportsModelsApi?: boolean;
|
|
73
|
-
icon?: string;
|
|
74
|
-
/** 静态模型列表(当不支持 /models API 时使用) */
|
|
75
|
-
models?: Model[];
|
|
76
|
-
}
|
|
66
|
+
/** 默认存储适配器(加密) */
|
|
67
|
+
export declare const defaultStorageAdapter: StorageAdapter;
|
|
77
68
|
|
|
78
69
|
export declare interface DirectChatOptions {
|
|
79
70
|
apiFormat: string;
|
|
@@ -94,6 +85,12 @@ export declare interface DirectChatResult {
|
|
|
94
85
|
latencyMs?: number;
|
|
95
86
|
}
|
|
96
87
|
|
|
88
|
+
/**
|
|
89
|
+
* 加密存储适配器(默认)
|
|
90
|
+
* 使用 AES 加密存储,防止 API Key 明文泄露
|
|
91
|
+
*/
|
|
92
|
+
export declare const encryptedStorageAdapter: StorageAdapter;
|
|
93
|
+
|
|
97
94
|
export declare type FetcherActionType = 'fetchModels' | 'checkConnection';
|
|
98
95
|
|
|
99
96
|
export declare interface FetcherParams {
|
|
@@ -199,9 +196,7 @@ export declare type I18NKeys = keyof typeof I18N['zh'];
|
|
|
199
196
|
|
|
200
197
|
export declare type Language = keyof typeof I18N;
|
|
201
198
|
|
|
202
|
-
/**
|
|
203
|
-
* Default localStorage adapter
|
|
204
|
-
*/
|
|
199
|
+
/** @deprecated 使用 encryptedStorageAdapter 或 plainStorageAdapter */
|
|
205
200
|
export declare const localStorageAdapter: StorageAdapter;
|
|
206
201
|
|
|
207
202
|
export declare interface Model {
|
|
@@ -218,6 +213,11 @@ export declare interface Model {
|
|
|
218
213
|
*/
|
|
219
214
|
export declare type ModelFetcher = (params: FetcherParams) => Promise<any>;
|
|
220
215
|
|
|
216
|
+
/**
|
|
217
|
+
* 明文存储适配器(不推荐)
|
|
218
|
+
*/
|
|
219
|
+
export declare const plainStorageAdapter: StorageAdapter;
|
|
220
|
+
|
|
221
221
|
export declare interface Provider {
|
|
222
222
|
id: string;
|
|
223
223
|
name: string;
|
|
@@ -275,7 +275,7 @@ export declare interface ProviderStrategy {
|
|
|
275
275
|
buildChatPayload: (model: string, messages: Array<{
|
|
276
276
|
role: string;
|
|
277
277
|
content: string;
|
|
278
|
-
}>, maxTokens
|
|
278
|
+
}>, maxTokens?: number) => Record<string, unknown>;
|
|
279
279
|
parseChatResponse: (data: any) => string;
|
|
280
280
|
buildHeaders: (apiKey: string) => Record<string, string>;
|
|
281
281
|
}
|