llaminate 0.1.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/.gitattributes +2 -0
- package/LICENSE +21 -0
- package/README.md +95 -0
- package/assets/llaminate-256.webp +0 -0
- package/assets/llaminate.jpg +0 -0
- package/assets/llaminate.webp +0 -0
- package/dist/build-info.json +5 -0
- package/dist/config.schema.json +126 -0
- package/dist/llaminate.d.ts +202 -0
- package/dist/llaminate.min.js +9 -0
- package/dist/llaminate.min.js.map +1 -0
- package/dist/ratelimiter.d.ts +33 -0
- package/dist/ratelimiter.min.js +7 -0
- package/dist/ratelimiter.min.js.map +1 -0
- package/dist/system.hbs +3 -0
- package/docs/LICENSE +21 -0
- package/docs/Llaminate.html +1040 -0
- package/docs/Llaminate.module_Endpoints.html +278 -0
- package/docs/Llaminate.module_Llaminate.html +200 -0
- package/docs/Llaminate.module_MimeTypes.html +275 -0
- package/docs/LlaminateConfig.html +667 -0
- package/docs/LlaminateMessage.html +328 -0
- package/docs/LlaminateResponse.html +253 -0
- package/docs/assets/llaminate-256.webp +0 -0
- package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Bold-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Light-webfont.svg +1831 -0
- package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.svg +1831 -0
- package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docs/index.html +142 -0
- package/docs/scripts/linenumber.js +25 -0
- package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/docs/scripts/prettify/lang-css.js +2 -0
- package/docs/scripts/prettify/prettify.js +28 -0
- package/docs/styles/jsdoc-default.css +358 -0
- package/docs/styles/prettify-jsdoc.css +111 -0
- package/docs/styles/prettify-tomorrow.css +132 -0
- package/jsdoc.json +23 -0
- package/package.json +38 -0
- package/scripts/build.sh +21 -0
- package/scripts/docs.sh +28 -0
- package/scripts/prebuild.js +43 -0
- package/scripts/prepare.sh +11 -0
- package/scripts/pretest.js +14 -0
- package/src/config.schema.json +126 -0
- package/src/llaminate.d.ts +99 -0
- package/src/llaminate.ts +1326 -0
- package/src/llaminate.types.js +176 -0
- package/src/ratelimiter.ts +95 -0
- package/src/system.hbs +3 -0
- package/tests/attachments.test.js +66 -0
- package/tests/common/base64.js +13 -0
- package/tests/common/matches.js +69 -0
- package/tests/common/setup.js +45 -0
- package/tests/complete.test.js +27 -0
- package/tests/extensions/toMatchSchema.js +20 -0
- package/tests/history.test.js +86 -0
- package/tests/stream.test.js +67 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,1040 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>: Class: Llaminate</title>
|
|
6
|
+
|
|
7
|
+
<script src="scripts/prettify/prettify.js"> </script>
|
|
8
|
+
<script src="scripts/prettify/lang-css.js"> </script>
|
|
9
|
+
<!--[if lt IE 9]>
|
|
10
|
+
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
11
|
+
<![endif]-->
|
|
12
|
+
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
|
13
|
+
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
|
14
|
+
</head>
|
|
15
|
+
|
|
16
|
+
<body>
|
|
17
|
+
|
|
18
|
+
<div id="main">
|
|
19
|
+
|
|
20
|
+
<h1 class="page-title">Class: Llaminate</h1>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
<section>
|
|
28
|
+
|
|
29
|
+
<header>
|
|
30
|
+
|
|
31
|
+
<h2><span class="attribs"><span class="type-signature"></span></span>Llaminate<span class="signature">(config)</span><span class="type-signature"></span></h2>
|
|
32
|
+
|
|
33
|
+
<div class="class-description">Represents the Llaminate service for managing and interacting with AI models.</div>
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
</header>
|
|
37
|
+
|
|
38
|
+
<article>
|
|
39
|
+
<div class="container-overview">
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
<h2>Constructor</h2>
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
<h4 class="name" id="Llaminate"><span class="type-signature"></span>new Llaminate<span class="signature">(config)</span><span class="type-signature"></span></h4>
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
<div class="description">
|
|
56
|
+
Constructs a new instance of the Llaminate class.
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
<h5>Parameters:</h5>
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
<table class="params">
|
|
71
|
+
<thead>
|
|
72
|
+
<tr>
|
|
73
|
+
|
|
74
|
+
<th>Name</th>
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
<th>Type</th>
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
<th class="last">Description</th>
|
|
84
|
+
</tr>
|
|
85
|
+
</thead>
|
|
86
|
+
|
|
87
|
+
<tbody>
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
<tr>
|
|
91
|
+
|
|
92
|
+
<td class="name"><code>config</code></td>
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
<td class="type">
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
<span class="param-type"><a href="LlaminateConfig.html">LlaminateConfig</a></span>
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
</td>
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
<td class="description last">The configuration options for the
|
|
109
|
+
Llaminate instance.</td>
|
|
110
|
+
</tr>
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
</tbody>
|
|
114
|
+
</table>
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
<dl class="details">
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
</dl>
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
<h5>Throws:</h5>
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
<div class="param-desc">
|
|
173
|
+
|
|
174
|
+
Will throw an error if the provided configuration is invalid.
|
|
175
|
+
|
|
176
|
+
</div>
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
<h5>Example</h5>
|
|
187
|
+
|
|
188
|
+
<pre class="prettyprint"><code>const mistral = new Llaminate({
|
|
189
|
+
endpoint: Llaminate.MISTRAL,
|
|
190
|
+
key: "12345-abcde-67890-fghij-klm",
|
|
191
|
+
model: "mistral-small-latest",
|
|
192
|
+
system: ["You are a sarcastic assistant who answers very briefly and bluntly."]
|
|
193
|
+
rpm: 720
|
|
194
|
+
});</code></pre>
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
<h3 class="subsection-title">Classes</h3>
|
|
207
|
+
|
|
208
|
+
<dl>
|
|
209
|
+
<dt><a href="Llaminate.html">Llaminate</a></dt>
|
|
210
|
+
<dd></dd>
|
|
211
|
+
</dl>
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
<h3 class="subsection-title">Methods</h3>
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
<h4 class="name" id="clear"><span class="type-signature"></span>clear<span class="signature">()</span><span class="type-signature"></span></h4>
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
<div class="description">
|
|
239
|
+
Resets the chat history. This does not affect the configuration or any
|
|
240
|
+
other settings.
|
|
241
|
+
</div>
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
<dl class="details">
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
</dl>
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
<h5>Returns:</h5>
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
<div class="param-desc">
|
|
308
|
+
void
|
|
309
|
+
</div>
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
<h5>Example</h5>
|
|
319
|
+
|
|
320
|
+
<pre class="prettyprint"><code>// EXAMPLE: Populating and then clearing the history
|
|
321
|
+
mistral.complete("What's your name?"); // "John"
|
|
322
|
+
mistral.complete("How do you spell that?"); // "J-O-H-N"
|
|
323
|
+
mistral.clear();
|
|
324
|
+
mistral.complete("Tell me again?"); // "Tell you what again?"</code></pre>
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
<h4 class="name" id="complete"><span class="type-signature">(async) </span>complete<span class="signature">(prompt, config<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise.<<a href="LlaminateResponse.html">LlaminateResponse</a>>}</span></h4>
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
<div class="description">
|
|
342
|
+
Sends a prompt to the LLM service and returns a chat completion response.
|
|
343
|
+
</div>
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
<h5>Parameters:</h5>
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
<table class="params">
|
|
357
|
+
<thead>
|
|
358
|
+
<tr>
|
|
359
|
+
|
|
360
|
+
<th>Name</th>
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
<th>Type</th>
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
<th>Attributes</th>
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
<th class="last">Description</th>
|
|
372
|
+
</tr>
|
|
373
|
+
</thead>
|
|
374
|
+
|
|
375
|
+
<tbody>
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
<tr>
|
|
379
|
+
|
|
380
|
+
<td class="name"><code>prompt</code></td>
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
<td class="type">
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
<span class="param-type">string</span>
|
|
387
|
+
|
|
|
388
|
+
|
|
389
|
+
<span class="param-type">Array.<<a href="LlaminateMessage.html">LlaminateMessage</a>></span>
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
</td>
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
<td class="attributes">
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
</td>
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
<td class="description last">The input prompt or
|
|
408
|
+
messages to send to the service.</td>
|
|
409
|
+
</tr>
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
<tr>
|
|
414
|
+
|
|
415
|
+
<td class="name"><code>config</code></td>
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
<td class="type">
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
<span class="param-type"><a href="LlaminateConfig.html">LlaminateConfig</a></span>
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
</td>
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
<td class="attributes">
|
|
429
|
+
|
|
430
|
+
<optional><br>
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
</td>
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
<td class="description last">Optional configuration settings for
|
|
442
|
+
this completion.</td>
|
|
443
|
+
</tr>
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
</tbody>
|
|
447
|
+
</table>
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
<dl class="details">
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
</dl>
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
<h5>Throws:</h5>
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
<div class="param-desc">
|
|
506
|
+
|
|
507
|
+
Will throw an error if the prompt is invalid, the response is
|
|
508
|
+
unsuccessful, or if the response does not conform to the expected format.
|
|
509
|
+
|
|
510
|
+
</div>
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
<h5>Returns:</h5>
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
<div class="param-desc">
|
|
520
|
+
A promise resolving to a
|
|
521
|
+
LlaminateResponse from the service.
|
|
522
|
+
</div>
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
<dl>
|
|
527
|
+
<dt>
|
|
528
|
+
Type
|
|
529
|
+
</dt>
|
|
530
|
+
<dd>
|
|
531
|
+
|
|
532
|
+
<span class="param-type">Promise.<<a href="LlaminateResponse.html">LlaminateResponse</a>></span>
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
</dd>
|
|
536
|
+
</dl>
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
<h5>Examples</h5>
|
|
544
|
+
|
|
545
|
+
<pre class="prettyprint"><code>// EXAMPLE 1: Simple prompt with default configuration
|
|
546
|
+
const response = await mistral.complete("What's the capital of France?");
|
|
547
|
+
console.log(response.message); // "Paris"</code></pre>
|
|
548
|
+
|
|
549
|
+
<pre class="prettyprint"><code>// EXAMPLE 2: System messages set through configuration
|
|
550
|
+
const response = await mistral.complete("What's the capital of France?",
|
|
551
|
+
{ system: [
|
|
552
|
+
"You are a children's geography tutor.",
|
|
553
|
+
"Always reply as if you are explaining to a child."
|
|
554
|
+
] } );</code></pre>
|
|
555
|
+
|
|
556
|
+
<pre class="prettyprint"><code>// EXAMPLE 3: An image attachment (supported depends on LLM model)
|
|
557
|
+
const response = await mistral.complete(
|
|
558
|
+
"Generate a helpful HTML `alt` tag for this image.", {
|
|
559
|
+
attachments: [ { type: Llaminate.JPEG, url: "https://example.com/image.jpg" } ]
|
|
560
|
+
});</code></pre>
|
|
561
|
+
|
|
562
|
+
<pre class="prettyprint"><code>// EXAMPLE 4: Prompt with a pre-rolled conversation history
|
|
563
|
+
const history = [
|
|
564
|
+
{ role: "user", content: "What's a good name for a houseplant?" },
|
|
565
|
+
{ role: "assistant", content: "How about Fernie Sanders?" },
|
|
566
|
+
{ role: "user", content: "Nice. Any other suggestions?" },
|
|
567
|
+
{ role: "assistant", content: "How about Leaf Erickson?" }
|
|
568
|
+
];
|
|
569
|
+
const prompt = "Great. What could be its nickname?";
|
|
570
|
+
const response = await mistral.complete(prompt, { history });</code></pre>
|
|
571
|
+
|
|
572
|
+
<pre class="prettyprint"><code>// EXAMPLE 5: Rolling the conversation history into the prompt
|
|
573
|
+
const messages = history.concat({ role: "user", content: prompt });
|
|
574
|
+
const response = await mistral.complete(messages);</code></pre>
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
<h4 class="name" id="export"><span class="type-signature"></span>export<span class="signature">(window<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Array.<<a href="LlaminateMessage.html">LlaminateMessage</a>>}</span></h4>
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
|
|
591
|
+
<div class="description">
|
|
592
|
+
Exports the chat history. By default, this exports the entire chat
|
|
593
|
+
history. If a window is specified, only the most recent messages are
|
|
594
|
+
returned. The window counts back each of the most recent user message, it
|
|
595
|
+
includes assistant responses to these, and any system prompts set in the
|
|
596
|
+
global configuration.
|
|
597
|
+
</div>
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
<h5>Parameters:</h5>
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
<table class="params">
|
|
611
|
+
<thead>
|
|
612
|
+
<tr>
|
|
613
|
+
|
|
614
|
+
<th>Name</th>
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
<th>Type</th>
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
<th>Attributes</th>
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
<th class="last">Description</th>
|
|
626
|
+
</tr>
|
|
627
|
+
</thead>
|
|
628
|
+
|
|
629
|
+
<tbody>
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
<tr>
|
|
633
|
+
|
|
634
|
+
<td class="name"><code>window</code></td>
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
<td class="type">
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
<span class="param-type">number</span>
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
</td>
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
<td class="attributes">
|
|
648
|
+
|
|
649
|
+
<optional><br>
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
|
|
654
|
+
|
|
655
|
+
</td>
|
|
656
|
+
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
<td class="description last">The length of the window to retrieve.</td>
|
|
661
|
+
</tr>
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
</tbody>
|
|
665
|
+
</table>
|
|
666
|
+
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
<dl class="details">
|
|
673
|
+
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
</dl>
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
|
|
721
|
+
<h5>Returns:</h5>
|
|
722
|
+
|
|
723
|
+
|
|
724
|
+
<div class="param-desc">
|
|
725
|
+
An array of chat history messages.
|
|
726
|
+
</div>
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
|
|
730
|
+
<dl>
|
|
731
|
+
<dt>
|
|
732
|
+
Type
|
|
733
|
+
</dt>
|
|
734
|
+
<dd>
|
|
735
|
+
|
|
736
|
+
<span class="param-type">Array.<<a href="LlaminateMessage.html">LlaminateMessage</a>></span>
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
</dd>
|
|
740
|
+
</dl>
|
|
741
|
+
|
|
742
|
+
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
<h5>Examples</h5>
|
|
748
|
+
|
|
749
|
+
<pre class="prettyprint"><code>// EXAMPLE 1: Exporting the entire history of messages
|
|
750
|
+
const history = mistral.export();
|
|
751
|
+
localStorage.setItem('mistral-history', JSON.stringify(history));</code></pre>
|
|
752
|
+
|
|
753
|
+
<pre class="prettyprint"><code>// EXAMPLE 2: Getting a window of recent messages
|
|
754
|
+
// Returns the last 5 user-assistant interactions and all system prompts
|
|
755
|
+
const history = mistral.export(5);
|
|
756
|
+
console.log(history.length);
|
|
757
|
+
// e.g. 14 = 5 user messages + 5 assistant replies (one that included a
|
|
758
|
+
// tool call) + 2 system prompts</code></pre>
|
|
759
|
+
|
|
760
|
+
|
|
761
|
+
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
<h4 class="name" id="stream"><span class="type-signature">(async, generator) </span>stream<span class="signature">(prompt, config<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {<a href="LlaminateResponse.html">LlaminateResponse</a>}</span></h4>
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
|
|
775
|
+
<div class="description">
|
|
776
|
+
Sends a prompt to the LLM service and streams the response.
|
|
777
|
+
</div>
|
|
778
|
+
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
<h5>Parameters:</h5>
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
<table class="params">
|
|
791
|
+
<thead>
|
|
792
|
+
<tr>
|
|
793
|
+
|
|
794
|
+
<th>Name</th>
|
|
795
|
+
|
|
796
|
+
|
|
797
|
+
<th>Type</th>
|
|
798
|
+
|
|
799
|
+
|
|
800
|
+
<th>Attributes</th>
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
<th class="last">Description</th>
|
|
806
|
+
</tr>
|
|
807
|
+
</thead>
|
|
808
|
+
|
|
809
|
+
<tbody>
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
<tr>
|
|
813
|
+
|
|
814
|
+
<td class="name"><code>prompt</code></td>
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
<td class="type">
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
<span class="param-type">string</span>
|
|
821
|
+
|
|
|
822
|
+
|
|
823
|
+
<span class="param-type">Array.<<a href="LlaminateMessage.html">LlaminateMessage</a>></span>
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
</td>
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
<td class="attributes">
|
|
831
|
+
|
|
832
|
+
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
</td>
|
|
837
|
+
|
|
838
|
+
|
|
839
|
+
|
|
840
|
+
|
|
841
|
+
<td class="description last">The input prompt or
|
|
842
|
+
messages to send to the service.</td>
|
|
843
|
+
</tr>
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
|
|
847
|
+
<tr>
|
|
848
|
+
|
|
849
|
+
<td class="name"><code>config</code></td>
|
|
850
|
+
|
|
851
|
+
|
|
852
|
+
<td class="type">
|
|
853
|
+
|
|
854
|
+
|
|
855
|
+
<span class="param-type"><a href="LlaminateConfig.html">LlaminateConfig</a></span>
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
|
|
859
|
+
</td>
|
|
860
|
+
|
|
861
|
+
|
|
862
|
+
<td class="attributes">
|
|
863
|
+
|
|
864
|
+
<optional><br>
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
|
|
870
|
+
</td>
|
|
871
|
+
|
|
872
|
+
|
|
873
|
+
|
|
874
|
+
|
|
875
|
+
<td class="description last">Optional configuration settings for
|
|
876
|
+
this completion.</td>
|
|
877
|
+
</tr>
|
|
878
|
+
|
|
879
|
+
|
|
880
|
+
</tbody>
|
|
881
|
+
</table>
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
<dl class="details">
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
|
|
910
|
+
|
|
911
|
+
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
|
|
919
|
+
|
|
920
|
+
|
|
921
|
+
</dl>
|
|
922
|
+
|
|
923
|
+
|
|
924
|
+
|
|
925
|
+
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
<h5>Throws:</h5>
|
|
936
|
+
|
|
937
|
+
|
|
938
|
+
|
|
939
|
+
<div class="param-desc">
|
|
940
|
+
|
|
941
|
+
Will throw an error if the prompt is invalid, the response is
|
|
942
|
+
unsuccessful, or if the response does not conform to the expected format.
|
|
943
|
+
|
|
944
|
+
</div>
|
|
945
|
+
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
<h5>Yields:</h5>
|
|
953
|
+
|
|
954
|
+
|
|
955
|
+
<div class="param-desc">
|
|
956
|
+
An asynchronous generator yielding
|
|
957
|
+
responses from the service.
|
|
958
|
+
</div>
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
<dl>
|
|
963
|
+
<dt>
|
|
964
|
+
Type
|
|
965
|
+
</dt>
|
|
966
|
+
<dd>
|
|
967
|
+
|
|
968
|
+
<span class="param-type"><a href="LlaminateResponse.html">LlaminateResponse</a></span>
|
|
969
|
+
|
|
970
|
+
|
|
971
|
+
</dd>
|
|
972
|
+
</dl>
|
|
973
|
+
|
|
974
|
+
|
|
975
|
+
|
|
976
|
+
|
|
977
|
+
<h5>Examples</h5>
|
|
978
|
+
|
|
979
|
+
<pre class="prettyprint"><code>// EXAMPLE 1: Streaming the response to a simple prompt
|
|
980
|
+
const stream = mistral.stream("Tell me a joke and explain it.");
|
|
981
|
+
for await (const response of stream) {
|
|
982
|
+
console.log(response.message);
|
|
983
|
+
}</code></pre>
|
|
984
|
+
|
|
985
|
+
<pre class="prettyprint"><code>// EXAMPLE 2: Streaming a response with a structured output
|
|
986
|
+
const stream = mistral.stream("Tell me a joke and explain it.", {
|
|
987
|
+
schema: {
|
|
988
|
+
type: "object",
|
|
989
|
+
properties: {
|
|
990
|
+
joke: {
|
|
991
|
+
type: "string",
|
|
992
|
+
description: "Your response to the user's query."
|
|
993
|
+
},
|
|
994
|
+
explanation: {
|
|
995
|
+
type: "string",
|
|
996
|
+
description: "Your internal thoughts about the user's query."
|
|
997
|
+
},
|
|
998
|
+
},
|
|
999
|
+
required: ["joke", "explanation"],
|
|
1000
|
+
additionalProperties: false,
|
|
1001
|
+
}
|
|
1002
|
+
});
|
|
1003
|
+
for await (const response of stream) {
|
|
1004
|
+
// Initially streams as a string until the JSON schema can be validated
|
|
1005
|
+
console.log(response.message);
|
|
1006
|
+
console.log(response.message?.joke);
|
|
1007
|
+
console.log(response.message?.explanation);
|
|
1008
|
+
}</code></pre>
|
|
1009
|
+
|
|
1010
|
+
|
|
1011
|
+
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
|
|
1015
|
+
|
|
1016
|
+
|
|
1017
|
+
|
|
1018
|
+
</article>
|
|
1019
|
+
|
|
1020
|
+
</section>
|
|
1021
|
+
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
|
+
|
|
1025
|
+
</div>
|
|
1026
|
+
|
|
1027
|
+
<nav>
|
|
1028
|
+
<h4><a href="index.html">README.md</a></h4><h3>Modules</h3><ul><li><a href="Llaminate.module_Endpoints.html">Endpoints</a></li><li><a href="Llaminate.module_Llaminate.html">Llaminate</a></li><li><a href="Llaminate.module_MimeTypes.html">MimeTypes</a></li></ul><h3>Classes</h3><ul><li><a href="Llaminate.html">Llaminate</a></li></ul><h3>Interfaces</h3><ul><li><a href="LlaminateConfig.html">LlaminateConfig</a></li><li><a href="LlaminateMessage.html">LlaminateMessage</a></li><li><a href="LlaminateResponse.html">LlaminateResponse</a></li></ul>
|
|
1029
|
+
</nav>
|
|
1030
|
+
|
|
1031
|
+
<br class="clear">
|
|
1032
|
+
|
|
1033
|
+
<footer>
|
|
1034
|
+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc"> 4.0.5</a>
|
|
1035
|
+
</footer>
|
|
1036
|
+
|
|
1037
|
+
<script> prettyPrint(); </script>
|
|
1038
|
+
<script src="scripts/linenumber.js"> </script>
|
|
1039
|
+
</body>
|
|
1040
|
+
</html>
|