@trymirai/uzu 0.1.50 → 0.2.0
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 +41 -1
- package/bridging/grammarConfig.d.mts +13 -0
- package/bridging/grammarConfig.d.mts.map +1 -0
- package/bridging/grammarConfig.d.ts +13 -0
- package/bridging/grammarConfig.d.ts.map +1 -0
- package/bridging/grammarConfig.js +36 -0
- package/bridging/grammarConfig.js.map +1 -0
- package/bridging/grammarConfig.mjs +31 -0
- package/bridging/grammarConfig.mjs.map +1 -0
- package/bridging/parsedText.d.mts +2 -0
- package/bridging/parsedText.d.mts.map +1 -1
- package/bridging/parsedText.d.ts +2 -0
- package/bridging/parsedText.d.ts.map +1 -1
- package/bridging/parsedText.js +8 -0
- package/bridging/parsedText.js.map +1 -1
- package/bridging/parsedText.mjs +8 -0
- package/bridging/parsedText.mjs.map +1 -1
- package/bridging/runConfig.d.mts +3 -0
- package/bridging/runConfig.d.mts.map +1 -1
- package/bridging/runConfig.d.ts +3 -0
- package/bridging/runConfig.d.ts.map +1 -1
- package/bridging/runConfig.js +14 -6
- package/bridging/runConfig.js.map +1 -1
- package/bridging/runConfig.mjs +14 -6
- package/bridging/runConfig.mjs.map +1 -1
- package/bridging/samplingMethod.d.mts +1 -1
- package/bridging/samplingMethod.d.mts.map +1 -1
- package/bridging/samplingMethod.d.ts +1 -1
- package/bridging/samplingMethod.d.ts.map +1 -1
- package/bridging/samplingMethod.js +4 -1
- package/bridging/samplingMethod.js.map +1 -1
- package/bridging/samplingMethod.mjs +4 -1
- package/bridging/samplingMethod.mjs.map +1 -1
- package/index.d.mts +1 -0
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +3 -1
- package/index.js.map +1 -1
- package/index.mjs +1 -0
- package/index.mjs.map +1 -1
- package/interactors/chatSessionInteractor.d.mts +2 -0
- package/interactors/chatSessionInteractor.d.mts.map +1 -1
- package/interactors/chatSessionInteractor.d.ts +2 -0
- package/interactors/chatSessionInteractor.d.ts.map +1 -1
- package/interactors/chatSessionInteractor.js +4 -0
- package/interactors/chatSessionInteractor.js.map +1 -1
- package/interactors/chatSessionInteractor.mjs +4 -0
- package/interactors/chatSessionInteractor.mjs.map +1 -1
- package/internal/tslib.js +55 -0
- package/napi/uzu.d.ts +11 -5
- package/napi/uzu.js +2 -0
- package/napi/uzu.mjs +1 -0
- package/napi/uzu.node +0 -0
- package/package.json +4 -1
- package/src/bridging/grammarConfig.ts +40 -0
- package/src/bridging/parsedText.ts +10 -0
- package/src/bridging/runConfig.ts +22 -6
- package/src/bridging/samplingMethod.ts +9 -1
- package/src/index.ts +1 -0
- package/src/interactors/chatSessionInteractor.ts +6 -0
- package/src/napi/uzu.d.ts +11 -5
- package/src/napi/uzu.js +2 -0
- package/src/napi/uzu.mjs +1 -0
- package/src/napi/uzu.node +0 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.mts.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ChatSession } from "../bridging/chatSession.js";
|
|
2
|
+
import { GrammarConfig } from "../bridging/grammarConfig.js";
|
|
2
3
|
import { Input } from "../bridging/input.js";
|
|
3
4
|
import { Message } from "../bridging/message.js";
|
|
4
5
|
import { Output } from "../bridging/output.js";
|
|
@@ -17,6 +18,7 @@ export declare class ChatSessionInteractor implements Interactor<ChatSession> {
|
|
|
17
18
|
enableThinking(enableThinking: boolean): ChatSessionInteractor;
|
|
18
19
|
samplingPolicy(samplingPolicy: SamplingPolicy): ChatSessionInteractor;
|
|
19
20
|
samplingMethod(samplingMethod: SamplingMethod): ChatSessionInteractor;
|
|
21
|
+
grammarConfig(grammarConfig: GrammarConfig | null): ChatSessionInteractor;
|
|
20
22
|
run(input: Input, progress?: (partialOutput: Output) => boolean): Promise<Output>;
|
|
21
23
|
reply(text: string, progress?: (partialOutput: Output) => boolean): Promise<Output>;
|
|
22
24
|
replyToMessages(messages: Message[], progress?: (partialOutput: Output) => boolean): Promise<Output>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatSessionInteractor.d.ts","sourceRoot":"","sources":["../src/interactors/chatSessionInteractor.ts"],"names":[],"mappings":"OAAO,EAAE,WAAW,EAAE;OACf,EAAE,KAAK,EAAE;OACT,EAAE,OAAO,EAAE;OACX,EAAE,MAAM,EAAE;OACV,EAAE,SAAS,EAAE;OACb,EAAE,cAAc,EAAE;OAClB,EAAE,cAAc,EAAE;OAClB,EAAE,mBAAmB,EAAE;OACvB,EAAE,UAAU,EAAE,gBAAgB,EAAE;AAEvC,qBAAa,qBAAsB,YAAW,UAAU,CAAC,WAAW,CAAC;IACjE,QAAQ,CAAC,eAAe,EAAE,mBAAmB,CAAC;IAC9C,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAC/C,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;gBAGvB,eAAe,EAAE,mBAAmB,EACpC,OAAO,EAAE,gBAAgB,CAAC,WAAW,CAAC,EACtC,MAAM,EAAE,SAAS;IAOf,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC;IAMtC,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,qBAAqB;IAKvD,cAAc,CAAC,cAAc,EAAE,OAAO,GAAG,qBAAqB;IAK9D,cAAc,CAAC,cAAc,EAAE,cAAc,GAAG,qBAAqB;IAKrE,cAAc,CAAC,cAAc,EAAE,cAAc,GAAG,qBAAqB;
|
|
1
|
+
{"version":3,"file":"chatSessionInteractor.d.ts","sourceRoot":"","sources":["../src/interactors/chatSessionInteractor.ts"],"names":[],"mappings":"OAAO,EAAE,WAAW,EAAE;OACf,EAAE,aAAa,EAAE;OACjB,EAAE,KAAK,EAAE;OACT,EAAE,OAAO,E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config.withSamplingPolicy(samplingPolicy_1.SamplingPolicy.custom(samplingMethod));
|
|
30
30
|
return new ChatSessionInteractor(this.modelInteractor, this.entity, config);
|
|
31
31
|
}
|
|
32
|
+
grammarConfig(grammarConfig) {
|
|
33
|
+
const config = this.config.withGrammarConfig(grammarConfig);
|
|
34
|
+
return new ChatSessionInteractor(this.modelInteractor, this.entity, config);
|
|
35
|
+
}
|
|
32
36
|
/* Run */
|
|
33
37
|
async run(input, progress = () => true) {
|
|
34
38
|
const outputPromise = (async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatSessionInteractor.js","sourceRoot":"","sources":["../src/interactors/chatSessionInteractor.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"chatSessionInteractor.js","sourceRoot":"","sources":["../src/interactors/chatSessionInteractor.ts"],"names":[],"mappings":";;;AAEA,gDAA0C;AAK1C,kEAA4D;AAI5D,MAAa,qBAAqB;IAK9B,YACI,eAAoC,EACpC,OAAsC,EACtC,MAAiB;QAEjB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,QAAQ;QACV,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,YAAY;IAEZ,WAAW,CAAC,WAAmB;QAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;QACxD,OAAO,IAAI,qBAAqB,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChF,CAAC;IAED,cAAc,CAAC,cAAuB;QAClC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;QAC9D,OAAO,IAAI,qBAAqB,CAAC,IAAI,CAAC,eA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E,CAAC,IAAI;QAC/E,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,aAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,eAAe,CACjB,QAAmB,EACnB,WAA+C,GAAG,EAAE,CAAC,IAAI;QAEzD,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,aAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC;CACJ;AApED,sDAoEC"}
|
|
@@ -26,6 +26,10 @@ export class ChatSessionInteractor {
|
|
|
26
26
|
const config = this.config.withSamplingPolicy(SamplingPolicy.custom(samplingMethod));
|
|
27
27
|
return new ChatSessionInteractor(this.modelInteractor, this.entity, config);
|
|
28
28
|
}
|
|
29
|
+
grammarConfig(grammarConfig) {
|
|
30
|
+
const config = this.config.withGrammarConfig(grammarConfig);
|
|
31
|
+
return new ChatSessionInteractor(this.modelInteractor, this.entity, config);
|
|
32
|
+
}
|
|
29
33
|
/* Run */
|
|
30
34
|
async run(input, progress = () => true) {
|
|
31
35
|
const outputPromise = (async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatSessionInteractor.mjs","sourceRoot":"","sources":["../src/interactors/chatSessionInteractor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chatSessionInteractor.mjs","sourceRoot":"","sources":["../src/interactors/chatSessionInteractor.ts"],"names":[],"mappings":"OAEO,EAAE,KAAK,EAAE;OAKT,EAAE,cAAc,EAAE;AAIzB,MAAM,OAAO,qBAAqB;IAK9B,YACI,eAAoC,EACpC,OAAsC,EACtC,MAAiB;QAEjB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,QAAQ;QACV,OAAO,MAA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E,CAAC,IAAI;QAC7E,MAAM,aAAa,GAAG,CAAC,KAAK,IAAI,EAAE;YAC9B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;YACtC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACzD,OAAO,MAAM,CAAC;QAClB,CAAC,CAAC,EAAE,CAAC;QACL,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC;QACnC,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,IAAY,EAAE,WAA+C,GAAG,EAAE,CAAC,IAAI;QAC/E,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,eAAe,CACjB,QAAmB,EACnB,WAA+C,GAAG,EAAE,CAAC,IAAI;QAEzD,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC;CACJ"}
|
package/internal/tslib.js
CHANGED
|
@@ -1,2 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.__setModuleDefault = exports.__createBinding = void 0;
|
|
4
|
+
exports.__importStar = __importStar;
|
|
5
|
+
var __createBinding = Object.create
|
|
6
|
+
? function (o, m, k, k2) {
|
|
7
|
+
if (k2 === void 0)
|
|
8
|
+
k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () {
|
|
14
|
+
return m[k];
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}
|
|
20
|
+
: function (o, m, k, k2) {
|
|
21
|
+
if (k2 === void 0)
|
|
22
|
+
k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
};
|
|
25
|
+
exports.__createBinding = __createBinding;
|
|
26
|
+
var __setModuleDefault = Object.create
|
|
27
|
+
? function (o, v) {
|
|
28
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
29
|
+
}
|
|
30
|
+
: function (o, v) {
|
|
31
|
+
o["default"] = v;
|
|
32
|
+
};
|
|
33
|
+
exports.__setModuleDefault = __setModuleDefault;
|
|
34
|
+
var ownKeys = function (o) {
|
|
35
|
+
ownKeys =
|
|
36
|
+
Object.getOwnPropertyNames ||
|
|
37
|
+
function (o2) {
|
|
38
|
+
var ar = [];
|
|
39
|
+
for (var k in o2)
|
|
40
|
+
if (Object.prototype.hasOwnProperty.call(o2, k))
|
|
41
|
+
ar[ar.length] = k;
|
|
42
|
+
return ar;
|
|
43
|
+
};
|
|
44
|
+
return ownKeys(o);
|
|
45
|
+
};
|
|
46
|
+
function __importStar(mod) {
|
|
47
|
+
if (mod && mod.__esModule)
|
|
48
|
+
return mod;
|
|
49
|
+
var result = {};
|
|
50
|
+
if (mod != null) {
|
|
51
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++)
|
|
52
|
+
if (k[i] !== "default")
|
|
53
|
+
__createBinding(result, mod, k[i]);
|
|
54
|
+
}
|
|
55
|
+
__setModuleDefault(result, mod);
|
|
56
|
+
return result;
|
|
57
|
+
}
|
package/napi/uzu.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* auto-generated by NAPI-RS */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export declare class ChatSession {
|
|
4
|
-
run(input: Input, config: RunConfig, progress?: (arg: Output) => boolean | undefined | null): Output
|
|
4
|
+
run(input: Input, config: RunConfig, progress?: ((arg: Output) => boolean) | undefined | null): Output
|
|
5
5
|
reset(): void
|
|
6
6
|
}
|
|
7
7
|
|
|
@@ -12,9 +12,9 @@ export declare class Engine {
|
|
|
12
12
|
createModelDownloadHandle(repoId: string): ModelDownloadHandle
|
|
13
13
|
constructor()
|
|
14
14
|
createChatSession(model: ChatModel, config: Config): ChatSession
|
|
15
|
-
registerLicenseStatusHandler(callback?: (arg: LicenseStatus) => void | undefined | null): void
|
|
16
|
-
registerModelDownloadStateHandler(callback?: (arg0: string, arg1: ModelDownloadState) => void | undefined | null): void
|
|
17
|
-
registerChatModelsHandler(callback?: (arg: Array<ChatModel>) => void | undefined | null): void
|
|
15
|
+
registerLicenseStatusHandler(callback?: ((arg: LicenseStatus) => void) | undefined | null): void
|
|
16
|
+
registerModelDownloadStateHandler(callback?: ((arg0: string, arg1: ModelDownloadState) => void) | undefined | null): void
|
|
17
|
+
registerChatModelsHandler(callback?: ((arg: Array<ChatModel>) => void) | undefined | null): void
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export declare class ModelDownloadHandle {
|
|
@@ -83,6 +83,11 @@ export declare const enum FinishReason {
|
|
|
83
83
|
ContextLimitReached = 3
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
export type GrammarConfig =
|
|
87
|
+
| { type: 'JsonSchema', schema: string }
|
|
88
|
+
| { type: 'Regex', pattern: string }
|
|
89
|
+
| { type: 'BuiltinJson' }
|
|
90
|
+
|
|
86
91
|
export type Input =
|
|
87
92
|
| { type: 'Text', text: string }
|
|
88
93
|
| { type: 'Messages', messages: Array<Message> }
|
|
@@ -170,6 +175,7 @@ export interface RunConfig {
|
|
|
170
175
|
tokensLimit: number
|
|
171
176
|
enableThinking: boolean
|
|
172
177
|
samplingPolicy: SamplingPolicy
|
|
178
|
+
grammarConfig?: GrammarConfig
|
|
173
179
|
}
|
|
174
180
|
|
|
175
181
|
export interface RunStats {
|
|
@@ -179,7 +185,7 @@ export interface RunStats {
|
|
|
179
185
|
|
|
180
186
|
export type SamplingMethod =
|
|
181
187
|
| { type: 'Greedy' }
|
|
182
|
-
| { type: 'Stochastic', temperature?: number, topK?: number, topP?: number }
|
|
188
|
+
| { type: 'Stochastic', temperature?: number, topK?: number, topP?: number, minP?: number }
|
|
183
189
|
|
|
184
190
|
export type SamplingPolicy =
|
|
185
191
|
| { type: 'Default' }
|
package/napi/uzu.js
CHANGED
|
@@ -47,6 +47,7 @@ const {
|
|
|
47
47
|
AsyncBatchSize,
|
|
48
48
|
ContextLength,
|
|
49
49
|
ContextMode,
|
|
50
|
+
GrammarConfig,
|
|
50
51
|
Input,
|
|
51
52
|
LicenseStatus,
|
|
52
53
|
ModelStorageError,
|
|
@@ -85,6 +86,7 @@ module.exports = {
|
|
|
85
86
|
AsyncBatchSize,
|
|
86
87
|
ContextLength,
|
|
87
88
|
ContextMode,
|
|
89
|
+
GrammarConfig,
|
|
88
90
|
Input,
|
|
89
91
|
LicenseStatus,
|
|
90
92
|
ModelStorageError,
|
package/napi/uzu.mjs
CHANGED
package/napi/uzu.node
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
"cpu": [
|
|
4
4
|
"arm64"
|
|
5
5
|
],
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"zod": "^4.2.1"
|
|
8
|
+
},
|
|
6
9
|
"description": "A high-performance inference engine for AI models",
|
|
7
10
|
"exports": {
|
|
8
11
|
".": {
|
|
@@ -98,5 +101,5 @@
|
|
|
98
101
|
},
|
|
99
102
|
"type": "commonjs",
|
|
100
103
|
"types": "./index.d.ts",
|
|
101
|
-
"version": "0.
|
|
104
|
+
"version": "0.2.0"
|
|
102
105
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
import { GrammarConfig as NapiGrammarConfig } from '../napi/uzu';
|
|
3
|
+
import { ToNapi } from './napi';
|
|
4
|
+
|
|
5
|
+
export class GrammarConfig implements ToNapi<NapiGrammarConfig> {
|
|
6
|
+
private readonly napiGrammarConfig: NapiGrammarConfig;
|
|
7
|
+
|
|
8
|
+
private constructor(napiGrammarConfig: NapiGrammarConfig) {
|
|
9
|
+
this.napiGrammarConfig = napiGrammarConfig;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static jsonSchema(schema: string): GrammarConfig {
|
|
13
|
+
let a = z.object({
|
|
14
|
+
name: z.string(),
|
|
15
|
+
age: z.number(),
|
|
16
|
+
});
|
|
17
|
+
const napiGrammarConfig: NapiGrammarConfig = { type: 'JsonSchema', schema: schema };
|
|
18
|
+
return new GrammarConfig(napiGrammarConfig);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static regex(pattern: string): GrammarConfig {
|
|
22
|
+
const napiGrammarConfig: NapiGrammarConfig = { type: 'Regex', pattern: pattern };
|
|
23
|
+
return new GrammarConfig(napiGrammarConfig);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static builtinJson(): GrammarConfig {
|
|
27
|
+
const napiGrammarConfig: NapiGrammarConfig = { type: 'BuiltinJson' };
|
|
28
|
+
return new GrammarConfig(napiGrammarConfig);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static fromType(type: z.ZodType): GrammarConfig {
|
|
32
|
+
let schema = z.toJSONSchema(type);
|
|
33
|
+
let schemaString = JSON.stringify(schema);
|
|
34
|
+
return GrammarConfig.jsonSchema(schemaString);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
toNapi(): NapiGrammarConfig {
|
|
38
|
+
return this.napiGrammarConfig;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
1
2
|
import { ParsedText as NapiParsedText } from '../napi/uzu';
|
|
2
3
|
|
|
3
4
|
export class ParsedText {
|
|
@@ -14,4 +15,13 @@ export class ParsedText {
|
|
|
14
15
|
const response = napiEntity.response ?? null;
|
|
15
16
|
return new ParsedText(chainOfThought, response);
|
|
16
17
|
}
|
|
18
|
+
|
|
19
|
+
structuredResponse<T extends z.ZodType>(type: T): z.infer<T> | null {
|
|
20
|
+
if (this.response === null) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const data = JSON.parse(this.response);
|
|
24
|
+
const result = type.parse(data);
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
17
27
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RunConfig as NapiRunConfig } from '../napi/uzu';
|
|
2
|
+
import { GrammarConfig } from './grammarConfig';
|
|
2
3
|
import { ToNapi } from './napi';
|
|
3
4
|
import { SamplingPolicy } from './samplingPolicy';
|
|
4
5
|
|
|
@@ -6,36 +7,51 @@ export class RunConfig implements ToNapi<NapiRunConfig> {
|
|
|
6
7
|
readonly tokensLimit: number;
|
|
7
8
|
readonly enableThinking: boolean;
|
|
8
9
|
readonly samplingPolicy: SamplingPolicy;
|
|
10
|
+
readonly grammarConfig: GrammarConfig | null;
|
|
9
11
|
|
|
10
|
-
private constructor(
|
|
12
|
+
private constructor(
|
|
13
|
+
tokensLimit: number,
|
|
14
|
+
enableThinking: boolean,
|
|
15
|
+
samplingPolicy: SamplingPolicy,
|
|
16
|
+
grammarConfig: GrammarConfig | null,
|
|
17
|
+
) {
|
|
11
18
|
this.tokensLimit = tokensLimit;
|
|
12
19
|
this.enableThinking = enableThinking;
|
|
13
20
|
this.samplingPolicy = samplingPolicy;
|
|
21
|
+
this.grammarConfig = grammarConfig;
|
|
14
22
|
}
|
|
15
23
|
|
|
16
24
|
static default(): RunConfig {
|
|
17
|
-
return new RunConfig(1024, true, SamplingPolicy.default());
|
|
25
|
+
return new RunConfig(1024, true, SamplingPolicy.default(), null);
|
|
18
26
|
}
|
|
19
27
|
|
|
20
28
|
withTokensLimit(tokensLimit: number): RunConfig {
|
|
21
|
-
return new RunConfig(tokensLimit, this.enableThinking, this.samplingPolicy);
|
|
29
|
+
return new RunConfig(tokensLimit, this.enableThinking, this.samplingPolicy, this.grammarConfig);
|
|
22
30
|
}
|
|
23
31
|
|
|
24
32
|
withEnableThinking(enableThinking: boolean): RunConfig {
|
|
25
|
-
return new RunConfig(this.tokensLimit, enableThinking, this.samplingPolicy);
|
|
33
|
+
return new RunConfig(this.tokensLimit, enableThinking, this.samplingPolicy, this.grammarConfig);
|
|
26
34
|
}
|
|
27
35
|
|
|
28
36
|
withSamplingPolicy(samplingPolicy: SamplingPolicy): RunConfig {
|
|
29
|
-
return new RunConfig(this.tokensLimit, this.enableThinking, samplingPolicy);
|
|
37
|
+
return new RunConfig(this.tokensLimit, this.enableThinking, samplingPolicy, this.grammarConfig);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
withGrammarConfig(grammarConfig: GrammarConfig | null): RunConfig {
|
|
41
|
+
return new RunConfig(this.tokensLimit, this.enableThinking, this.samplingPolicy, grammarConfig);
|
|
30
42
|
}
|
|
31
43
|
|
|
32
44
|
toNapi(): NapiRunConfig {
|
|
33
45
|
const napiSamplingPolicy = this.samplingPolicy.toNapi();
|
|
34
|
-
|
|
46
|
+
let napiRunConfig: NapiRunConfig = {
|
|
35
47
|
tokensLimit: this.tokensLimit,
|
|
36
48
|
enableThinking: this.enableThinking,
|
|
37
49
|
samplingPolicy: napiSamplingPolicy,
|
|
38
50
|
};
|
|
51
|
+
if (this.grammarConfig !== null) {
|
|
52
|
+
let napiGrammarConfig = this.grammarConfig.toNapi();
|
|
53
|
+
napiRunConfig.grammarConfig = napiGrammarConfig;
|
|
54
|
+
}
|
|
39
55
|
return napiRunConfig;
|
|
40
56
|
}
|
|
41
57
|
}
|
|
@@ -13,7 +13,12 @@ export class SamplingMethod implements ToNapi<NapiSamplingMethod> {
|
|
|
13
13
|
return new SamplingMethod(napiSamplingMethod);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
static stochastic(
|
|
16
|
+
static stochastic(
|
|
17
|
+
temperature: number | null,
|
|
18
|
+
topK: number | null,
|
|
19
|
+
topP: number | null,
|
|
20
|
+
minP: number | null,
|
|
21
|
+
): SamplingMethod {
|
|
17
22
|
let napiSamplingMethod: NapiSamplingMethod = {
|
|
18
23
|
type: 'Stochastic',
|
|
19
24
|
};
|
|
@@ -26,6 +31,9 @@ export class SamplingMethod implements ToNapi<NapiSamplingMethod> {
|
|
|
26
31
|
if (topP !== null) {
|
|
27
32
|
napiSamplingMethod.topP = topP;
|
|
28
33
|
}
|
|
34
|
+
if (minP !== null) {
|
|
35
|
+
napiSamplingMethod.minP = minP;
|
|
36
|
+
}
|
|
29
37
|
return new SamplingMethod(napiSamplingMethod);
|
|
30
38
|
}
|
|
31
39
|
|
package/src/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { DownloadProgressUpdate } from './bridging/downloadProgressUpdate';
|
|
|
10
10
|
export { DownloadPhase, DownloadState } from './bridging/downloadState';
|
|
11
11
|
export { Engine as default } from './bridging/engine';
|
|
12
12
|
export { FinishReason } from './bridging/finishReason';
|
|
13
|
+
export { GrammarConfig } from './bridging/grammarConfig';
|
|
13
14
|
export { Input } from './bridging/input';
|
|
14
15
|
export { Message } from './bridging/message';
|
|
15
16
|
export { ModelType } from './bridging/modelType';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ChatSession } from '../bridging/chatSession';
|
|
2
|
+
import { GrammarConfig } from '../bridging/grammarConfig';
|
|
2
3
|
import { Input } from '../bridging/input';
|
|
3
4
|
import { Message } from '../bridging/message';
|
|
4
5
|
import { Output } from '../bridging/output';
|
|
@@ -49,6 +50,11 @@ export class ChatSessionInteractor implements Interactor<ChatSession> {
|
|
|
49
50
|
return new ChatSessionInteractor(this.modelInteractor, this.entity, config);
|
|
50
51
|
}
|
|
51
52
|
|
|
53
|
+
grammarConfig(grammarConfig: GrammarConfig | null): ChatSessionInteractor {
|
|
54
|
+
const config = this.config.withGrammarConfig(grammarConfig);
|
|
55
|
+
return new ChatSessionInteractor(this.modelInteractor, this.entity, config);
|
|
56
|
+
}
|
|
57
|
+
|
|
52
58
|
/* Run */
|
|
53
59
|
|
|
54
60
|
async run(input: Input, progress: (partialOutput: Output) => boolean = () => true): Promise<Output> {
|
package/src/napi/uzu.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* auto-generated by NAPI-RS */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export declare class ChatSession {
|
|
4
|
-
run(input: Input, config: RunConfig, progress?: (arg: Output) => boolean | undefined | null): Output
|
|
4
|
+
run(input: Input, config: RunConfig, progress?: ((arg: Output) => boolean) | undefined | null): Output
|
|
5
5
|
reset(): void
|
|
6
6
|
}
|
|
7
7
|
|
|
@@ -12,9 +12,9 @@ export declare class Engine {
|
|
|
12
12
|
createModelDownloadHandle(repoId: string): ModelDownloadHandle
|
|
13
13
|
constructor()
|
|
14
14
|
createChatSession(model: ChatModel, config: Config): ChatSession
|
|
15
|
-
registerLicenseStatusHandler(callback?: (arg: LicenseStatus) => void | undefined | null): void
|
|
16
|
-
registerModelDownloadStateHandler(callback?: (arg0: string, arg1: ModelDownloadState) => void | undefined | null): void
|
|
17
|
-
registerChatModelsHandler(callback?: (arg: Array<ChatModel>) => void | undefined | null): void
|
|
15
|
+
registerLicenseStatusHandler(callback?: ((arg: LicenseStatus) => void) | undefined | null): void
|
|
16
|
+
registerModelDownloadStateHandler(callback?: ((arg0: string, arg1: ModelDownloadState) => void) | undefined | null): void
|
|
17
|
+
registerChatModelsHandler(callback?: ((arg: Array<ChatModel>) => void) | undefined | null): void
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export declare class ModelDownloadHandle {
|
|
@@ -83,6 +83,11 @@ export declare const enum FinishReason {
|
|
|
83
83
|
ContextLimitReached = 3
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
export type GrammarConfig =
|
|
87
|
+
| { type: 'JsonSchema', schema: string }
|
|
88
|
+
| { type: 'Regex', pattern: string }
|
|
89
|
+
| { type: 'BuiltinJson' }
|
|
90
|
+
|
|
86
91
|
export type Input =
|
|
87
92
|
| { type: 'Text', text: string }
|
|
88
93
|
| { type: 'Messages', messages: Array<Message> }
|
|
@@ -170,6 +175,7 @@ export interface RunConfig {
|
|
|
170
175
|
tokensLimit: number
|
|
171
176
|
enableThinking: boolean
|
|
172
177
|
samplingPolicy: SamplingPolicy
|
|
178
|
+
grammarConfig?: GrammarConfig
|
|
173
179
|
}
|
|
174
180
|
|
|
175
181
|
export interface RunStats {
|
|
@@ -179,7 +185,7 @@ export interface RunStats {
|
|
|
179
185
|
|
|
180
186
|
export type SamplingMethod =
|
|
181
187
|
| { type: 'Greedy' }
|
|
182
|
-
| { type: 'Stochastic', temperature?: number, topK?: number, topP?: number }
|
|
188
|
+
| { type: 'Stochastic', temperature?: number, topK?: number, topP?: number, minP?: number }
|
|
183
189
|
|
|
184
190
|
export type SamplingPolicy =
|
|
185
191
|
| { type: 'Default' }
|
package/src/napi/uzu.js
CHANGED
|
@@ -47,6 +47,7 @@ const {
|
|
|
47
47
|
AsyncBatchSize,
|
|
48
48
|
ContextLength,
|
|
49
49
|
ContextMode,
|
|
50
|
+
GrammarConfig,
|
|
50
51
|
Input,
|
|
51
52
|
LicenseStatus,
|
|
52
53
|
ModelStorageError,
|
|
@@ -85,6 +86,7 @@ module.exports = {
|
|
|
85
86
|
AsyncBatchSize,
|
|
86
87
|
ContextLength,
|
|
87
88
|
ContextMode,
|
|
89
|
+
GrammarConfig,
|
|
88
90
|
Input,
|
|
89
91
|
LicenseStatus,
|
|
90
92
|
ModelStorageError,
|
package/src/napi/uzu.mjs
CHANGED
package/src/napi/uzu.node
CHANGED
|
Binary file
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.2.0';
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.2.0";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.mts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.mts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.2.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
package/version.js
CHANGED
package/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,OAAO,CAAC"}
|
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.2.0';
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|
package/version.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.mjs","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.mjs","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
|