@trymirai/uzu 0.1.3 → 0.1.5

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 CHANGED
@@ -8,6 +8,7 @@
8
8
  <a href="https://docsend.com/v/76bpr/mirai2025"><img src="https://img.shields.io/badge/View-Deck-red" alt="View our deck"></a>
9
9
  <a href="mailto:alexey@getmirai.co,dima@getmirai.co,aleksei@getmirai.co?subject=Interested%20in%20Mirai"><img src="https://img.shields.io/badge/Send-Email-green" alt="Contact us"></a>
10
10
  <a href="https://docs.trymirai.com/components/inference-engine"><img src="https://img.shields.io/badge/Read-Docs-blue" alt="Read docs"></a>
11
+ [![npm (scoped)](https://img.shields.io/npm/v/%40trymirai%2Fuzu)](https://www.npmjs.com/package/@trymirai/uzu)
11
12
  [![License](https://img.shields.io/badge/License-MIT-blue)](LICENSE)
12
13
 
13
14
  # uzu-ts
@@ -19,192 +20,185 @@ Node package for [uzu](https://github.com/trymirai/uzu), a **high-performance**
19
20
  - [Broad model support](https://trymirai.com/models)
20
21
  - Observable model manager
21
22
 
22
- ## Quick Start
23
+ ## Setup
23
24
 
25
+ Add the `uzu` dependency to your project's `package.json`:
24
26
 
25
- ```bash
26
- # 1 / Install TS dependencies (installs @napi-rs/cli locally)
27
- cd bindings/ts
28
- pnpm install
29
-
30
- # 2 / Build the native addon in release mode
31
- pnpm run build
32
-
33
- # 3 / Set your API key in `examples/api_key.ts`, then run the examples
34
- pnpm run chat
35
- pnpm run summarize
36
- pnpm run classify
27
+ ```json
28
+ "dependencies": {
29
+ "@trymirai/uzu": "0.1.4"
30
+ }
37
31
  ```
38
32
 
39
- ### Setup
40
-
41
- Add the `uzu-ts` dependency to your project:
42
-
43
- Set up your project via [Platform](https://platform.trymirai.com), obtain an `API_KEY`, and initialize engine:
33
+ Create and activate engine:
44
34
 
45
35
  ```ts
46
- import { Engine } from './uzu'
47
-
48
36
  const engine = new Engine()
49
- const licenseStatus = await engine.activate('API_KEY')
37
+ const licenseStatus: LicenseStatus = await engine.activate(apiKey)
50
38
  ```
51
39
 
52
- ### Refresh models registry:
40
+ ### Refresh models registry / list cloud models:
53
41
 
54
42
  ```ts
55
- const registry = await engine.updateRegistry()
56
- const modelIdentifiers = registry.map((m) => m.identifier)
43
+ const localModels: LocalModel[] = await engine.updateRegistry()
44
+ const localModelId = 'Meta-Llama-3.2-1B-Instruct-bfloat16'
57
45
  ```
58
46
 
59
47
  ### Download with progress handle
60
48
 
61
49
  ```ts
62
- const modelIdentifier = 'Meta-Llama-3.2-1B-Instruct-bfloat16'
50
+ const donwloadHandle = engine.downloadHandle(localModelId)
51
+ donwloadHandle.start()
63
52
 
64
- const handle = engine.downloadHandle(modelIdentifier)
65
- handle.start()
66
-
67
- for await (const downloadProgress of handle.progress()) {
68
- console.log(`Progress: ${Math.round(downloadProgress.progress * 100)}%`)
53
+ for await (const donwloadProgress of donwloadHandle.progress()) {
54
+ handleProgress(donwloadProgress)
69
55
  }
70
56
  ```
71
57
 
72
58
  Alternatively, you may use engine to control and observe model download:
73
59
 
74
60
  ```ts
75
- engine.download(modelIdentifier)
76
- engine.pause(modelIdentifier)
77
- engine.resume(modelIdentifier)
78
- engine.delete(modelIdentifier)
61
+ // engine.download(localModelId)
62
+ // engine.pause(localModelId)
63
+ // engine.resume(localModelId)
64
+ // engine.stop(localModelId)
65
+ // engine.delete(localModelId)
79
66
 
80
- // ... later you can query state
81
- const state = engine.getState(modelIdentifier)
67
+ const modelState: ModelDownloadState = engine.getState(localModelId)
82
68
  ```
83
69
 
84
- Possible model state values:
85
-
86
- - `.notDownloaded`
87
- - `.downloading(progress: Double)`
88
- - `.paused(progress: Double)`
89
- - `.downloaded`
90
- - `.error(message: String)`
91
-
92
70
  ### Session
93
71
 
94
72
  `Session` is the core entity used to communicate with the model:
95
73
 
96
74
  ```ts
97
- const session = engine.createSession({ type: 'Local', id: 'Meta-Llama-3.2-1B-Instruct-bfloat16' })
75
+ // Choose one of the two options below by commenting/uncommenting:
76
+ // const modelId: ModelID = { type: 'Cloud', id: cloudRepoId }
77
+ const modelId: ModelID = { type: 'Local', id: localModelId }
78
+ const session: Session = engine.createSession(modelId)
98
79
  ```
99
80
 
100
- `Session` offers different configuration presets that can provide significant performance boosts for common use cases like classification and summarization:
81
+ ### Chat
101
82
 
102
- ```ts
103
- import { type SessionConfig } from './uzu'
83
+ Load `Session` with a chat-configured config and run it with a specific prompt or a list of messages:
104
84
 
85
+ ```ts
105
86
  const config: SessionConfig = {
106
- preset: { type: 'General' },
107
- samplingSeed: { type: 'Default' },
108
- contextLength: { type: 'Default' },
87
+ preset: { type: 'General' },
88
+ samplingSeed: { type: 'Custom', seed: 12345 },
89
+ contextLength: { type: 'Default' },
109
90
  }
110
91
  session.load(config)
111
92
  ```
112
93
 
113
- Once loaded, the same `Session` can be reused for multiple requests until you drop it. Each model may consume a significant amount of RAM, so it's important to keep only one session loaded at a time.
114
-
115
- ### Inference
116
-
117
- After loading, you can run the `Session` with a specific prompt or a list of messages:
118
-
119
94
  ```ts
120
- import { SessionMessageRole, type SessionInput } from './uzu'
121
-
122
95
  const input: SessionInput = {
123
- type: 'Messages',
124
- messages: [
125
- { role: SessionMessageRole.System, content: 'You are a helpful assistant' },
126
- { role: SessionMessageRole.User, content: 'Tell about London' },
127
- ],
96
+ type: 'Messages',
97
+ messages: [
98
+ {
99
+ role: SessionMessageRole.System,
100
+ content: 'You are a helpful assistant.'
101
+ },
102
+ {
103
+ role: SessionMessageRole.User,
104
+ content: 'Tell me a short, funny story about a robot.'
105
+ },
106
+ ],
128
107
  }
129
-
130
- const output = session.run(
131
- input,
132
- { tokensLimit: 128, samplingConfig: { type: 'Argmax' } },
133
- (partialOutput) => {
134
- // Access the current text using partialOutput.text
135
- return true // Return true to continue generation
136
- },
137
- )
138
108
  ```
139
109
 
140
- `SessionOutput` also includes generation metrics such as prefill duration and tokens per second. It’s important to note that you should run a **release** build to obtain accurate metrics.
110
+ ```ts
111
+ const runConfig: SessionRunConfig = {
112
+ tokensLimit: 128,
113
+ samplingConfig: { type: 'Argmax' },
114
+ }
115
+ ```
141
116
 
142
- ### Presets
117
+ ```ts
118
+ const output = session.run(input, runConfig, (partialOutput) => {
119
+ return handlePartialOutput(partialOutput)
120
+ })
121
+ ```
143
122
 
144
- #### Summarization
123
+ ### Summarization
145
124
 
146
125
  In this example, we will extract a summary of the input text:
147
126
 
148
127
  ```ts
149
- import { type SessionConfig, type SessionInput } from './uzu'
150
-
151
- const textToSummarize =
152
- 'A Large Language Model (LLM) is a type of artificial intelligence that processes and generates human-like text. It is trained on vast datasets containing books, articles, and web content, allowing it to understand and predict language patterns. LLMs use deep learning, particularly transformer-based architectures, to analyze text, recognize context, and generate coherent responses. These models have a wide range of applications, including chatbots, content creation, translation, and code generation. One of the key strengths of LLMs is their ability to generate contextually relevant text based on prompts. They utilize self-attention mechanisms to weigh the importance of words within a sentence, improving accuracy and fluency. Examples of popular LLMs include OpenAI's GPT series, Google's BERT, and Meta's LLaMA. As these models grow in size and sophistication, they continue to enhance human-computer interactions, making AI-powered communication more natural and effective.'
153
- const text = `Text is: "${textToSummarize}". Write only summary itself.`
154
-
155
128
  const config: SessionConfig = {
156
- preset: { type: 'Summarization' },
157
- samplingSeed: { type: 'Default' },
158
- contextLength: { type: 'Default' },
129
+ preset: { type: 'Summarization' },
130
+ samplingSeed: { type: 'Default' },
131
+ contextLength: { type: 'Default' },
159
132
  }
160
133
  session.load(config)
134
+ ```
161
135
 
162
- const input: SessionInput = { type: 'Text', text }
136
+ ```ts
137
+ const input: SessionInput = {
138
+ type: 'Text',
139
+ text: `Text is: "${textToSummarize}". Write only summary itself.`,
140
+ }
141
+ ```
163
142
 
164
- const output = session.run(
165
- input,
166
- { tokensLimit: 1024, samplingConfig: { type: 'Argmax' } },
167
- () => true,
168
- )
143
+ ```ts
144
+ const runConfig: SessionRunConfig = {
145
+ tokensLimit: 256,
146
+ samplingConfig: { type: 'Argmax' },
147
+ }
169
148
  ```
170
149
 
171
- This will generate 34 output tokens with only 5 model runs during the generation phase, instead of 34 runs.
150
+ ```ts
151
+ const output = session.run(input, runConfig, (partialOutput) => {
152
+ return handlePartialOutput(partialOutput)
153
+ })
154
+ ```
172
155
 
173
- #### Classification
156
+ ### Classification
174
157
 
175
158
  Let’s look at a case where you need to classify input text based on a specific feature, such as `sentiment`:
176
159
 
177
160
  ```ts
178
- import { type SessionClassificationFeature, type SessionConfig, type SessionInput } from './uzu'
179
-
180
161
  const feature: SessionClassificationFeature = {
181
- name: 'sentiment',
182
- values: ['Happy', 'Sad', 'Angry', 'Fearful', 'Surprised', 'Disgusted'],
162
+ name: 'sentiment',
163
+ values: ['Happy', 'Sad', 'Angry', 'Fearful', 'Surprised', 'Disgusted'],
183
164
  }
165
+ ```
184
166
 
185
- const textToDetectFeature = "Today's been awesome! Everything just feels right, and I can't stop smiling."
186
- const text = `Text is: "${textToDetectFeature}". Choose ${feature.name} from the list: ${feature.values.join(
187
- ', ',
188
- )}. Answer with one word. Don't add a dot at the end.`
189
-
167
+ ```ts
190
168
  const config: SessionConfig = {
191
- preset: { type: 'Classification', feature },
192
- samplingSeed: { type: 'Default' },
193
- contextLength: { type: 'Default' },
169
+ preset: { type: 'Classification', feature },
170
+ samplingSeed: { type: 'Default' },
171
+ contextLength: { type: 'Default' },
194
172
  }
195
173
  session.load(config)
174
+ ```
196
175
 
197
- const input: SessionInput = { type: 'Text', text }
176
+ ```ts
177
+ const textToDetectFeature =
178
+ "Today's been awesome! Everything just feels right, and I can't stop smiling."
179
+ const classificationPrompt =
180
+ `Text is: "${textToDetectFeature}". Choose ${feature.name} from the list: ${feature.values.join(', ')}. ` +
181
+ "Answer with one word. Don't add a dot at the end."
182
+ const input: SessionInput = { type: 'Text', text: classificationPrompt }
183
+ ```
198
184
 
199
- const output = session.run(
200
- input,
201
- { tokensLimit: 32, samplingConfig: { type: 'Argmax' } },
202
- () => true,
203
- )
185
+ ```ts
186
+ const runConfig: SessionRunConfig = {
187
+ tokensLimit: 32,
188
+ samplingConfig: { type: 'Argmax' },
189
+ }
190
+ ```
191
+
192
+ ```ts
193
+ const output = session.run(input, runConfig, (partialOutput) => {
194
+ return handlePartialOutput(partialOutput)
195
+ })
204
196
  ```
205
197
 
206
198
  In this example, you will get the answer `Happy` immediately after the prefill step, and the actual generation won't even start.
207
199
 
208
200
  ## License
209
201
 
210
- This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
202
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
203
+
204
+
package/README.orig.md ADDED
@@ -0,0 +1,215 @@
1
+ <p align="center">
2
+ <picture>
3
+ <img alt="Mirai" src="https://artifacts.trymirai.com/social/github/uzu-typescript.jpg" style="max-width: 100%;">
4
+ </picture>
5
+ </p>
6
+
7
+ <a href="https://artifacts.trymirai.com/social/about_us.mp3"><img src="https://img.shields.io/badge/Listen-Podcast-red" alt="Listen to our podcast"></a>
8
+ <a href="https://docsend.com/v/76bpr/mirai2025"><img src="https://img.shields.io/badge/View-Deck-red" alt="View our deck"></a>
9
+ <a href="mailto:alexey@getmirai.co,dima@getmirai.co,aleksei@getmirai.co?subject=Interested%20in%20Mirai"><img src="https://img.shields.io/badge/Send-Email-green" alt="Contact us"></a>
10
+ <a href="https://docs.trymirai.com/components/inference-engine"><img src="https://img.shields.io/badge/Read-Docs-blue" alt="Read docs"></a>
11
+ [![npm (scoped)](https://img.shields.io/npm/v/%40trymirai%2Fuzu)](https://www.npmjs.com/package/@trymirai/uzu)
12
+ [![License](https://img.shields.io/badge/License-MIT-blue)](LICENSE)
13
+
14
+ # uzu-ts
15
+
16
+ Node package for [uzu](https://github.com/trymirai/uzu), a **high-performance** inference engine for AI models on Apple Silicon. It allows you to deploy AI directly in your app with **zero latency**, **full data privacy**, and **no inference costs**. You don’t need an ML team or weeks of setup - one developer can handle everything in minutes. Key features:
17
+
18
+ - Simple, high-level API
19
+ - Specialized configurations with significant performance boosts for common use cases like classification and summarization
20
+ - [Broad model support](https://trymirai.com/models)
21
+ - Observable model manager
22
+
23
+ ## Quick Start
24
+
25
+ Set up your project via [Platform](https://platform.trymirai.com), obtain an `MIRAI_API_KEY`.
26
+
27
+ ```bash
28
+ # Set your API key in `examples/api_key.ts`, then run the examples
29
+ pnpm run chat
30
+ pnpm run summarisation
31
+ pnpm run classification
32
+ ```
33
+
34
+ ## Setup
35
+
36
+ Add the `uzu` dependency to your project's `package.json`:
37
+
38
+ ```json
39
+ "dependencies": {
40
+ "@trymirai/uzu": "0.1.4"
41
+ }
42
+ ```
43
+
44
+ Create and activate engine:
45
+
46
+ ```ts
47
+ const engine = new Engine()
48
+ const licenseStatus: LicenseStatus = await engine.activate(apiKey)
49
+ ```
50
+
51
+ ### Refresh models registry / list cloud models:
52
+
53
+ ```ts
54
+ const localModels: LocalModel[] = await engine.updateRegistry()
55
+ const localModelId = 'Meta-Llama-3.2-1B-Instruct-bfloat16'
56
+ ```
57
+
58
+ ### Download with progress handle
59
+
60
+ ```ts
61
+ const donwloadHandle = engine.downloadHandle(localModelId)
62
+ donwloadHandle.start()
63
+
64
+ for await (const donwloadProgress of donwloadHandle.progress()) {
65
+ handleProgress(donwloadProgress)
66
+ }
67
+ ```
68
+
69
+ Alternatively, you may use engine to control and observe model download:
70
+
71
+ ```ts
72
+ // engine.download(localModelId)
73
+ // engine.pause(localModelId)
74
+ // engine.resume(localModelId)
75
+ // engine.stop(localModelId)
76
+ // engine.delete(localModelId)
77
+
78
+ const modelState: ModelDownloadState = engine.getState(localModelId)
79
+ ```
80
+
81
+ ### Session
82
+
83
+ `Session` is the core entity used to communicate with the model:
84
+
85
+ ```ts
86
+ // Choose one of the two options below by commenting/uncommenting:
87
+ // const modelId: ModelID = { type: 'Cloud', id: cloudRepoId }
88
+ const modelId: ModelID = { type: 'Local', id: localModelId }
89
+ const session: Session = engine.createSession(modelId)
90
+ ```
91
+
92
+ ### Chat
93
+
94
+ Load `Session` with a chat-configured config and run it with a specific prompt or a list of messages:
95
+
96
+ ```ts
97
+ const config: SessionConfig = {
98
+ preset: { type: 'General' },
99
+ samplingSeed: { type: 'Custom', seed: 12345 },
100
+ contextLength: { type: 'Default' },
101
+ }
102
+ session.load(config)
103
+ ```
104
+
105
+ ```ts
106
+ const input: SessionInput = {
107
+ type: 'Messages',
108
+ messages: [
109
+ {
110
+ role: SessionMessageRole.System,
111
+ content: 'You are a helpful assistant.'
112
+ },
113
+ {
114
+ role: SessionMessageRole.User,
115
+ content: 'Tell me a short, funny story about a robot.'
116
+ },
117
+ ],
118
+ }
119
+ ```
120
+
121
+ ```ts
122
+ const runConfig: SessionRunConfig = {
123
+ tokensLimit: 128,
124
+ samplingConfig: { type: 'Argmax' },
125
+ }
126
+ ```
127
+
128
+ ```ts
129
+ const output = session.run(input, runConfig, (partialOutput) => {
130
+ return handlePartialOutput(partialOutput)
131
+ })
132
+ ```
133
+
134
+ ### Summarization
135
+
136
+ In this example, we will extract a summary of the input text:
137
+
138
+ ```ts
139
+ const config: SessionConfig = {
140
+ preset: { type: 'Summarization' },
141
+ samplingSeed: { type: 'Default' },
142
+ contextLength: { type: 'Default' },
143
+ }
144
+ session.load(config)
145
+ ```
146
+
147
+ ```ts
148
+ const input: SessionInput = {
149
+ type: 'Text',
150
+ text: `Text is: "${textToSummarize}". Write only summary itself.`,
151
+ }
152
+ ```
153
+
154
+ ```ts
155
+ const runConfig: SessionRunConfig = {
156
+ tokensLimit: 256,
157
+ samplingConfig: { type: 'Argmax' },
158
+ }
159
+ ```
160
+
161
+ ```ts
162
+ const output = session.run(input, runConfig, (partialOutput) => {
163
+ return handlePartialOutput(partialOutput)
164
+ })
165
+ ```
166
+
167
+ ### Classification
168
+
169
+ Let’s look at a case where you need to classify input text based on a specific feature, such as `sentiment`:
170
+
171
+ ```ts
172
+ const feature: SessionClassificationFeature = {
173
+ name: 'sentiment',
174
+ values: ['Happy', 'Sad', 'Angry', 'Fearful', 'Surprised', 'Disgusted'],
175
+ }
176
+ ```
177
+
178
+ ```ts
179
+ const config: SessionConfig = {
180
+ preset: { type: 'Classification', feature },
181
+ samplingSeed: { type: 'Default' },
182
+ contextLength: { type: 'Default' },
183
+ }
184
+ session.load(config)
185
+ ```
186
+
187
+ ```ts
188
+ const textToDetectFeature =
189
+ "Today's been awesome! Everything just feels right, and I can't stop smiling."
190
+ const classificationPrompt =
191
+ `Text is: "${textToDetectFeature}". Choose ${feature.name} from the list: ${feature.values.join(', ')}. ` +
192
+ "Answer with one word. Don't add a dot at the end."
193
+ const input: SessionInput = { type: 'Text', text: classificationPrompt }
194
+ ```
195
+
196
+ ```ts
197
+ const runConfig: SessionRunConfig = {
198
+ tokensLimit: 32,
199
+ samplingConfig: { type: 'Argmax' },
200
+ }
201
+ ```
202
+
203
+ ```ts
204
+ const output = session.run(input, runConfig, (partialOutput) => {
205
+ return handlePartialOutput(partialOutput)
206
+ })
207
+ ```
208
+
209
+ In this example, you will get the answer `Happy` immediately after the prefill step, and the actual generation won't even start.
210
+
211
+ ## License
212
+
213
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
214
+
215
+
package/README.src.md ADDED
@@ -0,0 +1,146 @@
1
+ <p align="center">
2
+ <picture>
3
+ <img alt="Mirai" src="https://artifacts.trymirai.com/social/github/uzu-typescript.jpg" style="max-width: 100%;">
4
+ </picture>
5
+ </p>
6
+
7
+ <a href="https://artifacts.trymirai.com/social/about_us.mp3"><img src="https://img.shields.io/badge/Listen-Podcast-red" alt="Listen to our podcast"></a>
8
+ <a href="https://docsend.com/v/76bpr/mirai2025"><img src="https://img.shields.io/badge/View-Deck-red" alt="View our deck"></a>
9
+ <a href="mailto:alexey@getmirai.co,dima@getmirai.co,aleksei@getmirai.co?subject=Interested%20in%20Mirai"><img src="https://img.shields.io/badge/Send-Email-green" alt="Contact us"></a>
10
+ <a href="https://docs.trymirai.com/components/inference-engine"><img src="https://img.shields.io/badge/Read-Docs-blue" alt="Read docs"></a>
11
+ [![npm (scoped)](https://img.shields.io/npm/v/%40trymirai%2Fuzu)](https://www.npmjs.com/package/@trymirai/uzu)
12
+ [![License](https://img.shields.io/badge/License-MIT-blue)](LICENSE)
13
+
14
+ # uzu-ts
15
+
16
+ Node package for [uzu](https://github.com/trymirai/uzu), a **high-performance** inference engine for AI models on Apple Silicon. It allows you to deploy AI directly in your app with **zero latency**, **full data privacy**, and **no inference costs**. You don’t need an ML team or weeks of setup - one developer can handle everything in minutes. Key features:
17
+
18
+ - Simple, high-level API
19
+ - Specialized configurations with significant performance boosts for common use cases like classification and summarization
20
+ - [Broad model support](https://trymirai.com/models)
21
+ - Observable model manager
22
+
23
+ ## Quick Start
24
+
25
+ Set up your project via [Platform](https://platform.trymirai.com), obtain an `MIRAI_API_KEY`.
26
+
27
+ ```bash
28
+ # Set your API key in `examples/api_key.ts`, then run the examples
29
+ pnpm run chat
30
+ pnpm run summarisation
31
+ pnpm run classification
32
+ ```
33
+
34
+ ## Setup
35
+
36
+ Add the `uzu` dependency to your project's `package.json`:
37
+
38
+ ```json
39
+ "dependencies": {
40
+ "@trymirai/uzu": "0.1.4"
41
+ }
42
+ ```
43
+
44
+ Create and activate engine:
45
+
46
+ ```ts
47
+ // include:examples/chat.ts#activation lang=ts
48
+ ```
49
+
50
+ ### Refresh models registry / list cloud models:
51
+
52
+ ```ts
53
+ // include:examples/chat.ts#registry lang=ts
54
+ ```
55
+
56
+ ### Download with progress handle
57
+
58
+ ```ts
59
+ // include:examples/chat.ts#download lang=ts
60
+ ```
61
+
62
+ Alternatively, you may use engine to control and observe model download:
63
+
64
+ ```ts
65
+ // include:examples/chat.ts#model-state lang=ts
66
+ ```
67
+
68
+ ### Session
69
+
70
+ `Session` is the core entity used to communicate with the model:
71
+
72
+ ```ts
73
+ // include:examples/chat.ts#session-create lang=ts
74
+ ```
75
+
76
+ ### Chat
77
+
78
+ Load `Session` with a chat-configured config and run it with a specific prompt or a list of messages:
79
+
80
+ ```ts
81
+ // include:examples/chat.ts#session-load lang=ts
82
+ ```
83
+
84
+ ```ts
85
+ // include:examples/chat.ts#session-input lang=ts
86
+ ```
87
+
88
+ ```ts
89
+ // include:examples/chat.ts#session-run-config lang=ts
90
+ ```
91
+
92
+ ```ts
93
+ // include:examples/chat.ts#session-run lang=ts
94
+ ```
95
+
96
+ ### Summarization
97
+
98
+ In this example, we will extract a summary of the input text:
99
+
100
+ ```ts
101
+ // include:examples/summarisation.ts#session-load lang=ts
102
+ ```
103
+
104
+ ```ts
105
+ // include:examples/summarisation.ts#session-input lang=ts
106
+ ```
107
+
108
+ ```ts
109
+ // include:examples/summarisation.ts#session-run-config lang=ts
110
+ ```
111
+
112
+ ```ts
113
+ // include:examples/summarisation.ts#session-run lang=ts
114
+ ```
115
+
116
+ ### Classification
117
+
118
+ Let’s look at a case where you need to classify input text based on a specific feature, such as `sentiment`:
119
+
120
+ ```ts
121
+ // include:examples/classification.ts#classification-feature lang=ts
122
+ ```
123
+
124
+ ```ts
125
+ // include:examples/classification.ts#session-load lang=ts
126
+ ```
127
+
128
+ ```ts
129
+ // include:examples/classification.ts#session-input lang=ts
130
+ ```
131
+
132
+ ```ts
133
+ // include:examples/classification.ts#session-run-config lang=ts
134
+ ```
135
+
136
+ ```ts
137
+ // include:examples/classification.ts#session-run lang=ts
138
+ ```
139
+
140
+ In this example, you will get the answer `Happy` immediately after the prefill step, and the actual generation won't even start.
141
+
142
+ ## License
143
+
144
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
145
+
146
+
package/package.json CHANGED
@@ -1,22 +1,25 @@
1
1
  {
2
2
  "name": "@trymirai/uzu",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "private": false,
5
5
  "main": "uzu.node",
6
6
  "types": "uzu.d.ts",
7
7
  "packageManager": "pnpm@10.14.0",
8
8
  "scripts": {
9
- "build": "./build.sh",
10
- "chat": "ts-node examples/chat_example.ts",
11
- "summarize": "ts-node examples/summarization_example.ts",
12
- "classify": "ts-node examples/classification_example.ts"
9
+ "lint": "eslint .",
10
+ "generate:readme": "cargo run -q --manifest-path ../../Cargo.toml --bin uzu_docgen -- --root $PWD --src $PWD/README.src.md --dest $PWD/README.md",
11
+ "chat": "ts-node examples/chat.ts",
12
+ "summarisation": "ts-node examples/summarisation.ts",
13
+ "classification": "ts-node examples/classification.ts"
13
14
  },
14
15
  "devDependencies": {
15
16
  "@napi-rs/cli": "3.1.2",
16
17
  "@types/node": "24.2.0",
18
+ "@types/progress": "2.0.7",
19
+ "eslint": "9.33.0",
17
20
  "ts-node": "10.9.2",
18
21
  "typescript": "5.9.2",
19
- "@types/progress": "2.0.7"
22
+ "typescript-eslint": "8.40.0"
20
23
  },
21
24
  "dependencies": {
22
25
  "progress": "2.0.3"
package/uzu.node CHANGED
Binary file