@isdk/ai-tool 0.0.6 → 0.0.8
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/chunk-B7IE5ATQ.mjs +1 -0
- package/dist/chunk-U5DDQYSF.mjs +1 -22
- package/dist/funcs.d.mts +2 -2
- package/dist/funcs.d.ts +2 -2
- package/dist/funcs.js +1 -5020
- package/dist/funcs.mjs +1 -37
- package/dist/{index-D4KjfAKl.d.mts → index-Dgo3ZXPQ.d.mts} +29 -14
- package/dist/{index-D4KjfAKl.d.ts → index-Dgo3ZXPQ.d.ts} +29 -14
- package/dist/index.d.mts +372 -56
- package/dist/index.d.ts +372 -56
- package/dist/index.js +1 -5245
- package/dist/index.mjs +1 -402
- package/dist/test/util.js +1 -97
- package/dist/test/util.mjs +1 -60
- package/docs/classes/AbortError.md +8 -8
- package/docs/classes/AlreadyExistsError.md +8 -8
- package/docs/classes/BaseError.md +8 -8
- package/docs/classes/CancelableAbility.md +431 -0
- package/docs/classes/ClientTools.md +101 -51
- package/docs/classes/CommonError.md +8 -8
- package/docs/classes/EventClient.md +123 -73
- package/docs/classes/EventServer.md +121 -71
- package/docs/classes/EventToolFunc.md +91 -41
- package/docs/classes/FStringPromptTemplate.md +18 -18
- package/docs/classes/FewShotPromptTemplate.md +22 -22
- package/docs/classes/GolangPromptTemplate.md +18 -18
- package/docs/classes/HFEnvironment.md +9 -9
- package/docs/classes/HFInterpreter.md +17 -17
- package/docs/classes/HFTemplate.md +4 -4
- package/docs/classes/HfPromptTemplate.md +18 -18
- package/docs/classes/IntSet.md +249 -0
- package/docs/classes/NotFoundError.md +8 -8
- package/docs/classes/NotImplementationError.md +8 -8
- package/docs/classes/PromptExampleSelector.md +8 -8
- package/docs/classes/PromptTemplate.md +17 -17
- package/docs/classes/ReadableStreamError.md +8 -8
- package/docs/classes/ResClientTools.md +107 -57
- package/docs/classes/ResServerTools.md +105 -55
- package/docs/classes/SSEChannel.md +15 -15
- package/docs/classes/Semaphore.md +273 -0
- package/docs/classes/ServerTools.md +98 -48
- package/docs/classes/TaskAbortController.md +157 -0
- package/docs/classes/ToolFunc.md +80 -38
- package/docs/enums/AsyncFeatureBits.md +41 -0
- package/docs/enums/AsyncFeatures.md +41 -0
- package/docs/enums/ErrorCode.md +41 -19
- package/docs/enums/XXHashAlgorithm.md +2 -2
- package/docs/interfaces/AIChatAssistantMessageParam.md +6 -6
- package/docs/interfaces/AIChatContentPartImage.md +2 -2
- package/docs/interfaces/AIChatContentPartText.md +2 -2
- package/docs/interfaces/AIChatMessageParamBase.md +1 -1
- package/docs/interfaces/AIChatMessageToolCall.md +3 -3
- package/docs/interfaces/AIChatSystemMessageParam.md +3 -3
- package/docs/interfaces/AIChatToolMessageParam.md +4 -4
- package/docs/interfaces/AIChatUserMessageParam.md +7 -7
- package/docs/interfaces/AIResult.md +16 -5
- package/docs/interfaces/AIStreamParser.md +1 -1
- package/docs/interfaces/AIStreamParserOptions.md +1 -1
- package/docs/interfaces/BaseFunc.md +7 -7
- package/docs/interfaces/BaseFuncItem.md +6 -6
- package/docs/interfaces/CancelableAbilityOptions.md +126 -0
- package/docs/interfaces/ClientFuncItem.md +10 -10
- package/docs/interfaces/DotenvExpandOptions.md +3 -3
- package/docs/interfaces/DotenvExpandOutput.md +2 -2
- package/docs/interfaces/EventClientFuncParams.md +4 -4
- package/docs/interfaces/EventServerFuncParams.md +5 -5
- package/docs/interfaces/FewShotPromptTemplateOptions.md +11 -11
- package/docs/interfaces/FuncItem.md +7 -7
- package/docs/interfaces/FuncParam.md +16 -5
- package/docs/interfaces/PromptExampleSelectorOptions.md +2 -2
- package/docs/interfaces/PromptTemplateOptions.md +6 -6
- package/docs/interfaces/RemoteFuncItem.md +10 -10
- package/docs/interfaces/ResClientFuncParams.md +2 -2
- package/docs/interfaces/ResServerFuncParams.md +5 -5
- package/docs/interfaces/SanitizeFilenameOptions.md +2 -2
- package/docs/interfaces/ServerFuncItem.md +11 -11
- package/docs/interfaces/ServerFuncParams.md +2 -2
- package/docs/interfaces/StreamCallbacksAndOptions.md +124 -0
- package/docs/interfaces/TaskAbortControllers.md +7 -0
- package/docs/interfaces/TaskPromise.md +151 -0
- package/docs/interfaces/ToolFuncPackage.md +63 -0
- package/docs/modules.md +1156 -225
- package/package.json +5 -6
- package/dist/chunk-6AXCY6TJ.mjs +0 -5090
- package/docs/interfaces/AIStreamCallbacksAndOptions.md +0 -158
package/dist/funcs.mjs
CHANGED
|
@@ -1,37 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EventClient,
|
|
3
|
-
EventServer,
|
|
4
|
-
EventToolFunc,
|
|
5
|
-
_lrucache,
|
|
6
|
-
createLRUCache,
|
|
7
|
-
event,
|
|
8
|
-
eventClient,
|
|
9
|
-
eventServer,
|
|
10
|
-
getDefaultSimilarPassingScore,
|
|
11
|
-
isSimilar,
|
|
12
|
-
lrucache,
|
|
13
|
-
mergeSegments,
|
|
14
|
-
registerCoreTools,
|
|
15
|
-
segments,
|
|
16
|
-
similarity,
|
|
17
|
-
splitSegments
|
|
18
|
-
} from "./chunk-6AXCY6TJ.mjs";
|
|
19
|
-
import "./chunk-U5DDQYSF.mjs";
|
|
20
|
-
export {
|
|
21
|
-
EventClient,
|
|
22
|
-
EventServer,
|
|
23
|
-
EventToolFunc,
|
|
24
|
-
_lrucache,
|
|
25
|
-
createLRUCache,
|
|
26
|
-
event,
|
|
27
|
-
eventClient,
|
|
28
|
-
eventServer,
|
|
29
|
-
getDefaultSimilarPassingScore,
|
|
30
|
-
isSimilar,
|
|
31
|
-
lrucache,
|
|
32
|
-
mergeSegments,
|
|
33
|
-
registerCoreTools,
|
|
34
|
-
segments,
|
|
35
|
-
similarity,
|
|
36
|
-
splitSegments
|
|
37
|
-
};
|
|
1
|
+
import{EventClient as m,EventServer as o,EventToolFunc as r,_lrucache as p,createLRUCache as t,event as c,eventClient as h,eventServer as i,lrucache as j,registerCoreTools as k}from"./chunk-B7IE5ATQ.mjs";import"./chunk-U5DDQYSF.mjs";export{m as EventClient,o as EventServer,r as EventToolFunc,p as _lrucache,t as createLRUCache,c as event,h as eventClient,i as eventServer,j as lrucache,k as registerCoreTools};
|
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
import { EventEmitter, Event } from 'events-ex';
|
|
2
2
|
import { AdvancePropertyManager } from 'property-manager';
|
|
3
3
|
import { ICacheOptions, Cache } from 'secondary-cache';
|
|
4
|
-
import { IncomingMessage, ServerResponse } from 'http';
|
|
5
4
|
import { AbstractError } from 'abstract-error';
|
|
5
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
6
6
|
|
|
7
|
+
declare const ToolAsyncMultiTaskBit = 0;
|
|
8
|
+
declare const ToolAsyncCancelableBit = 1;
|
|
9
|
+
declare const ToolAsyncPriorityBit = 2;
|
|
10
|
+
declare enum AsyncFeatureBits {
|
|
11
|
+
MultiTask = 0,
|
|
12
|
+
Cancelable = 1,
|
|
13
|
+
Priority = 2
|
|
14
|
+
}
|
|
15
|
+
declare enum AsyncFeatures {
|
|
16
|
+
MultiTask = 1,// B0001
|
|
17
|
+
Cancelable = 2,// B010
|
|
18
|
+
Priority = 4
|
|
19
|
+
}
|
|
7
20
|
type FuncParamType = string;
|
|
8
21
|
interface FuncParam {
|
|
9
22
|
name?: string;
|
|
10
23
|
type?: FuncParamType;
|
|
11
24
|
required?: boolean;
|
|
12
25
|
description?: string;
|
|
26
|
+
asyncFeatures?: number;
|
|
13
27
|
depends?: {
|
|
14
28
|
[name: string]: ToolFunc;
|
|
15
29
|
};
|
|
@@ -35,6 +49,11 @@ interface BaseFunc extends BaseFuncItem {
|
|
|
35
49
|
interface Funcs {
|
|
36
50
|
[name: string]: ToolFunc;
|
|
37
51
|
}
|
|
52
|
+
interface ToolFuncPackage {
|
|
53
|
+
name: string;
|
|
54
|
+
register: (data?: any) => void;
|
|
55
|
+
unregister?: () => void;
|
|
56
|
+
}
|
|
38
57
|
declare interface ToolFunc extends BaseFunc {
|
|
39
58
|
[name: string]: any;
|
|
40
59
|
}
|
|
@@ -45,6 +64,7 @@ declare class ToolFunc extends AdvancePropertyManager {
|
|
|
45
64
|
static list(): Funcs;
|
|
46
65
|
static getByTag(tagName: string): ToolFunc | undefined;
|
|
47
66
|
static getAllByTag(tagName: string): ToolFunc[];
|
|
67
|
+
static hasAsyncFeature(feature: AsyncFeatureBits): boolean;
|
|
48
68
|
static run(name: string, params?: any): Promise<any>;
|
|
49
69
|
static runSync(name: string, params?: any): any;
|
|
50
70
|
static getFunc(name: string): any;
|
|
@@ -70,6 +90,7 @@ declare class ToolFunc extends AdvancePropertyManager {
|
|
|
70
90
|
runWithPos(...params: any[]): Promise<any>;
|
|
71
91
|
runWithPosAs(name: string, ...params: any[]): Promise<any>;
|
|
72
92
|
getFuncWithPos(name?: string): any;
|
|
93
|
+
hasAsyncFeature(feature: AsyncFeatureBits): boolean;
|
|
73
94
|
}
|
|
74
95
|
declare const ToolFuncSchema: {
|
|
75
96
|
name: {
|
|
@@ -98,6 +119,9 @@ declare const ToolFuncSchema: {
|
|
|
98
119
|
tags: {
|
|
99
120
|
type: string[];
|
|
100
121
|
};
|
|
122
|
+
asyncFeatures: {
|
|
123
|
+
type: string;
|
|
124
|
+
};
|
|
101
125
|
};
|
|
102
126
|
|
|
103
127
|
declare const PASSING_SCORE = 0.618;
|
|
@@ -136,6 +160,7 @@ interface RemoteFuncItem extends BaseFuncItem {
|
|
|
136
160
|
type ErrorCodeType = number | string;
|
|
137
161
|
declare enum ErrorCode {
|
|
138
162
|
OK = 200,
|
|
163
|
+
Accepted = 202,
|
|
139
164
|
BadRequest = 400,
|
|
140
165
|
InvalidArgument = 400,
|
|
141
166
|
Unauthorized = 401,
|
|
@@ -147,12 +172,13 @@ declare enum ErrorCode {
|
|
|
147
172
|
RequestTimeout = 408,
|
|
148
173
|
Conflict = 409,
|
|
149
174
|
Corruption = 409,
|
|
175
|
+
TooManyRequests = 429,
|
|
150
176
|
Aborted = 499,
|
|
151
177
|
InternalError = 500,
|
|
152
178
|
NotImplemented = 501,
|
|
153
179
|
NotSupported = 501,
|
|
154
180
|
BadGateway = 502,
|
|
155
|
-
ServiceUnavailable = 503
|
|
181
|
+
ServiceUnavailable = 503,// task is processing and Retry-After
|
|
156
182
|
GatewayTimeout = 504
|
|
157
183
|
}
|
|
158
184
|
declare const InternalErrorCode = ErrorCode.InternalError;
|
|
@@ -446,17 +472,6 @@ declare function _lrucache(this: ToolFunc, { key, value, options }?: {
|
|
|
446
472
|
declare function createLRUCache(name: string, options?: ICacheOptions | number): ToolFunc;
|
|
447
473
|
declare const lrucache: ToolFunc;
|
|
448
474
|
|
|
449
|
-
declare const similarity: ServerTools;
|
|
450
|
-
|
|
451
|
-
declare function getDefaultSimilarPassingScore(modelId: string): number;
|
|
452
|
-
declare const isSimilar: ServerTools;
|
|
453
|
-
|
|
454
|
-
declare const splitSegments: ServerTools;
|
|
455
|
-
|
|
456
|
-
declare const mergeSegments: ServerTools;
|
|
457
|
-
|
|
458
|
-
declare const segments: ServerTools;
|
|
459
|
-
|
|
460
475
|
interface ResClientFuncParams {
|
|
461
476
|
id?: string | number;
|
|
462
477
|
act?: string;
|
|
@@ -603,4 +618,4 @@ declare const eventServer: EventServer;
|
|
|
603
618
|
|
|
604
619
|
declare function registerCoreTools(): void;
|
|
605
620
|
|
|
606
|
-
export {
|
|
621
|
+
export { lrucache as $, AsyncFeatures as A, BaseError as B, CommonError as C, type BaseFunc as D, type ErrorCodeType as E, type FuncParamType as F, type Funcs as G, type ToolFuncPackage as H, InternalErrorCode as I, ToolFuncSchema as J, type ClientFuncItem as K, ClientTools as L, ClientToolFuncSchema as M, NotImplementedErrorCode as N, type ServerFuncParams as O, PASSING_SCORE as P, type ServerFuncItem as Q, RemoteToolFuncSchema as R, SSEChannelAlreadyClosedErrCode as S, ToolFunc as T, ServerTools as U, ServerToolFuncSchema as V, registerCoreTools as W, EventToolFunc as X, event as Y, createLRUCache as Z, _lrucache as _, type AIModelNameRules as a, type EventClientFuncParams as a0, EventClient as a1, eventClient as a2, type EventServerFuncParams as a3, EventServer as a4, eventServer as a5, type ResClientFuncParams as a6, ResClientTools as a7, ResClientToolsSchema as a8, type ResServerFuncParams as a9, ResServerTools as aa, ResServerToolsSchema as ab, ActionNames as b, type ActionName as c, type AIModelNameRuleFn as d, type AIModelNameRule as e, type RemoteFuncItem as f, ErrorCode as g, NotFoundErrorCode as h, AlreadyExistsErrorCode as i, AbortErrorCode as j, NotImplementationError as k, NotFoundError as l, AlreadyExistsError as m, AbortError as n, createError as o, SSEChannel as p, ToolAsyncMultiTaskBit as q, ToolAsyncCancelableBit as r, ToolAsyncPriorityBit as s, throwError as t, AsyncFeatureBits as u, type FuncParam as v, type FuncParams as w, type TFunc as x, type BaseFuncItem as y, type FuncItem as z };
|
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
import { EventEmitter, Event } from 'events-ex';
|
|
2
2
|
import { AdvancePropertyManager } from 'property-manager';
|
|
3
3
|
import { ICacheOptions, Cache } from 'secondary-cache';
|
|
4
|
-
import { IncomingMessage, ServerResponse } from 'http';
|
|
5
4
|
import { AbstractError } from 'abstract-error';
|
|
5
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
6
6
|
|
|
7
|
+
declare const ToolAsyncMultiTaskBit = 0;
|
|
8
|
+
declare const ToolAsyncCancelableBit = 1;
|
|
9
|
+
declare const ToolAsyncPriorityBit = 2;
|
|
10
|
+
declare enum AsyncFeatureBits {
|
|
11
|
+
MultiTask = 0,
|
|
12
|
+
Cancelable = 1,
|
|
13
|
+
Priority = 2
|
|
14
|
+
}
|
|
15
|
+
declare enum AsyncFeatures {
|
|
16
|
+
MultiTask = 1,// B0001
|
|
17
|
+
Cancelable = 2,// B010
|
|
18
|
+
Priority = 4
|
|
19
|
+
}
|
|
7
20
|
type FuncParamType = string;
|
|
8
21
|
interface FuncParam {
|
|
9
22
|
name?: string;
|
|
10
23
|
type?: FuncParamType;
|
|
11
24
|
required?: boolean;
|
|
12
25
|
description?: string;
|
|
26
|
+
asyncFeatures?: number;
|
|
13
27
|
depends?: {
|
|
14
28
|
[name: string]: ToolFunc;
|
|
15
29
|
};
|
|
@@ -35,6 +49,11 @@ interface BaseFunc extends BaseFuncItem {
|
|
|
35
49
|
interface Funcs {
|
|
36
50
|
[name: string]: ToolFunc;
|
|
37
51
|
}
|
|
52
|
+
interface ToolFuncPackage {
|
|
53
|
+
name: string;
|
|
54
|
+
register: (data?: any) => void;
|
|
55
|
+
unregister?: () => void;
|
|
56
|
+
}
|
|
38
57
|
declare interface ToolFunc extends BaseFunc {
|
|
39
58
|
[name: string]: any;
|
|
40
59
|
}
|
|
@@ -45,6 +64,7 @@ declare class ToolFunc extends AdvancePropertyManager {
|
|
|
45
64
|
static list(): Funcs;
|
|
46
65
|
static getByTag(tagName: string): ToolFunc | undefined;
|
|
47
66
|
static getAllByTag(tagName: string): ToolFunc[];
|
|
67
|
+
static hasAsyncFeature(feature: AsyncFeatureBits): boolean;
|
|
48
68
|
static run(name: string, params?: any): Promise<any>;
|
|
49
69
|
static runSync(name: string, params?: any): any;
|
|
50
70
|
static getFunc(name: string): any;
|
|
@@ -70,6 +90,7 @@ declare class ToolFunc extends AdvancePropertyManager {
|
|
|
70
90
|
runWithPos(...params: any[]): Promise<any>;
|
|
71
91
|
runWithPosAs(name: string, ...params: any[]): Promise<any>;
|
|
72
92
|
getFuncWithPos(name?: string): any;
|
|
93
|
+
hasAsyncFeature(feature: AsyncFeatureBits): boolean;
|
|
73
94
|
}
|
|
74
95
|
declare const ToolFuncSchema: {
|
|
75
96
|
name: {
|
|
@@ -98,6 +119,9 @@ declare const ToolFuncSchema: {
|
|
|
98
119
|
tags: {
|
|
99
120
|
type: string[];
|
|
100
121
|
};
|
|
122
|
+
asyncFeatures: {
|
|
123
|
+
type: string;
|
|
124
|
+
};
|
|
101
125
|
};
|
|
102
126
|
|
|
103
127
|
declare const PASSING_SCORE = 0.618;
|
|
@@ -136,6 +160,7 @@ interface RemoteFuncItem extends BaseFuncItem {
|
|
|
136
160
|
type ErrorCodeType = number | string;
|
|
137
161
|
declare enum ErrorCode {
|
|
138
162
|
OK = 200,
|
|
163
|
+
Accepted = 202,
|
|
139
164
|
BadRequest = 400,
|
|
140
165
|
InvalidArgument = 400,
|
|
141
166
|
Unauthorized = 401,
|
|
@@ -147,12 +172,13 @@ declare enum ErrorCode {
|
|
|
147
172
|
RequestTimeout = 408,
|
|
148
173
|
Conflict = 409,
|
|
149
174
|
Corruption = 409,
|
|
175
|
+
TooManyRequests = 429,
|
|
150
176
|
Aborted = 499,
|
|
151
177
|
InternalError = 500,
|
|
152
178
|
NotImplemented = 501,
|
|
153
179
|
NotSupported = 501,
|
|
154
180
|
BadGateway = 502,
|
|
155
|
-
ServiceUnavailable = 503
|
|
181
|
+
ServiceUnavailable = 503,// task is processing and Retry-After
|
|
156
182
|
GatewayTimeout = 504
|
|
157
183
|
}
|
|
158
184
|
declare const InternalErrorCode = ErrorCode.InternalError;
|
|
@@ -446,17 +472,6 @@ declare function _lrucache(this: ToolFunc, { key, value, options }?: {
|
|
|
446
472
|
declare function createLRUCache(name: string, options?: ICacheOptions | number): ToolFunc;
|
|
447
473
|
declare const lrucache: ToolFunc;
|
|
448
474
|
|
|
449
|
-
declare const similarity: ServerTools;
|
|
450
|
-
|
|
451
|
-
declare function getDefaultSimilarPassingScore(modelId: string): number;
|
|
452
|
-
declare const isSimilar: ServerTools;
|
|
453
|
-
|
|
454
|
-
declare const splitSegments: ServerTools;
|
|
455
|
-
|
|
456
|
-
declare const mergeSegments: ServerTools;
|
|
457
|
-
|
|
458
|
-
declare const segments: ServerTools;
|
|
459
|
-
|
|
460
475
|
interface ResClientFuncParams {
|
|
461
476
|
id?: string | number;
|
|
462
477
|
act?: string;
|
|
@@ -603,4 +618,4 @@ declare const eventServer: EventServer;
|
|
|
603
618
|
|
|
604
619
|
declare function registerCoreTools(): void;
|
|
605
620
|
|
|
606
|
-
export {
|
|
621
|
+
export { lrucache as $, AsyncFeatures as A, BaseError as B, CommonError as C, type BaseFunc as D, type ErrorCodeType as E, type FuncParamType as F, type Funcs as G, type ToolFuncPackage as H, InternalErrorCode as I, ToolFuncSchema as J, type ClientFuncItem as K, ClientTools as L, ClientToolFuncSchema as M, NotImplementedErrorCode as N, type ServerFuncParams as O, PASSING_SCORE as P, type ServerFuncItem as Q, RemoteToolFuncSchema as R, SSEChannelAlreadyClosedErrCode as S, ToolFunc as T, ServerTools as U, ServerToolFuncSchema as V, registerCoreTools as W, EventToolFunc as X, event as Y, createLRUCache as Z, _lrucache as _, type AIModelNameRules as a, type EventClientFuncParams as a0, EventClient as a1, eventClient as a2, type EventServerFuncParams as a3, EventServer as a4, eventServer as a5, type ResClientFuncParams as a6, ResClientTools as a7, ResClientToolsSchema as a8, type ResServerFuncParams as a9, ResServerTools as aa, ResServerToolsSchema as ab, ActionNames as b, type ActionName as c, type AIModelNameRuleFn as d, type AIModelNameRule as e, type RemoteFuncItem as f, ErrorCode as g, NotFoundErrorCode as h, AlreadyExistsErrorCode as i, AbortErrorCode as j, NotImplementationError as k, NotFoundError as l, AlreadyExistsError as m, AbortError as n, createError as o, SSEChannel as p, ToolAsyncMultiTaskBit as q, ToolAsyncCancelableBit as r, ToolAsyncPriorityBit as s, throwError as t, AsyncFeatureBits as u, type FuncParam as v, type FuncParams as w, type TFunc as x, type BaseFuncItem as y, type FuncItem as z };
|