modelfusion 0.134.0 → 0.135.1

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/CHANGELOG.md DELETED
@@ -1,2301 +0,0 @@
1
- # Changelog
2
-
3
- ## v0.134.0 - 2024-01-28
4
-
5
- ### Added
6
-
7
- - Added prompt function support to `generateText`, `streamText`, `generateStructure`, and `streamStructure`. You can create prompt functions for text, instruction, and chat prompts using `createTextPrompt`, `createInstructionPrompt`, and `createChatPrompt`. Prompt functions allow you to load prompts from external sources and improve the prompt logging. Example:
8
-
9
- ```ts
10
- const storyPrompt = createInstructionPrompt(
11
- async ({ protagonist }: { protagonist: string }) => ({
12
- system: "You are an award-winning author.",
13
- instruction: `Write a short story about ${protagonist} learning to love.`,
14
- })
15
- );
16
-
17
- const text = await generateText({
18
- model: openai
19
- .ChatTextGenerator({ model: "gpt-3.5-turbo" })
20
- .withInstructionPrompt(),
21
-
22
- prompt: storyPrompt({
23
- protagonist: "a robot",
24
- }),
25
- });
26
- ```
27
-
28
- ### Changed
29
-
30
- - Refactored build to use `tsup`.
31
-
32
- ## v0.133.0 - 2024-01-26
33
-
34
- ### Added
35
-
36
- - Support for OpenAI embedding custom dimensions.
37
-
38
- ### Changed
39
-
40
- - **breaking change**: renamed `embeddingDimensions` setting to `dimensions`
41
-
42
- ## v0.132.0 - 2024-01-25
43
-
44
- ### Added
45
-
46
- - Support for OpenAI `text-embedding-3-small` and `text-embedding-3-large` embedding models.
47
- - Support for OpenAI `gpt-4-turbo-preview`, `gpt-4-0125-preview`, and `gpt-3.5-turbo-0125` chat models.
48
-
49
- ## v0.131.1 - 2024-01-25
50
-
51
- ### Fixed
52
-
53
- - Add `type-fest` as dependency to fix type inference errors.
54
-
55
- ## v0.131.0 - 2024-01-23
56
-
57
- ### Added
58
-
59
- - `ObjectStreamResponse` and `ObjectStreamFromResponse` serialization functions for using server-generated object streams in web applications.
60
-
61
- Server example:
62
-
63
- ```ts
64
- export async function POST(req: Request) {
65
- const { myArgs } = await req.json();
66
-
67
- const objectStream = await streamObject({
68
- // ...
69
- });
70
-
71
- // serialize the object stream to a response:
72
- return new ObjectStreamResponse(objectStream);
73
- }
74
- ```
75
-
76
- Client example:
77
-
78
- ```ts
79
- const response = await fetch("/api/stream-object-openai", {
80
- method: "POST",
81
- body: JSON.stringify({ myArgs }),
82
- });
83
-
84
- // deserialize (result object is simpler than the full response)
85
- const stream = ObjectStreamFromResponse({
86
- schema: itinerarySchema,
87
- response,
88
- });
89
-
90
- for await (const { partialObject } of stream) {
91
- // do something, e.g. setting a React state
92
- }
93
- ```
94
-
95
- ### Changed
96
-
97
- - **breaking change**: rename `generateStructure` to `generateObject` and `streamStructure` to `streamObject`. Related names have been changed accordingly.
98
- - **breaking change**: the `streamObject` result stream contains additional data. You need to use `stream.partialObject` or destructuring to access it:
99
-
100
- ```ts
101
- const objectStream = await streamObject({
102
- // ...
103
- });
104
-
105
- for await (const { partialObject } of objectStream) {
106
- console.clear();
107
- console.log(partialObject);
108
- }
109
- ```
110
-
111
- - **breaking change**: the result from successful `Schema` validations is stored in the `value` property (before: `data`).
112
-
113
- ## v0.130.1 - 2024-01-22
114
-
115
- ### Fixed
116
-
117
- - Duplex speech streaming works in Vercel Edge Functions.
118
-
119
- ## v0.130.0 - 2024-01-21
120
-
121
- ### Changed
122
-
123
- - **breaking change**: updated `generateTranscription` interface. The function now takes a `mimeType` and `audioData` (base64-encoded string, `Uint8Array`, `Buffer` or `ArrayBuffer`). Example:
124
-
125
- ```ts
126
- import { generateTranscription, openai } from "modelfusion";
127
- import fs from "node:fs";
128
-
129
- const transcription = await generateTranscription({
130
- model: openai.Transcriber({ model: "whisper-1" }),
131
- mimeType: "audio/mp3",
132
- audioData: await fs.promises.readFile("data/test.mp3"),
133
- });
134
- ```
135
-
136
- - Images in instruction and chat prompts can be `Buffer` or `ArrayBuffer` instances (in addition to base64-encoded strings and `Uint8Array` instances).
137
-
138
- ## v0.129.0 - 2024-01-20
139
-
140
- ### Changed
141
-
142
- - **breaking change**: Usage of Node `async_hooks` has been renamed from `node:async_hooks` to `async_hooks` for easier Webpack configuration. To exclude the `async_hooks` from client-side bundling, you can use the following config for Next.js (`next.config.mjs` or `next.config.js`):
143
-
144
- ```js
145
- /**
146
- * @type {import('next').NextConfig}
147
- */
148
- const nextConfig = {
149
- webpack: (config, { isServer }) => {
150
- if (isServer) {
151
- return config;
152
- }
153
-
154
- config.resolve = config.resolve ?? {};
155
- config.resolve.fallback = config.resolve.fallback ?? {};
156
-
157
- // async hooks is not available in the browser:
158
- config.resolve.fallback.async_hooks = false;
159
-
160
- return config;
161
- },
162
- };
163
- ```
164
-
165
- ## v0.128.0 - 2024-01-20
166
-
167
- ### Changed
168
-
169
- - **breaking change**: ModelFusion uses `Uint8Array` instead of `Buffer` for better cross-platform compatibility (see also ["Goodbye, Node.js Buffer"](https://sindresorhus.com/blog/goodbye-nodejs-buffer)). This can lead to breaking changes in your code if you use `Buffer`-specific methods.
170
- - **breaking change**: Image content in multi-modal instruction and chat inputs (e.g. for GPT Vision) is passed in the `image` property (instead of `base64Image`) and supports both base64 strings and `Uint8Array` inputs:
171
-
172
- ```ts
173
- const image = fs.readFileSync(path.join("data", "example-image.png"));
174
-
175
- const textStream = await streamText({
176
- model: openai.ChatTextGenerator({
177
- model: "gpt-4-vision-preview",
178
- maxGenerationTokens: 1000,
179
- }),
180
-
181
- prompt: [
182
- openai.ChatMessage.user([
183
- { type: "text", text: "Describe the image in detail:\n\n" },
184
- { type: "image", image, mimeType: "image/png" },
185
- ]),
186
- ],
187
- });
188
- ```
189
-
190
- - OpenAI-compatible providers with predefined API configurations have a customized provider name that shows up in the events.
191
-
192
- ## v0.127.0 - 2024-01-15
193
-
194
- ### Changed
195
-
196
- - **breaking change**: `streamStructure` returns an async iterable over deep partial objects. If you need to get the fully validated final result, you can use the `fullResponse: true` option and await the `structurePromise` value. Example:
197
-
198
- ```ts
199
- const { structureStream, structurePromise } = await streamStructure({
200
- model: ollama
201
- .ChatTextGenerator({
202
- model: "openhermes2.5-mistral",
203
- maxGenerationTokens: 1024,
204
- temperature: 0,
205
- })
206
- .asStructureGenerationModel(jsonStructurePrompt.text()),
207
-
208
- schema: zodSchema(
209
- z.object({
210
- characters: z.array(
211
- z.object({
212
- name: z.string(),
213
- class: z
214
- .string()
215
- .describe("Character class, e.g. warrior, mage, or thief."),
216
- description: z.string(),
217
- })
218
- ),
219
- })
220
- ),
221
-
222
- prompt:
223
- "Generate 3 character descriptions for a fantasy role playing game.",
224
-
225
- fullResponse: true,
226
- });
227
-
228
- for await (const partialStructure of structureStream) {
229
- console.clear();
230
- console.log(partialStructure);
231
- }
232
-
233
- const structure = await structurePromise;
234
-
235
- console.clear();
236
- console.log("FINAL STRUCTURE");
237
- console.log(structure);
238
- ```
239
-
240
- - **breaking change**: Renamed `text` value in `streamText` with `fullResponse: true` to `textPromise`.
241
-
242
- ### Fixed
243
-
244
- - Ollama streaming.
245
- - Ollama structure generation and streaming.
246
-
247
- ## v0.126.0 - 2024-01-15
248
-
249
- ### Changed
250
-
251
- - **breaking change**: rename `useTool` to `runTool` and `useTools` to `runTools` to avoid confusion with React hooks.
252
-
253
- ## v0.125.0 - 2024-01-14
254
-
255
- ### Added
256
-
257
- - Perplexity AI chat completion support. Example:
258
-
259
- ```ts
260
- import { openaicompatible, streamText } from "modelfusion";
261
-
262
- const textStream = await streamText({
263
- model: openaicompatible
264
- .ChatTextGenerator({
265
- api: openaicompatible.PerplexityApi(),
266
- provider: "openaicompatible-perplexity",
267
- model: "pplx-70b-online", // online model with access to web search
268
- maxGenerationTokens: 500,
269
- })
270
- .withTextPrompt(),
271
-
272
- prompt: "What is RAG in AI?",
273
- });
274
- ```
275
-
276
- ## v0.124.0 - 2024-01-13
277
-
278
- ### Added
279
-
280
- - [Embedding-support for OpenAI-compatible providers](https://modelfusion.dev/integration/model-provider/openaicompatible/#embed-text). You can for example use the Together AI embedding endpoint:
281
-
282
- ```ts
283
- import { embed, openaicompatible } from "modelfusion";
284
-
285
- const embedding = await embed({
286
- model: openaicompatible.TextEmbedder({
287
- api: openaicompatible.TogetherAIApi(),
288
- provider: "openaicompatible-togetherai",
289
- model: "togethercomputer/m2-bert-80M-8k-retrieval",
290
- }),
291
- value: "At first, Nox didn't know what to do with the pup.",
292
- });
293
- ```
294
-
295
- ## v0.123.0 - 2024-01-13
296
-
297
- ### Added
298
-
299
- - `classify` model function ([docs](https://modelfusion.dev/guide/function/classify)) for classifying values. The `SemanticClassifier` has been renamed to `EmbeddingSimilarityClassifier` and can be used in conjunction with `classify`:
300
-
301
- ```ts
302
- import { classify, EmbeddingSimilarityClassifier, openai } from "modelfusion";
303
-
304
- const classifier = new EmbeddingSimilarityClassifier({
305
- embeddingModel: openai.TextEmbedder({ model: "text-embedding-ada-002" }),
306
- similarityThreshold: 0.82,
307
- clusters: [
308
- {
309
- name: "politics" as const,
310
- values: [
311
- "they will save the country!",
312
- // ...
313
- ],
314
- },
315
- {
316
- name: "chitchat" as const,
317
- values: [
318
- "how's the weather today?",
319
- // ...
320
- ],
321
- },
322
- ],
323
- });
324
-
325
- // strongly typed result:
326
- const result = await classify({
327
- model: classifier,
328
- value: "don't you love politics?",
329
- });
330
- ```
331
-
332
- ## v0.122.0 - 2024-01-13
333
-
334
- ### Changed
335
-
336
- - **breaking change**: Switch from positional parameters to named parameters (parameter object) for all model and tool functions. The parameter object is the first and only parameter of the function. Additional options (last parameter before) are now part of the parameter object. Example:
337
-
338
- ```ts
339
- // old:
340
- const text = await generateText(
341
- openai
342
- .ChatTextGenerator({
343
- model: "gpt-3.5-turbo",
344
- maxGenerationTokens: 1000,
345
- })
346
- .withTextPrompt(),
347
-
348
- "Write a short story about a robot learning to love",
349
-
350
- {
351
- functionId: "example-function",
352
- }
353
- );
354
-
355
- // new:
356
- const text = await generateText({
357
- model: openai
358
- .ChatTextGenerator({
359
- model: "gpt-3.5-turbo",
360
- maxGenerationTokens: 1000,
361
- })
362
- .withTextPrompt(),
363
-
364
- prompt: "Write a short story about a robot learning to love",
365
-
366
- functionId: "example-function",
367
- });
368
- ```
369
-
370
- This change was made to make the API more flexible and to allow for future extensions.
371
-
372
- ## v0.121.2 - 2024-01-11
373
-
374
- ### Fixed
375
-
376
- - Ollama response schema for repeated calls with Ollama 0.1.19 completion models. Thanks [@Necmttn](https://github.com/Necmttn) for the bugfix!
377
-
378
- ## v0.121.1 - 2024-01-10
379
-
380
- ### Fixed
381
-
382
- - Ollama response schema for repeated calls with Ollama 0.1.19 chat models. Thanks [@jakedetels](https://github.com/jakedetels) for the bug report!
383
-
384
- ## v0.121.0 - 2024-01-09
385
-
386
- ### Added
387
-
388
- - Synthia prompt template
389
-
390
- ### Changed
391
-
392
- - **breaking change**: Renamed `parentCallId` function parameter to `callId` to enable options pass-through.
393
- - Better output filtering for `detailed-object` log format (e.g. via `modelfusion.setLogFormat("detailed-object")`)
394
-
395
- ## v0.120.0 - 2024-01-09
396
-
397
- ### Added
398
-
399
- - `OllamaCompletionModel` supports setting the prompt template in the settings. Prompt formats are available under `ollama.prompt.*`. You can then call `.withTextPrompt()`, `.withInstructionPrompt()` or `.withChatPrompt()` to use a standardized prompt.
400
-
401
- ```ts
402
- const model = ollama
403
- .CompletionTextGenerator({
404
- model: "mistral",
405
- promptTemplate: ollama.prompt.Mistral,
406
- raw: true, // required when using custom prompt template
407
- maxGenerationTokens: 120,
408
- })
409
- .withTextPrompt();
410
- ```
411
-
412
- ### Removed
413
-
414
- - **breaking change**: removed `.withTextPromptTemplate` on `OllamaCompletionModel`.
415
-
416
- ## v0.119.1 - 2024-01-08
417
-
418
- ### Fixed
419
-
420
- - Incorrect export. Thanks [@mloenow](https://github.com/mloenow) for the fix!
421
-
422
- ## v0.119.0 - 2024-01-07
423
-
424
- ### Added
425
-
426
- - Schema-specific GBNF grammar generator for `LlamaCppCompletionModel`. When using `jsonStructurePrompt`, it automatically uses a GBNF grammar for the JSON schema that you provide. Example:
427
-
428
- ```ts
429
- const structure = await generateStructure(
430
- llamacpp
431
- .CompletionTextGenerator({
432
- // run openhermes-2.5-mistral-7b.Q4_K_M.gguf in llama.cpp
433
- promptTemplate: llamacpp.prompt.ChatML,
434
- maxGenerationTokens: 1024,
435
- temperature: 0,
436
- })
437
- // automatically restrict the output to your schema using GBNF:
438
- .asStructureGenerationModel(jsonStructurePrompt.text()),
439
-
440
- zodSchema(
441
- z.array(
442
- z.object({
443
- name: z.string(),
444
- class: z
445
- .string()
446
- .describe("Character class, e.g. warrior, mage, or thief."),
447
- description: z.string(),
448
- })
449
- )
450
- ),
451
-
452
- "Generate 3 character descriptions for a fantasy role playing game. "
453
- );
454
- ```
455
-
456
- ## v0.118.0 - 2024-01-07
457
-
458
- ### Added
459
-
460
- - `LlamaCppCompletionModel` supports setting the prompt template in the settings. Prompt formats are available under `llamacpp.prompt.*`. You can then call `.withTextPrompt()`, `.withInstructionPrompt()` or `.withChatPrompt()` to use a standardized prompt.
461
-
462
- ```ts
463
- const model = llamacpp
464
- .CompletionTextGenerator({
465
- // run https://huggingface.co/TheBloke/OpenHermes-2.5-Mistral-7B-GGUF with llama.cpp
466
- promptTemplate: llamacpp.prompt.ChatML,
467
- contextWindowSize: 4096,
468
- maxGenerationTokens: 512,
469
- })
470
- .withChatPrompt();
471
- ```
472
-
473
- ### Changed
474
-
475
- - **breaking change**: renamed `response` to `rawResponse` when using `fullResponse: true` setting.
476
- - **breaking change**: renamed `llamacpp.TextGenerator` to `llamacpp.CompletionTextGenerator`.
477
-
478
- ### Removed
479
-
480
- - **breaking change**: removed `.withTextPromptTemplate` on `LlamaCppCompletionModel`.
481
-
482
- ## v0.117.0 - 2024-01-06
483
-
484
- ### Added
485
-
486
- - Predefined Llama.cpp GBNF grammars:
487
-
488
- - `llamacpp.grammar.json`: Restricts the output to JSON.
489
- - `llamacpp.grammar.jsonArray`: Restricts the output to a JSON array.
490
- - `llamacpp.grammar.list`: Restricts the output to a newline-separated list where each line starts with `- `.
491
-
492
- - Llama.cpp structure generation support:
493
-
494
- ```ts
495
- const structure = await generateStructure(
496
- llamacpp
497
- .TextGenerator({
498
- // run openhermes-2.5-mistral-7b.Q4_K_M.gguf in llama.cpp
499
- maxGenerationTokens: 1024,
500
- temperature: 0,
501
- })
502
- .withTextPromptTemplate(ChatMLPrompt.instruction()) // needed for jsonStructurePrompt.text()
503
- .asStructureGenerationModel(jsonStructurePrompt.text()), // automatically restrict the output to JSON
504
-
505
- zodSchema(
506
- z.object({
507
- characters: z.array(
508
- z.object({
509
- name: z.string(),
510
- class: z
511
- .string()
512
- .describe("Character class, e.g. warrior, mage, or thief."),
513
- description: z.string(),
514
- })
515
- ),
516
- })
517
- ),
518
-
519
- "Generate 3 character descriptions for a fantasy role playing game. "
520
- );
521
- ```
522
-
523
- ## v0.116.0 - 2024-01-05
524
-
525
- ### Added
526
-
527
- - Semantic classifier. An easy way to determine a class of a text using embeddings. Example:
528
-
529
- ```ts
530
- import { SemanticClassifier, openai } from "modelfusion";
531
-
532
- const classifier = new SemanticClassifier({
533
- embeddingModel: openai.TextEmbedder({
534
- model: "text-embedding-ada-002",
535
- }),
536
- similarityThreshold: 0.82,
537
- clusters: [
538
- {
539
- name: "politics" as const,
540
- values: [
541
- "isn't politics the best thing ever",
542
- "why don't you tell me about your political opinions",
543
- "don't you just love the president",
544
- "don't you just hate the president",
545
- "they're going to destroy this country!",
546
- "they will save the country!",
547
- ],
548
- },
549
- {
550
- name: "chitchat" as const,
551
- values: [
552
- "how's the weather today?",
553
- "how are things going?",
554
- "lovely weather today",
555
- "the weather is horrendous",
556
- "let's go to the chippy",
557
- ],
558
- },
559
- ],
560
- });
561
-
562
- console.log(await classifier.classify("don't you love politics?")); // politics
563
- console.log(await classifier.classify("how's the weather today?")); // chitchat
564
- console.log(
565
- await classifier.classify("I'm interested in learning about llama 2")
566
- ); // null
567
- ```
568
-
569
- ## v0.115.0 - 2024-01-05
570
-
571
- ### Removed
572
-
573
- - Anthropic support. Anthropic has a strong stance against open-source models and against non-US AI. I will not support them by providing a ModelFusion integration.
574
-
575
- ## v0.114.1 - 2024-01-05
576
-
577
- ### Fixed
578
-
579
- - Together AI text generation and text streaming using OpenAI-compatible chat models.
580
-
581
- ## v0.114.0 - 2024-01-05
582
-
583
- ### Added
584
-
585
- - Custom call header support for APIs. You can pass a `customCallHeaders` function into API configurations to add custom headers. The function is called with `functionType`, `functionId`, `run`, and `callId` parameters. Example for Helicone:
586
-
587
- ```ts
588
- const text = await generateText(
589
- openai
590
- .ChatTextGenerator({
591
- api: new HeliconeOpenAIApiConfiguration({
592
- customCallHeaders: ({ functionId, callId }) => ({
593
- "Helicone-Property-FunctionId": functionId,
594
- "Helicone-Property-CallId": callId,
595
- }),
596
- }),
597
- model: "gpt-3.5-turbo",
598
- temperature: 0.7,
599
- maxGenerationTokens: 500,
600
- })
601
- .withTextPrompt(),
602
-
603
- "Write a short story about a robot learning to love",
604
-
605
- { functionId: "example-function" }
606
- );
607
- ```
608
-
609
- - Rudimentary caching support for `generateText`. You can use a `MemoryCache` to store the response of a `generateText` call. Example:
610
-
611
- ```ts
612
- import { MemoryCache, generateText, ollama } from "modelfusion";
613
-
614
- const model = ollama
615
- .ChatTextGenerator({ model: "llama2:chat", maxGenerationTokens: 100 })
616
- .withTextPrompt();
617
-
618
- const cache = new MemoryCache();
619
-
620
- const text1 = await generateText(
621
- model,
622
- "Write a short story about a robot learning to love:",
623
- { cache }
624
- );
625
-
626
- console.log(text1);
627
-
628
- // 2nd call will use cached response:
629
- const text2 = await generateText(
630
- model,
631
- "Write a short story about a robot learning to love:", // same text
632
- { cache }
633
- );
634
-
635
- console.log(text2);
636
- ```
637
-
638
- - `validateTypes` and `safeValidateTypes` helpers that perform type checking of an object against a `Schema` (e.g., a `zodSchema`).
639
-
640
- ## v0.113.0 - 2024-01-03
641
-
642
- [Structure generation](https://modelfusion.dev/guide/function/generate-structure) improvements.
643
-
644
- ### Added
645
-
646
- - `.asStructureGenerationModel(...)` function to `OpenAIChatModel` and `OllamaChatModel` to create structure generation models from chat models.
647
- - `jsonStructurePrompt` helper function to create structure generation models.
648
-
649
- ### Example
650
-
651
- ```ts
652
- import {
653
- generateStructure,
654
- jsonStructurePrompt,
655
- ollama,
656
- zodSchema,
657
- } from "modelfusion";
658
-
659
- const structure = await generateStructure(
660
- ollama
661
- .ChatTextGenerator({
662
- model: "openhermes2.5-mistral",
663
- maxGenerationTokens: 1024,
664
- temperature: 0,
665
- })
666
- .asStructureGenerationModel(jsonStructurePrompt.text()),
667
-
668
- zodSchema(
669
- z.object({
670
- characters: z.array(
671
- z.object({
672
- name: z.string(),
673
- class: z
674
- .string()
675
- .describe("Character class, e.g. warrior, mage, or thief."),
676
- description: z.string(),
677
- })
678
- ),
679
- })
680
- ),
681
-
682
- "Generate 3 character descriptions for a fantasy role playing game. "
683
- );
684
- ```
685
-
686
- ## v0.112.0 - 2024-01-02
687
-
688
- ### Changed
689
-
690
- - **breaking change**: renamed `useToolsOrGenerateText` to `useTools`
691
- - **breaking change**: renamed `generateToolCallsOrText` to `generateToolCalls`
692
-
693
- ### Removed
694
-
695
- - Restriction on tool names. OpenAI tool calls do not have such a restriction.
696
-
697
- ## v0.111.0 - 2024-01-01
698
-
699
- Reworked API configuration support.
700
-
701
- ### Added
702
-
703
- - All providers now have an `Api` function that you can call to create custom API configurations. The base URL set up is more flexible and allows you to override parts of the base URL selectively.
704
- - `api` namespace with retry and throttle configurations
705
-
706
- ### Changed
707
-
708
- - Updated Cohere models.
709
- - Updated LMNT API calls to LMNT `v1` API.
710
- - **breaking change**: Renamed `throttleUnlimitedConcurrency` to `throttleOff`.
711
-
712
- ## v0.110.0 - 2023-12-30
713
-
714
- ### Changed
715
-
716
- - **breaking change**: renamed `modelfusion/extension` to `modelfusion/internal`. This requires updating `modelfusion-experimental` (if used) to `v0.3.0`
717
-
718
- ### Removed
719
-
720
- - Deprecated OpenAI completion models that will be deactivated on January 4, 2024.
721
-
722
- ## v0.109.0 - 2023-12-30
723
-
724
- ### Added
725
-
726
- - [Open AI compatible completion model](https://modelfusion.dev/integration/model-provider/openaicompatible/). It e.g. works with Fireworks AI.
727
- - Together AI API configuration (for Open AI compatible chat models):
728
-
729
- ```ts
730
- import {
731
- TogetherAIApiConfiguration,
732
- openaicompatible,
733
- streamText,
734
- } from "modelfusion";
735
-
736
- const textStream = await streamText(
737
- openaicompatible
738
- .ChatTextGenerator({
739
- api: new TogetherAIApiConfiguration(),
740
- model: "mistralai/Mixtral-8x7B-Instruct-v0.1",
741
- })
742
- .withTextPrompt(),
743
-
744
- "Write a story about a robot learning to love"
745
- );
746
- ```
747
-
748
- - Updated Llama.cpp model settings. GBNF grammars can be passed into the `grammar` setting:
749
-
750
- ```ts
751
- const text = await generateText(
752
- llamacpp
753
- .TextGenerator({
754
- maxGenerationTokens: 512,
755
- temperature: 0,
756
- // simple list grammar:
757
- grammar: `root ::= ("- " item)+
758
- item ::= [^\\n]+ "\\n"`,
759
- })
760
- .withTextPromptTemplate(MistralInstructPrompt.text()),
761
-
762
- "List 5 ingredients for a lasagna:\n\n"
763
- );
764
- ```
765
-
766
- ## v0.107.0 - 2023-12-29
767
-
768
- ### Added
769
-
770
- - Mistral instruct prompt template
771
-
772
- ### Changed
773
-
774
- - **breaking change**: Renamed `LlamaCppTextGenerationModel` to `LlamaCppCompletionModel`.
775
-
776
- ### Fixed
777
-
778
- - Updated `LlamaCppCompletionModel` to the latest llama.cpp version.
779
- - Fixed formatting of system prompt for chats in Llama2 2 prompt template.
780
-
781
- ## v0.106.0 - 2023-12-28
782
-
783
- Experimental features that are unlikely to become stable before v1.0 have been moved to a separate `modelfusion-experimental` package.
784
-
785
- ### Removed
786
-
787
- - Cost calculation
788
- - `guard` function
789
- - Browser and server features (incl. flow)
790
- - `summarizeRecursively` function
791
-
792
- ## v0.105.0 - 2023-12-26
793
-
794
- ### Added
795
-
796
- - Tool call support for chat prompts. Assistant messages can contain tool calls, and tool messages can contain tool call results. Tool calls can be used to implement e.g. agents:
797
-
798
- ```ts
799
- const chat: ChatPrompt = {
800
- system: "You are ...",
801
- messages: [ChatMessage.user({ text: instruction })],
802
- };
803
-
804
- while (true) {
805
- const { text, toolResults } = await useToolsOrGenerateText(
806
- openai
807
- .ChatTextGenerator({ model: "gpt-4-1106-preview" })
808
- .withChatPrompt(),
809
- tools, // array of tools
810
- chat
811
- );
812
-
813
- // add the assistant and tool messages to the chat:
814
- chat.messages.push(
815
- ChatMessage.assistant({ text, toolResults }),
816
- ChatMessage.tool({ toolResults })
817
- );
818
-
819
- if (toolResults == null) {
820
- return; // no more actions, break loop
821
- }
822
-
823
- // ... (handle tool results)
824
- }
825
- ```
826
-
827
- - `streamText` returns a `text` promise when invoked with `fullResponse: true`. After the streaming has finished, the promise resolves with the full text.
828
-
829
- ```ts
830
- const { text, textStream } = await streamText(
831
- openai.ChatTextGenerator({ model: "gpt-3.5-turbo" }).withTextPrompt(),
832
- "Write a short story about a robot learning to love:",
833
- { fullResponse: true }
834
- );
835
-
836
- // ... (handle streaming)
837
-
838
- console.log(await text); // full text
839
- ```
840
-
841
- ## v0.104.0 - 2023-12-24
842
-
843
- ### Changed
844
-
845
- - **breaking change**: Unified text and multimodal prompt templates. `[Text/MultiModal]InstructionPrompt` is now `InstructionPrompt`, and `[Text/MultiModalChatPrompt]` is now `ChatPrompt`.
846
- - More flexible chat prompts: The chat prompt validation is now chat template specific and validated at runtime. E.g. the Llama2 prompt template only supports turns of user and assistant messages, whereas other formats are more flexible.
847
-
848
- ## v0.103.0 - 2023-12-23
849
-
850
- ### Added
851
-
852
- - `finishReason` support for `generateText`.
853
-
854
- The finish reason can be `stop` (the model stopped because it generated a stop sequence), `length` (the model stopped because it generated the maximum number of tokens), `content-filter` (the model stopped because the content filter detected a violation), `tool-calls` (the model stopped because it triggered a tool call), `error` (the model stopped because of an error), `other` (the model stopped for another reason), or `unknown` (the model stop reason is not know or the model does not support finish reasons).
855
-
856
- You can extract it from the full response when using `fullResponse: true`:
857
-
858
- ```ts
859
- const { text, finishReason } = await generateText(
860
- openai
861
- .ChatTextGenerator({ model: "gpt-3.5-turbo", maxGenerationTokens: 200 })
862
- .withTextPrompt(),
863
- "Write a short story about a robot learning to love:",
864
- { fullResponse: true }
865
- );
866
- ```
867
-
868
- ## v0.102.0 - 2023-12-22
869
-
870
- ### Added
871
-
872
- - You can specify `numberOfGenerations` on image generation models and create multiple images by using the `fullResponse: true` option. Example:
873
-
874
- ```ts
875
- // generate 2 images:
876
- const { images } = await generateImage(
877
- openai.ImageGenerator({
878
- model: "dall-e-3",
879
- numberOfGenerations: 2,
880
- size: "1024x1024",
881
- }),
882
- "the wicked witch of the west in the style of early 19th century painting",
883
- { fullResponse: true }
884
- );
885
- ```
886
-
887
- - **breaking change**: Image generation models use a generalized `numberOfGenerations` parameter (instead of model specific parameters) to specify the number of generations.
888
-
889
- ## v0.101.0 - 2023-12-22
890
-
891
- ### Changed
892
-
893
- - Automatic1111 Stable Diffusion Web UI configuration has separate configuration of host, port, and path.
894
-
895
- ### Fixed
896
-
897
- - Automatic1111 Stable Diffusion Web UI uses negative prompt and seed.
898
-
899
- ## v0.100.0 - 2023-12-17
900
-
901
- ### Added
902
-
903
- - `ollama.ChatTextGenerator` model that calls the Ollama chat API.
904
- - Ollama chat messages and prompts are exposed through `ollama.ChatMessage` and `ollama.ChatPrompt`
905
- - OpenAI chat messages and prompts are exposed through `openai.ChatMessage` and `openai.ChatPrompt`
906
- - Mistral chat messages and prompts are exposed through `mistral.ChatMessage` and `mistral.ChatPrompt`
907
-
908
- ### Changed
909
-
910
- - **breaking change**: renamed `ollama.TextGenerator` to `ollama.CompletionTextGenerator`
911
- - **breaking change**: renamed `mistral.TextGenerator` to `mistral.ChatTextGenerator`
912
-
913
- ## v0.99.0 - 2023-12-16
914
-
915
- ### Added
916
-
917
- - You can specify `numberOfGenerations` on text generation models and access multiple generations by using the `fullResponse: true` option. Example:
918
-
919
- ```ts
920
- // generate 2 texts:
921
- const { texts } = await generateText(
922
- openai.CompletionTextGenerator({
923
- model: "gpt-3.5-turbo-instruct",
924
- numberOfGenerations: 2,
925
- maxGenerationTokens: 1000,
926
- }),
927
- "Write a short story about a robot learning to love:\n\n",
928
- { fullResponse: true }
929
- );
930
- ```
931
-
932
- - **breaking change**: Text generation models use a generalized `numberOfGenerations` parameter (instead of model specific parameters) to specify the number of generations.
933
-
934
- ### Changed
935
-
936
- - **breaking change**: Renamed `maxCompletionTokens` text generation model setting to `maxGenerationTokens`.
937
-
938
- ## v0.98.0 - 2023-12-16
939
-
940
- ### Changed
941
-
942
- - **breaking change**: `responseType` option was changed into `fullResponse` option and uses a boolean value to make discovery easy. The response values from the full response have been renamed for clarity. For base64 image generation, you can use the `imageBase64` value from the full response:
943
-
944
- ```ts
945
- const { imageBase64 } = await generateImage(model, prompt, {
946
- fullResponse: true,
947
- });
948
- ```
949
-
950
- ### Improved
951
-
952
- - Better docs for the OpenAI chat settings. Thanks [@bearjaws](https://github.com/bearjaws) for the contribution!
953
-
954
- ### Fixed
955
-
956
- - Streaming OpenAI chat text generation when setting `n:2` or higher returns only the stream from the first choice.
957
-
958
- ## v0.97.0 - 2023-12-14
959
-
960
- ### Added
961
-
962
- - **breaking change**: Ollama image (vision) support. This changes the Ollama prompt format. You can add `.withTextPrompt()` to existing Ollama text generators to get a text prompt like before.
963
-
964
- Vision example:
965
-
966
- ```ts
967
- import { ollama, streamText } from "modelfusion";
968
-
969
- const textStream = await streamText(
970
- ollama.TextGenerator({
971
- model: "bakllava",
972
- maxCompletionTokens: 1024,
973
- temperature: 0,
974
- }),
975
- {
976
- prompt: "Describe the image in detail",
977
- images: [image], // base-64 encoded png or jpeg
978
- }
979
- );
980
- ```
981
-
982
- ### Changed
983
-
984
- - **breaking change**: Switch Ollama settings to camelCase to align with the rest of the library.
985
-
986
- ## v0.96.0 - 2023-12-14
987
-
988
- ### Added
989
-
990
- - [Mistral platform support](https://modelfusion.dev/integration/model-provider/mistral)
991
-
992
- ## v0.95.0 - 2023-12-10
993
-
994
- ### Added
995
-
996
- - `cachePrompt` parameter for llama.cpp models. Thanks [@djwhitt](https://github.com/djwhitt) for the contribution!
997
-
998
- ## v0.94.0 - 2023-12-10
999
-
1000
- ### Added
1001
-
1002
- - Prompt template for neural-chat models.
1003
-
1004
- ## v0.93.0 - 2023-12-10
1005
-
1006
- ### Added
1007
-
1008
- - Optional response prefix for instruction prompts to guide the LLM response.
1009
-
1010
- ### Changed
1011
-
1012
- - **breaking change**: Renamed prompt format to prompt template to align with the commonly used language (e.g. from model cards).
1013
-
1014
- ## v0.92.1 - 2023-12-10
1015
-
1016
- ### Changed
1017
-
1018
- - Improved Ollama error handling.
1019
-
1020
- ## v0.92.0 - 2023-12-09
1021
-
1022
- ### Changed
1023
-
1024
- - **breaking change**: setting global function observers and global logging has changed.
1025
- You can call methods on a `modelfusion` import:
1026
-
1027
- ```ts
1028
- import { modelfusion } from "modelfusion";
1029
-
1030
- modelfusion.setLogFormat("basic-text");
1031
- ```
1032
-
1033
- - Cleaned output when using `detailed-object` log format.
1034
-
1035
- ## v0.91.0 - 2023-12-09
1036
-
1037
- ### Added
1038
-
1039
- - `Whisper.cpp` [transcription (speech-to-text) model](https://modelfusion.dev/integration/model-provider/whispercpp) support.
1040
-
1041
- ```ts
1042
- import { generateTranscription, whispercpp } from "modelfusion";
1043
-
1044
- const data = await fs.promises.readFile("data/test.wav");
1045
-
1046
- const transcription = await generateTranscription(whispercpp.Transcriber(), {
1047
- type: "wav",
1048
- data,
1049
- });
1050
- ```
1051
-
1052
- ### Improved
1053
-
1054
- - Better error reporting.
1055
-
1056
- ## v0.90.0 - 2023-12-03
1057
-
1058
- ### Added
1059
-
1060
- - Temperature and language settings to OpenAI transcription model.
1061
-
1062
- ## v0.89.0 - 2023-11-30
1063
-
1064
- ### Added
1065
-
1066
- - `maxValuesPerCall` setting for `OpenAITextEmbeddingModel` to enable different configurations, e.g. for Azure. Thanks [@nanotronic](https://github.com/nanotronic) for the contribution!
1067
-
1068
- ## v0.88.0 - 2023-11-28
1069
-
1070
- ### Added
1071
-
1072
- - Multi-modal chat prompts. Supported by OpenAI vision chat models and by BakLLaVA prompt format.
1073
-
1074
- ### Changed
1075
-
1076
- - **breaking change**: renamed `ChatPrompt` to `TextChatPrompt` to distinguish it from multi-modal chat prompts.
1077
-
1078
- ## v0.87.0 - 2023-11-27
1079
-
1080
- ### Added
1081
-
1082
- - **experimental**: `modelfusion/extension` export with functions and classes that are necessary to implement providers in 3rd party node modules. See [lgrammel/modelfusion-example-provider](https://github.com/lgrammel/modelfusion-example-provider) for an example.
1083
-
1084
- ## v0.85.0 - 2023-11-26
1085
-
1086
- ### Added
1087
-
1088
- - `OpenAIChatMessage` function call support.
1089
-
1090
- ## v0.84.0 - 2023-11-26
1091
-
1092
- ### Added
1093
-
1094
- - Support for OpenAI-compatible chat APIs. See [OpenAI Compatible](https://modelfusion.dev/integration/model-provider/openaicompatible) for details.
1095
-
1096
- ```ts
1097
- import {
1098
- BaseUrlApiConfiguration,
1099
- openaicompatible,
1100
- generateText,
1101
- } from "modelfusion";
1102
-
1103
- const text = await generateText(
1104
- openaicompatible
1105
- .ChatTextGenerator({
1106
- api: new BaseUrlApiConfiguration({
1107
- baseUrl: "https://api.fireworks.ai/inference/v1",
1108
- headers: {
1109
- Authorization: `Bearer ${process.env.FIREWORKS_API_KEY}`,
1110
- },
1111
- }),
1112
- model: "accounts/fireworks/models/mistral-7b",
1113
- })
1114
- .withTextPrompt(),
1115
-
1116
- "Write a story about a robot learning to love"
1117
- );
1118
- ```
1119
-
1120
- ## v0.83.0 - 2023-11-26
1121
-
1122
- ### Added
1123
-
1124
- - Introduce `uncheckedSchema()` facade function as an easier way to create unchecked ModelFusion schemas. This aligns the API with `zodSchema()`.
1125
-
1126
- ### Changed
1127
-
1128
- - **breaking change**: Renamed `InstructionPrompt` interface to `MultiModalInstructionPrompt` to clearly distinguish it from `TextInstructionPrompt`.
1129
- - **breaking change**: Renamed `.withBasicPrompt` methods for image generation models to `.withTextPrompt` to align with text generation models.
1130
-
1131
- ## v0.82.0 - 2023-11-25
1132
-
1133
- ### Added
1134
-
1135
- - Introduce `zodSchema()` facade function as an easier way to create new ModelFusion Zod schemas. This clearly distinguishes it from `ZodSchema` that is also part of the zod library.
1136
-
1137
- ## v0.81.0 - 2023-11-25
1138
-
1139
- **breaking change**: `generateStructure` and `streamStructure` redesign. The new API does not require function calling and `StructureDefinition` objects any more. This makes it more flexible and it can be used in 3 ways:
1140
-
1141
- - with OpenAI function calling:
1142
-
1143
- ```ts
1144
- const model = openai
1145
- .ChatTextGenerator({ model: "gpt-3.5-turbo" })
1146
- .asFunctionCallStructureGenerationModel({
1147
- fnName: "...",
1148
- fnDescription: "...",
1149
- });
1150
- ```
1151
-
1152
- - with OpenAI JSON format:
1153
-
1154
- ```ts
1155
- const model = openai
1156
- .ChatTextGenerator({
1157
- model: "gpt-4-1106-preview",
1158
- temperature: 0,
1159
- maxCompletionTokens: 1024,
1160
- responseFormat: { type: "json_object" },
1161
- })
1162
- .asStructureGenerationModel(
1163
- jsonStructurePrompt((instruction: string, schema) => [
1164
- OpenAIChatMessage.system(
1165
- "JSON schema: \n" +
1166
- JSON.stringify(schema.getJsonSchema()) +
1167
- "\n\n" +
1168
- "Respond only using JSON that matches the above schema."
1169
- ),
1170
- OpenAIChatMessage.user(instruction),
1171
- ])
1172
- );
1173
- ```
1174
-
1175
- - with Ollama (and a capable model, e.g., OpenHermes 2.5):
1176
- ```ts
1177
- const model = ollama
1178
- .TextGenerator({
1179
- model: "openhermes2.5-mistral",
1180
- maxCompletionTokens: 1024,
1181
- temperature: 0,
1182
- format: "json",
1183
- raw: true,
1184
- stopSequences: ["\n\n"], // prevent infinite generation
1185
- })
1186
- .withPromptFormat(ChatMLPromptFormat.instruction())
1187
- .asStructureGenerationModel(
1188
- jsonStructurePrompt((instruction: string, schema) => ({
1189
- system:
1190
- "JSON schema: \n" +
1191
- JSON.stringify(schema.getJsonSchema()) +
1192
- "\n\n" +
1193
- "Respond only using JSON that matches the above schema.",
1194
- instruction,
1195
- }))
1196
- );
1197
- ```
1198
-
1199
- See [generateStructure](https://modelfusion.dev/guide/function/generate-structure) for details on the new API.
1200
-
1201
- ## v0.80.0 - 2023-11-24
1202
-
1203
- ### Changed
1204
-
1205
- - **breaking change**: Restructured multi-modal instruction prompts and `OpenAIChatMessage.user()`
1206
-
1207
- ## v0.79.0 - 2023-11-23
1208
-
1209
- ### Added
1210
-
1211
- - Multi-tool usage from open source models
1212
-
1213
- Use `TextGenerationToolCallsOrGenerateTextModel` and related helper methods `.asToolCallsOrTextGenerationModel()` to create custom prompts & parsers.
1214
-
1215
- Examples:
1216
-
1217
- - `examples/basic/src/model-provider/ollama/ollama-use-tools-or-generate-text-openhermes-example.ts`
1218
- - `examples/basic/src/model-provider/llamacpp/llamacpp-use-tools-or-generate-text-openhermes-example.ts`
1219
-
1220
- Example prompt format:
1221
-
1222
- - `examples/basic/src/tool/prompts/open-hermes.ts` for OpenHermes 2.5
1223
-
1224
- ## v0.78.0 - 2023-11-23
1225
-
1226
- ### Removed
1227
-
1228
- - **breaking change**: Removed `FunctionListToolCallPromptFormat`. See `examples/basic/src/model-provide/ollama/ollama-use-tool-mistral-example.ts` for how to implement a `ToolCallPromptFormat` for your tool.
1229
-
1230
- ## v0.77.0 - 2023-11-23
1231
-
1232
- ### Changed
1233
-
1234
- - **breaking change**: Rename `Speech` to `SpeechGenerator` in facades
1235
- - **breaking change**: Rename `Transcription` to `Transcriber` in facades
1236
-
1237
- ## v0.76.0 - 2023-11-23
1238
-
1239
- ### Added
1240
-
1241
- - Anthropic Claude 2.1 support
1242
-
1243
- ## v0.75.0 - 2023-11-22
1244
-
1245
- Introducing model provider facades:
1246
-
1247
- ```ts
1248
- const image = await generateImage(
1249
- openai.ImageGenerator({ model: "dall-e-3", size: "1024x1024" }),
1250
- "the wicked witch of the west in the style of early 19th century painting"
1251
- );
1252
- ```
1253
-
1254
- ### Added
1255
-
1256
- - Model provider facades. You can e.g. use `ollama.TextGenerator(...)` instead of `new OllamaTextGenerationModel(...)`.
1257
-
1258
- ### Changed
1259
-
1260
- - **breaking change**: Fixed method name `isParallizable` to `isParallelizable` in `EmbeddingModel`.
1261
-
1262
- ### Removed
1263
-
1264
- - **breaking change**: removed `HuggingFaceImageDescriptionModel`. Image description models will be replaced by multi-modal vision models.
1265
-
1266
- ## v0.74.1 - 2023-11-22
1267
-
1268
- ### Improved
1269
-
1270
- - Increase OpenAI chat streaming resilience.
1271
-
1272
- ## v0.74.0 - 2023-11-21
1273
-
1274
- Prompt format and tool calling improvements.
1275
-
1276
- ### Added
1277
-
1278
- - text prompt format. Use simple text prompts, e.g. with `OpenAIChatModel`:
1279
- ```ts
1280
- const textStream = await streamText(
1281
- new OpenAIChatModel({
1282
- model: "gpt-3.5-turbo",
1283
- }).withTextPrompt(),
1284
- "Write a short story about a robot learning to love."
1285
- );
1286
- ```
1287
- - `.withTextPromptFormat` to `LlamaCppTextGenerationModel` for simplified prompt construction:
1288
- ```ts
1289
- const textStream = await streamText(
1290
- new LlamaCppTextGenerationModel({
1291
- // ...
1292
- }).withTextPromptFormat(Llama2PromptFormat.text()),
1293
- "Write a short story about a robot learning to love."
1294
- );
1295
- ```
1296
- - `.asToolCallGenerationModel()` to `OllamaTextGenerationModel` to simplify tool calls.
1297
-
1298
- ### Improved
1299
-
1300
- - better error reporting when using exponent backoff retries
1301
-
1302
- ### Removed
1303
-
1304
- - **breaking change**: removed `input` from `InstructionPrompt` (was Alpaca-specific, `AlpacaPromptFormat` still supports it)
1305
-
1306
- ## v0.73.1 - 2023-11-19
1307
-
1308
- Remove section newlines from Llama 2 prompt format.
1309
-
1310
- ## v0.73.0 - 2023-11-19
1311
-
1312
- Ollama edge case and error handling improvements.
1313
-
1314
- ## v0.72.0 - 2023-11-19
1315
-
1316
- **Breaking change**: the tool calling API has been reworked to support multiple parallel tool calls. This required multiple breaking changes (see below). Check out the updated [tools documentation](https://modelfusion.dev/guide/tools/) for details.
1317
-
1318
- ### Changed
1319
-
1320
- - `Tool` has `parameters` and `returnType` schemas (instead of `inputSchema` and `outputSchema`).
1321
- - `useTool` uses `generateToolCall` under the hood. The return value and error handling has changed.
1322
- - `useToolOrGenerateText` has been renamed to `useToolsOrGenerateText`. It uses `generateToolCallsOrText` under the hood. The return value and error handling has changed. It can invoke several tools in parallel and returns an array of tool results.
1323
- - The `maxRetries` parameter in `guard` has been replaced by a `maxAttempt` parameter.
1324
-
1325
- ### Removed
1326
-
1327
- - `generateStructureOrText` has been removed.
1328
-
1329
- ## v0.71.0 - 2023-11-17
1330
-
1331
- ### Added
1332
-
1333
- - Experimental generateToolCallsOrText function for generating a multiple parallel tool call using the OpenAI chat/tools API.
1334
-
1335
- ## v0.70.0 - 2023-11-16
1336
-
1337
- ### Added
1338
-
1339
- - ChatML prompt format.
1340
-
1341
- ### Changed
1342
-
1343
- - **breaking change**: `ChatPrompt` structure and terminology has changed to align more closely with OpenAI and similar chat prompts. This is also in preparation for integrating images and function calls results into chat prompts.
1344
- - **breaking change**: Prompt formats are namespaced. Use e.g. `Llama2PromptFormat.chat()` instead of `mapChatPromptToLlama2Format()`. See [Prompt Format](https://modelfusion.dev/guide/function/generate-text#prompt-styles) for documentation of the new prompt formats.
1345
-
1346
- ## v0.69.0 - 2023-11-15
1347
-
1348
- ### Added
1349
-
1350
- - Experimental generateToolCall function for generating a single tool call using the OpenAI chat/tools API.
1351
-
1352
- ## v0.68.0 - 2023-11-14
1353
-
1354
- ### Changed
1355
-
1356
- - Refactored JSON parsing to use abstracted schemas. You can use `parseJSON` and `safeParseJSON` to securely parse JSON objects and optionally type-check them using any schema (e.g. a Zod schema).
1357
-
1358
- ## v0.67.0 - 2023-11-12
1359
-
1360
- ### Added
1361
-
1362
- - Ollama 0.1.9 support: `format` (for forcing JSON output) and `raw` settings
1363
- - Improved Ollama settings documentation
1364
-
1365
- ## v0.66.0 - 2023-11-12
1366
-
1367
- ### Added
1368
-
1369
- - Support for fine-tuned OpenAI `gpt-4-0613` models
1370
- - Support for `trimWhitespace` model setting in `streamText` calls
1371
-
1372
- ## v0.65.0 - 2023-11-12
1373
-
1374
- ### Added
1375
-
1376
- - Image support for `OpenAIChatMessage.user`
1377
- - `mapInstructionPromptToBakLLaVA1ForLlamaCppFormat` prompt format
1378
-
1379
- ### Changed
1380
-
1381
- - **breaking change**: `VisionInstructionPrompt` was replaced by an optional `image` field in `InstructionPrompt`.
1382
-
1383
- ## v0.64.0 - 2023-11-11
1384
-
1385
- ### Added
1386
-
1387
- - Support for OpenAI vision model.
1388
- - Example: `examples/basic/src/model-provider/openai/openai-chat-stream-text-vision-example.ts`
1389
-
1390
- ## v0.63.0 - 2023-11-08
1391
-
1392
- ### Added
1393
-
1394
- - Support for OpenAI chat completion `seed` and `responseFormat` options.
1395
-
1396
- ## v0.62.0 - 2023-11-08
1397
-
1398
- ### Added
1399
-
1400
- - OpenAI speech generation support. Shoutout to [@bjsi](https://github.com/bjsi) for the awesome contribution!
1401
-
1402
- ## v0.61.0 - 2023-11-07
1403
-
1404
- ### Added
1405
-
1406
- - OpenAI `gpt-3.5-turbo-1106`, `gpt-4-1106-preview`, `gpt-4-vision-preview` chat models.
1407
- - OpenAI `Dalle-E-3` image model.
1408
-
1409
- ### Changed
1410
-
1411
- - **breaking change**: `OpenAIImageGenerationModel` requires a `model` parameter.
1412
-
1413
- ## v0.60.0 - 2023-11-06
1414
-
1415
- ### Added
1416
-
1417
- - Support image input for multi-modal Llama.cpp models (e.g. Llava, Bakllava).
1418
-
1419
- ### Changed
1420
-
1421
- - **breaking change**: Llama.cpp prompt format has changed to support images. Use `.withTextPrompt()` to get a text prompt format.
1422
-
1423
- ## v0.59.0 - 2023-11-06
1424
-
1425
- ### Added
1426
-
1427
- - ElevenLabs `eleven_turbo_v2` support.
1428
-
1429
- ## v0.58 - 2023-11-05
1430
-
1431
- ### Fixed
1432
-
1433
- - **breaking change**: Uncaught errors were caused by custom Promises. ModelFusion uses only standard Promises. To get full responses from model function, you need to use the `{ returnType: "full" }` option instead of calling `.asFullResponse()` on the result.
1434
-
1435
- ## v0.57.1 - 2023-11-05
1436
-
1437
- ### Improved
1438
-
1439
- - ModelFusion server error logging and reporting.
1440
-
1441
- ### Fixed
1442
-
1443
- - ModelFusion server creates directory for runs automatically when errors are thrown.
1444
-
1445
- ## v0.57.0 - 2023-11-04
1446
-
1447
- ### Added
1448
-
1449
- - Support for [Cohere v3 embeddings](https://txt.cohere.com/introducing-embed-v3/).
1450
-
1451
- ## v0.56.0 - 2023-11-04
1452
-
1453
- ### Added
1454
-
1455
- - [Ollama model provider](https://modelfusion.dev/integration/model-provider/ollama) for text embeddings.
1456
-
1457
- ## v0.55.1 - 2023-11-04
1458
-
1459
- ### Fixed
1460
-
1461
- - Llama.cpp embeddings are invoked sequentially to avoid rejection by the server.
1462
-
1463
- ## v0.55.0 - 2023-11-04
1464
-
1465
- ### Added
1466
-
1467
- - [Ollama model provider](https://modelfusion.dev/integration/model-provider/ollama) for text generation and text streaming.
1468
-
1469
- ## v0.54.0 - 2023-10-29
1470
-
1471
- Adding experimental ModelFusion server, flows, and browser utils.
1472
-
1473
- ### Added
1474
-
1475
- - ModelFusion server (separate export 'modelfusion/server') with a Fastify plugin for running ModelFusion flows on a server.
1476
- - ModelFusion flows.
1477
- - ModelFusion browser utils (separate export 'modelfusion/browser') for dealing with audio data and invoking ModelFusion flows on the server (`invokeFlow`).
1478
-
1479
- ### Changed
1480
-
1481
- - **breaking change**: `readEventSource` and `readEventSourceStream` are part of 'modelfusion/browser'.
1482
-
1483
- ## v0.53.2 - 2023-10-26
1484
-
1485
- ### Added
1486
-
1487
- - Prompt callback option for `streamStructure`
1488
-
1489
- ### Improved
1490
-
1491
- - Inline JSDoc comments for the model functions.
1492
-
1493
- ## v0.53.1 - 2023-10-25
1494
-
1495
- ### Fixed
1496
-
1497
- - Abort signals and errors during streaming are caught and forwarded correctly.
1498
-
1499
- ## v0.53.0 - 2023-10-23
1500
-
1501
- ### Added
1502
-
1503
- - `executeFunction` utility function for tracing execution time, parameters, and result of composite functions and non-ModelFusion functions.
1504
-
1505
- ## v0.52.0 - 2023-10-23
1506
-
1507
- ### Changed
1508
-
1509
- - Streaming results and `AsyncQueue` objects can be used by several consumers. Each consumer will receive all values. This means that you can e.g. forward the same text stream to speech generation and the client.
1510
-
1511
- ## v0.51.0 - 2023-10-23
1512
-
1513
- ElevenLabs improvements.
1514
-
1515
- ### Added
1516
-
1517
- - ElevenLabs model settings `outputFormat` and `optimizeStreamingLatency`.
1518
-
1519
- ### Fixed
1520
-
1521
- - Default ElevenLabs model is `eleven_monolingual_v1`.
1522
-
1523
- ## v0.50.0 - 2023-10-22
1524
-
1525
- ### Added
1526
-
1527
- - `parentCallId` event property
1528
- - Tracing for `useTool`, `useToolOrGenerateText`, `upsertIntoVectorIndex`, and `guard`
1529
-
1530
- ### Changed
1531
-
1532
- - **breaking change**: rename `embedding` event type to `embed`
1533
- - **breaking change**: rename `image-generation` event type to `generate-image`
1534
- - **breaking change**: rename `speech-generation` event type to `generate-speech`
1535
- - **breaking change**: rename `speech-streaming` event type to `stream-speech`
1536
- - **breaking change**: rename `structure-generation` event type to `generate-structure`
1537
- - **breaking change**: rename `structure-or-text-generation` event type to `generate-structure-or-text`
1538
- - **breaking change**: rename `structure-streaming` event type to `stream-structure`
1539
- - **breaking change**: rename `text-generation` event type to `generate-text`
1540
- - **breaking change**: rename `text-streaming` event type to `stream-text`
1541
- - **breaking change**: rename `transcription` event type to `generate-transcription`
1542
-
1543
- ## v0.49.0 - 2023-10-21
1544
-
1545
- ### Added
1546
-
1547
- - Speech synthesis streaming supports string inputs.
1548
- - Observability for speech synthesis streaming.
1549
-
1550
- ### Changed
1551
-
1552
- - **breaking change**: split `synthesizeSpeech` into `generateSpeech` and `streamSpeech` functions
1553
- - **breaking change**: renamed `speech-synthesis` event to `speech-generation`
1554
- - **breaking change**: renamed `transcribe` to `generateTranscription`
1555
- - **breaking change**: renamed `LmntSpeechSynthesisModel` to `LmntSpeechModel`
1556
- - **breaking change**: renamed `ElevenLabesSpeechSynthesisModel` to `ElevenLabsSpeechModel`
1557
- - **breaking change**: renamed `OpenAITextGenerationModel` to `OpenAICompletionModel`
1558
-
1559
- ### Removed
1560
-
1561
- - **breaking change**: `describeImage` model function. Use `generateText` instead (with e.g. `HuggingFaceImageDescriptionModel`).
1562
-
1563
- ## v0.48.0 - 2023-10-20
1564
-
1565
- ### Added
1566
-
1567
- - Duplex streaming for speech synthesis.
1568
- - Elevenlabs duplex streaming support.
1569
-
1570
- ### Changed
1571
-
1572
- - Schema is using data in return type (breaking change for tools).
1573
-
1574
- ## v0.47.0 - 2023-10-14
1575
-
1576
- ### Added
1577
-
1578
- - Prompt formats for image generation. You can use `.withPromptFormat()` or `.withBasicPrompt()` to apply a prompt format to an image generation model.
1579
-
1580
- ### Changed
1581
-
1582
- - **breaking change**: `generateImage` returns a Buffer with the binary image data instead of a base-64 encoded string. You can call `.asBase64Text()` on the response to get a base64 encoded string.
1583
-
1584
- ## v0.46.0 - 2023-10-14
1585
-
1586
- ### Added
1587
-
1588
- - `.withChatPrompt()` and `.withInstructionPrompt()` shorthand methods.
1589
-
1590
- ## v0.45.0 - 2023-10-14
1591
-
1592
- ### Changed
1593
-
1594
- - Updated Zod to 3.22.4. You need to use Zod 3.22.4 or higher in your project.
1595
-
1596
- ## v0.44.0 - 2023-10-13
1597
-
1598
- ### Added
1599
-
1600
- - Store runs in AsyncLocalStorage for convienience (Node.js only).
1601
-
1602
- ## v0.43.0 - 2023-10-12
1603
-
1604
- ### Added
1605
-
1606
- - Guard function.
1607
-
1608
- ## v0.42.0 - 2023-10-11
1609
-
1610
- ### Added
1611
-
1612
- - Anthropic model support (Claude 2, Claude instant).
1613
-
1614
- ## v0.41.0 - 2023-10-05
1615
-
1616
- ### Changed
1617
-
1618
- **breaking change**: generics simplification to enable dynamic model usage. Models can be used more easily as function parameters.
1619
-
1620
- - `output` renamed to `value` in `asFullResponse()`
1621
- - model settings can no longer be configured as a model options parameter. Use `.withSettings()` instead.
1622
-
1623
- ## v0.40.0 - 2023-10-04
1624
-
1625
- ### Changed
1626
-
1627
- **breaking change**: moved Pinecone integration into `@modelfusion/pinecone` module.
1628
-
1629
- ## v0.39.0 - 2023-10-03
1630
-
1631
- ### Added
1632
-
1633
- - `readEventSource` for parsing a server-sent event stream using the JavaScript EventSource.
1634
-
1635
- ### Changed
1636
-
1637
- **breaking change**: generalization to use Schema instead of Zod.
1638
-
1639
- - `MemoryVectorIndex.deserialize` requires a `Schema`, e.g. `new ZodSchema` (from ModelFusion).
1640
- - `readEventSourceStream` requires a `Schema`.
1641
- - `UncheckedJsonSchema[Schema/StructureDefinition]` renamed to `Unchecked[Schema/StructureDefinition]`.
1642
-
1643
- ## v0.38.0 - 2023-10-02
1644
-
1645
- ### Changed
1646
-
1647
- **breaking change**: Generalized embeddings beyond text embedding.
1648
-
1649
- - `embedText` renamed to `embed`.
1650
- - `embedTexts` renamed to `embedMany`
1651
- - Removed filtering from `VectorIndexRetriever` query (still available as a setting).
1652
-
1653
- ## v0.37.0 - 2023-10-02
1654
-
1655
- ### Added
1656
-
1657
- - `VectorIndexRetriever` supports a filter option that is passed to the vector index.
1658
- - `MemoryVectorIndex` supports filter functions that are applied to the objects before calculating the embeddings.
1659
-
1660
- ## v0.36.0 - 2023-10-02
1661
-
1662
- ### Added
1663
-
1664
- - `basic-text` logger logs function ids when available.
1665
- - `retrieve` produces events for logging and observability.
1666
-
1667
- ## v0.35.2 - 2023-09-27
1668
-
1669
- ### Fixed
1670
-
1671
- - Support empty stop sequences when calling OpenAI text and chat models.
1672
-
1673
- ## v0.35.1 - 2023-09-27
1674
-
1675
- ### Fixed
1676
-
1677
- - Fixed bugs in `streamStructure` partial JSON parsing.
1678
-
1679
- ## v0.35.0 - 2023-09-26
1680
-
1681
- ### Added
1682
-
1683
- - `streamStructure` for streaming structured responses, e.g. from OpenAI function calls. Thanks [@bjsi](https://github.com/bjsi) for the input!
1684
-
1685
- ## v0.34.0 - 2023-09-25
1686
-
1687
- ### Added
1688
-
1689
- - First version of event source utilities: `AsyncQueue`, `createEventSourceStream`, `readEventSourceStream`.
1690
-
1691
- ## v0.33.1 - 2023-09-24
1692
-
1693
- ### Fixed
1694
-
1695
- - Remove resolution part from type definitions.
1696
-
1697
- ## v0.33.0 - 2023-09-19
1698
-
1699
- ### Changed
1700
-
1701
- **breaking change**: Generalized vector store upsert/retrieve beyond text chunks:
1702
-
1703
- - `upsertTextChunks` renamed to `upsertIntoVectorStore`. Syntax has changed.
1704
- - `retrieveTextChunks` renamed to `retrieve`
1705
- - `SimilarTextChunksFromVectorIndexRetriever` renamed to `VectorIndexRetriever`
1706
-
1707
- ## v0.32.0 - 2023-09-19
1708
-
1709
- ### Added
1710
-
1711
- - OpenAI gpt-3.5-turbo-instruct model support.
1712
- - Autocomplete for Stability AI models (thanks [@Danielwinkelmann](https://github.com/Danielwinkelmann)!)
1713
-
1714
- ### Changed
1715
-
1716
- - Downgrade Zod version to 3.21.4 because of https://github.com/colinhacks/zod/issues/2697
1717
-
1718
- ## v0.31.0 - 2023-09-13
1719
-
1720
- ### Changed
1721
-
1722
- - **breaking change**: Renamed chat format construction functions to follow the pattern `map[Chat|Instruction]PromptTo[FORMAT]Format()`, e.g. `mapInstructionPromptToAlpacaFormat()`, for easy auto-completion.
1723
-
1724
- ### Removed
1725
-
1726
- - **breaking change**: The prompts for `generateStructure` and `generateStructureOrText` have been simplified. You can remove the `OpenAIChatPrompt.forStructureCurried` (and similar) parts.
1727
-
1728
- ## v0.30.0 - 2023-09-10
1729
-
1730
- ### Added
1731
-
1732
- - You can directly pass JSON schemas into `generateStructure` and `generateStructureOrText` calls without validation using `UncheckedJsonSchemaStructureDefinition`. This is useful when you need more flexility and don't require type inference. See `examples/basic/src/util/schema/generate-structure-unchecked-json-schema-example.ts`.
1733
-
1734
- ### Changed
1735
-
1736
- - **BREAKING CHANGE**: renamed `generateJson` and `generateJsonOrText` to `generateStructure` and `generateStructureOrText`.
1737
- - **BREAKING CHANGE**: introduced `ZodSchema` and `ZodStructureDefinition`. These are required for `generateStructure` and `generateStructureOrText` calls and in tools.
1738
- - **BREAKING CHANGE**: renamed the corresponding methods and objects.
1739
-
1740
- Why this breaking change?
1741
-
1742
- ModelFusion is currently tied to Zod, but there are many other type checking libraries out there, and Zod does not map perfectly to JSON Schema (which is used in OpenAI function calling).
1743
- Enabling you to use JSON Schema directly in ModelFusion is a first step towards decoupling ModelFusion from Zod.
1744
- You can also configure your own schema adapters that e.g. use Ajv or another library.
1745
- Since this change already affected all JSON generation calls and tools, I included other changes that I had planned in the same area (e.g., renaming to generateStructure and making it more consistent).
1746
-
1747
- ## v0.29.0 - 2023-09-09
1748
-
1749
- ### Added
1750
-
1751
- - `describeImage` model function for image captioning and OCR. HuggingFace provider available.
1752
-
1753
- ## v0.28.0 - 2023-09-09
1754
-
1755
- ### Added
1756
-
1757
- - BaseUrlApiConfiguration class for setting up API configurations with custom base URLs and headers.
1758
-
1759
- ## v0.27.0 - 2023-09-07
1760
-
1761
- ### Added
1762
-
1763
- - Support for running OpenAI on Microsoft Azure.
1764
-
1765
- ### Changed
1766
-
1767
- - **Breaking change**: Introduce API configuration. This affects setting the baseUrl, throttling, and retries.
1768
- - Improved Helicone support via `HeliconeOpenAIApiConfiguration`.
1769
-
1770
- ## v0.26.0 - 2023-09-06
1771
-
1772
- ### Added
1773
-
1774
- - LMNT speech synthesis support.
1775
-
1776
- ## v0.25.0 - 2023-09-05
1777
-
1778
- ### Changed
1779
-
1780
- - Separated cost calculation from Run.
1781
-
1782
- ## v0.24.1 - 2023-09-04
1783
-
1784
- ### Added
1785
-
1786
- - Exposed `logitBias` setting for OpenAI chat and text generation models.
1787
-
1788
- ## v0.24.0 - 2023-09-02
1789
-
1790
- ### Added
1791
-
1792
- - Support for fine-tuned OpenAI models (for the `davinci-002`, `babbage-002`, and `gpt-3.5-turbo` base models).
1793
-
1794
- ## v0.23.0 - 2023-08-31
1795
-
1796
- ### Added
1797
-
1798
- - Function logging support.
1799
- - Usage information for events.
1800
- - Filtering of model settings for events.
1801
-
1802
- ## v0.22.0 - 2023-08-28
1803
-
1804
- ### Changed
1805
-
1806
- - **Breaking change**: Restructured the function call events.
1807
-
1808
- ## v0.21.0 - 2023-08-26
1809
-
1810
- ### Changed
1811
-
1812
- - **Breaking change**: Reworked the function observer system. See [Function observers](https://modelfusion.dev/guide/util/observer) for details on how to use the new system.
1813
-
1814
- ## v0.20.0 - 2023-08-24
1815
-
1816
- ### Changed
1817
-
1818
- - **Breaking change**: Use `.asFullResponse()` to get full responses from model functions (replaces the `fullResponse: true` option).
1819
-
1820
- ## v0.19.0 - 2023-08-23
1821
-
1822
- ### Added
1823
-
1824
- - Support for "babbage-002" and "davinci-002" OpenAI base models.
1825
-
1826
- ### Fixed
1827
-
1828
- - Choose correct tokenizer for older OpenAI text models.
1829
-
1830
- ## v0.18.0 - 2023-08-22
1831
-
1832
- ### Added
1833
-
1834
- - Support for ElevenLabs speech synthesis parameters.
1835
-
1836
- ## v0.17.0 - 2023-08-21
1837
-
1838
- ### Added
1839
-
1840
- - `generateSpeech` function to generate speech from text.
1841
- - ElevenLabs support.
1842
-
1843
- ## v0.15.0 - 2023-08-21
1844
-
1845
- ### Changed
1846
-
1847
- - Introduced unified `stopSequences` and `maxCompletionTokens` properties for all text generation models. **Breaking change**: `maxCompletionTokens` and `stopSequences` are part of the base TextGenerationModel. Specific names for these properties in models have been replaced by this, e.g. `maxTokens` in OpenAI models is `maxCompletionTokens`.
1848
-
1849
- ## v0.14.0 - 2023-08-17
1850
-
1851
- ### Changed
1852
-
1853
- - **Breaking change**: Renamed prompt mappings (and related code) to prompt format.
1854
- - Improved type inference for WebSearchTool and executeTool.
1855
-
1856
- ## v0.12.0 - 2023-08-15
1857
-
1858
- ### Added
1859
-
1860
- - JsonTextGenerationModel and InstructionWithSchemaPrompt to support generateJson on text generation models.
1861
-
1862
- ## v0.11.0 - 2023-08-14
1863
-
1864
- ### Changed
1865
-
1866
- - WebSearchTool signature updated.
1867
-
1868
- ## v0.10.0 - 2023-08-13
1869
-
1870
- ### Added
1871
-
1872
- - Convenience functions to create OpenAI chat messages from tool calls and results.
1873
-
1874
- ## v0.9.0 - 2023-08-13
1875
-
1876
- ### Added
1877
-
1878
- - `WebSearchTool` definition to support the SerpAPI tool (separate package: `@modelfusion/serpapi-tools`)
1879
-
1880
- ## v0.8.0 - 2023-08-12
1881
-
1882
- ### Added
1883
-
1884
- - `executeTool` function that directly executes a single tool and records execution metadata.
1885
-
1886
- ### Changed
1887
-
1888
- - Reworked event system and introduced RunFunctionEvent.
1889
-
1890
- ## v0.7.0 - 2023-08-10
1891
-
1892
- ### Changed
1893
-
1894
- - **Breaking change**: Model functions return a simple object by default to make the 95% use case easier. You can use the `fullResponse` option to get a richer response object that includes the original model response and metadata.
1895
-
1896
- ## v0.6.0 - 2023-08-07
1897
-
1898
- ### Added
1899
-
1900
- - `splitTextChunk` function.
1901
-
1902
- ### Changed
1903
-
1904
- - **Breaking change**: Restructured text splitter functions.
1905
-
1906
- ## v0.5.0 - 2023-08-07
1907
-
1908
- ### Added
1909
-
1910
- - `splitTextChunks` function.
1911
- - Chat with PDF demo.
1912
-
1913
- ### Changed
1914
-
1915
- - **Breaking change**: Renamed VectorIndexSimilarTextChunkRetriever to SimilarTextChunksFromVectorIndexRetriever.
1916
- - **Breaking change**: Renamed 'content' property in TextChunk to 'text.
1917
-
1918
- ### Removed
1919
-
1920
- - `VectorIndexTextChunkStore`
1921
-
1922
- ## v0.4.1 - 2023-08-06
1923
-
1924
- ### Fixed
1925
-
1926
- - Type inference bug in `trimChatPrompt`.
1927
-
1928
- ## v0.4.0 - 2023-08-06
1929
-
1930
- ### Added
1931
-
1932
- - HuggingFace text embedding support.
1933
-
1934
- ## v0.3.0 - 2023-08-05
1935
-
1936
- ### Added
1937
-
1938
- - Helicone observability integration.
1939
-
1940
- ## v0.2.0 - 2023-08-04
1941
-
1942
- ### Added
1943
-
1944
- - Instruction prompts can contain optional `input` property.
1945
- - Alpaca instruction prompt mapping.
1946
- - Vicuna chat prompt mapping.
1947
-
1948
- ## v0.1.1 - 2023-08-02
1949
-
1950
- ### Changed
1951
-
1952
- - Docs updated to ModelFusion.
1953
-
1954
- ## v0.1.0 - 2023-08-01
1955
-
1956
- ### Changed
1957
-
1958
- - **Breaking Change**: Renamed to `modelfusion` (from `ai-utils.js`).
1959
-
1960
- ## v0.0.43 - 2023-08-01
1961
-
1962
- ### Changed
1963
-
1964
- - **Breaking Change**: model functions return rich objects that include the result, the model response and metadata. This enables you to access the original model response easily when you need it and also use the metadata outside of runs.
1965
-
1966
- ## v0.0.42 - 2023-07-31
1967
-
1968
- ### Added
1969
-
1970
- - `trimChatPrompt()` function to fit chat prompts into the context window and leave enough space for the completion.
1971
- - `maxCompletionTokens` property on TextGenerationModels.
1972
-
1973
- ### Changed
1974
-
1975
- - Renamed `withMaxTokens` to `withMaxCompletionTokens` on TextGenerationModels.
1976
-
1977
- ### Removed
1978
-
1979
- - `composeRecentMessagesOpenAIChatPrompt` function (use `trimChatPrompt` instead).
1980
-
1981
- ## v0.0.41 - 2023-07-30
1982
-
1983
- ### Added
1984
-
1985
- - ChatPrompt concept (with chat prompt mappings for text, OpenAI chat, and Llama 2 prompts).
1986
-
1987
- ### Changed
1988
-
1989
- - Renamed prompt mappings and changed into functions.
1990
-
1991
- ## v0.0.40 - 2023-07-30
1992
-
1993
- ### Added
1994
-
1995
- - Prompt mapping support for text generation and streaming.
1996
- - Added instruction prompt concept and mapping.
1997
- - Option to specify context window size for Llama.cpp text generation models.
1998
-
1999
- ### Changed
2000
-
2001
- - Renamed 'maxTokens' to 'contextWindowSize' where applicable.
2002
- - Restructured how tokenizers are exposed by text generation models.
2003
-
2004
- ## v0.0.39 - 2023-07-26
2005
-
2006
- ### Added
2007
-
2008
- - llama.cpp embedding support.
2009
-
2010
- ## v0.0.38 - 2023-07-24
2011
-
2012
- ### Changed
2013
-
2014
- - `zod` and `zod-to-json-schema` are peer dependencies and no longer included in the package.
2015
-
2016
- ## v0.0.37 - 2023-07-23
2017
-
2018
- ### Changed
2019
-
2020
- - `generateJsonOrText`, `useToolOrGenerateText`, `useTool` return additional information in the response (e.g. the parameters and additional text).
2021
-
2022
- ## v0.0.36 - 2023-07-23
2023
-
2024
- ### Changed
2025
-
2026
- - Renamed `callTool` to `useTool` and `callToolOrGenerateText` to `useToolOrGenerateText`.
2027
-
2028
- ## v0.0.35 - 2023-07-22
2029
-
2030
- ### Added
2031
-
2032
- - `generateJsonOrText`
2033
- - Tools: `Tool` class, `callTool`, `callToolOrGenerateText`
2034
-
2035
- ### Changed
2036
-
2037
- - Restructured "generateJson" arguments.
2038
-
2039
- ## v0.0.34 - 2023-07-18
2040
-
2041
- ### Removed
2042
-
2043
- - `asFunction` model function variants. Use JavaScript lamba functions instead.
2044
-
2045
- ## v0.0.33 - 2023-07-18
2046
-
2047
- ### Added
2048
-
2049
- - OpenAIChatAutoFunctionPrompt to call the OpenAI functions API with multiple functions in 'auto' mode.
2050
-
2051
- ## v0.0.32 - 2023-07-15
2052
-
2053
- ### Changed
2054
-
2055
- - Changed the prompt format of the generateJson function.
2056
-
2057
- ## v0.0.31 - 2023-07-14
2058
-
2059
- ### Changed
2060
-
2061
- - Reworked interaction with vectors stores. Removed VectorDB, renamed VectorStore to VectorIndex, and introduced upsertTextChunks and retrieveTextChunks functions.
2062
-
2063
- ## v0.0.30 - 2023-07-13
2064
-
2065
- ### Fixed
2066
-
2067
- - Bugs related to performance. not being available.
2068
-
2069
- ## v0.0.29 - 2023-07-13
2070
-
2071
- ### Added
2072
-
2073
- - Llama.cpp tokenization support.
2074
-
2075
- ### Changed
2076
-
2077
- - Split Tokenizer API into BasicTokenizer and FullTokenizer.
2078
- - Introduce countTokens function (replacing Tokenizer.countTokens).
2079
-
2080
- ## v0.0.28 - 2023-07-12
2081
-
2082
- ### Added
2083
-
2084
- - Events for streamText.
2085
-
2086
- ## v0.0.27 - 2023-07-11
2087
-
2088
- ### Added
2089
-
2090
- - TextDeltaEventSource for Client/Server streaming support.
2091
-
2092
- ### Fixed
2093
-
2094
- - End-of-stream bug in Llama.cpp text streaming.
2095
-
2096
- ## v0.0.26 - 2023-07-11
2097
-
2098
- ### Added
2099
-
2100
- - Streaming support for Cohere text generation models.
2101
-
2102
- ## v0.0.25 - 2023-07-10
2103
-
2104
- ### Added
2105
-
2106
- - Streaming support for OpenAI text completion models.
2107
- - OpenAI function streaming support (in low-level API).
2108
-
2109
- ## v0.0.24 - 2023-07-09
2110
-
2111
- ### Added
2112
-
2113
- - Generalized text streaming (async string iterable, useful for command line streaming).
2114
- - Streaming support for Llama.cpp text generation.
2115
-
2116
- ## v0.0.23 - 2023-07-08
2117
-
2118
- ### Added
2119
-
2120
- - Llama.cpp text generation support.
2121
-
2122
- ## v0.0.22 - 2023-07-08
2123
-
2124
- ### Changed
2125
-
2126
- - Convert all main methods (e.g. `model.generateText(...)`) to a functional API (i.e., `generateText(model, ...)`).
2127
-
2128
- ## v0.0.21 - 2023-07-07
2129
-
2130
- ### New
2131
-
2132
- - JSON generation model.
2133
-
2134
- ## v0.0.20 - 2023-07-02
2135
-
2136
- ### New
2137
-
2138
- - Automatic1111 image generation provider.
2139
-
2140
- ## v0.0.19 - 2023-06-30
2141
-
2142
- ### New
2143
-
2144
- - Cost calculation for OpenAI image generation and transcription models.
2145
-
2146
- ## v0.0.18 - 2023-06-28
2147
-
2148
- ### New
2149
-
2150
- - Cost calculation for Open AI text generation, chat and embedding models.
2151
-
2152
- ### Changed
2153
-
2154
- - Renamed RunContext to Run. Introduced DefaultRun.
2155
- - Changed events and observers.
2156
-
2157
- ## v0.0.17 - 2023-06-14
2158
-
2159
- ### New
2160
-
2161
- 1. Updated OpenAI models.
2162
- 1. Low-level support for OpenAI chat functions API (via `OpenAIChatModel.callApi`).
2163
- 1. TranscriptionModel and OpenAITranscriptionModel (using `whisper`)
2164
-
2165
- ### Changed
2166
-
2167
- 1. Single optional parameter for functions/method that contains run, functionId, etc.
2168
-
2169
- ## v0.0.16 - 2023-06-13
2170
-
2171
- ### Fixed
2172
-
2173
- 1. Retry is not attempted when you ran out of OpenAI credits.
2174
- 1. Vercel edge function support (switched to nanoid for unique IDs).
2175
-
2176
- ### Changed
2177
-
2178
- 1. Improved OpenAI chat streaming API.
2179
- 1. Changed `asFunction` variants from namespaced functions into stand-alone functions.
2180
-
2181
- ## v0.0.15 - 2023-06-12
2182
-
2183
- ### Changed
2184
-
2185
- 1. Documentation update.
2186
-
2187
- ## v0.0.14 - 2023-06-11
2188
-
2189
- ### Changed
2190
-
2191
- 1. Major rework of embedding APIs.
2192
-
2193
- ## v0.0.13 - 2023-06-10
2194
-
2195
- ### Changed
2196
-
2197
- 1. Major rework of text and image generation APIs.
2198
-
2199
- ## v0.0.12 - 2023-06-06
2200
-
2201
- ## v0.0.11 - 2023-06-05
2202
-
2203
- ### Changed
2204
-
2205
- 1. Various renames.
2206
-
2207
- ## v0.0.10 - 2023-06-04
2208
-
2209
- ### New
2210
-
2211
- 1. Pinecone VectorDB support
2212
- 1. Cohere tokenization support
2213
-
2214
- ## v0.0.9 - 2023-06-03
2215
-
2216
- ### New
2217
-
2218
- 1. OpenAI DALL-E image generation support
2219
- 1. `generateImage` function
2220
- 1. Throttling and retries on model level
2221
-
2222
- ## v0.0.8 - 2023-06-02
2223
-
2224
- ### New
2225
-
2226
- 1. Stability AI image generation support
2227
- 1. Image generation Next.js example
2228
-
2229
- ### Changed
2230
-
2231
- 1. Updated PDF to tweet example with style transfer
2232
-
2233
- ## v0.0.7 - 2023-06-01
2234
-
2235
- ### New
2236
-
2237
- 1. Hugging Face text generation support
2238
- 1. Memory vector DB
2239
-
2240
- ## v0.0.6 - 2023-05-31
2241
-
2242
- ### New
2243
-
2244
- 1. Cohere embedding API support
2245
-
2246
- ### Changes
2247
-
2248
- 1. Restructured retry logic
2249
- 1. `embed` embeds many texts at once
2250
-
2251
- ## v0.0.5 - 2023-05-30
2252
-
2253
- ### New
2254
-
2255
- 1. Cohere text generation support
2256
- 1. OpenAI chat streams can be returned as delta async iterables
2257
- 1. Documentation of integration APIs and models
2258
-
2259
- ## v0.0.4 - 2023-05-29
2260
-
2261
- ### New
2262
-
2263
- 1. OpenAI embedding support
2264
- 1. Text embedding functions
2265
- 1. Chat streams can be returned as ReadableStream or AsyncIterable
2266
- 1. Basic examples under `examples/basic`
2267
- 1. Initial documentation available at [modelfusion.dev](https://modelfusion.dev)
2268
-
2269
- ## v0.0.3 - 2023-05-28
2270
-
2271
- ### New
2272
-
2273
- 1. Voice recording and transcription Next.js app example.
2274
- 1. OpenAI transcription support (Whisper).
2275
-
2276
- ## v0.0.2 - 2023-05-27
2277
-
2278
- ### New
2279
-
2280
- 1. BabyAGI Example in TypeScript
2281
- 1. TikToken for OpenAI: We've added tiktoken to aid in tokenization and token counting, including those for message and prompt overhead tokens in chat.
2282
- 1. Tokenization-based Recursive Splitter: A new splitter that operates recursively using tokenization.
2283
- 1. Prompt Management Utility: An enhancement to fit recent chat messages into the context window.
2284
-
2285
- ## v0.0.1 - 2023-05-26
2286
-
2287
- ### New
2288
-
2289
- 1. AI Chat Example using Next.js: An example demonstrating AI chat implementation using Next.js.
2290
- 1. PDF to Twitter Thread Example: This shows how a PDF can be converted into a Twitter thread.
2291
- 1. OpenAI Chat Completion Streaming Support: A feature providing real-time response capabilities using OpenAI's chat completion streaming.
2292
- 1. OpenAI Chat and Text Completion Support: This addition enables the software to handle both chat and text completions from OpenAI.
2293
- 1. Retry Management: A feature to enhance resilience by managing retry attempts for tasks.
2294
- 1. Task Progress Reporting and Abort Signals: This allows users to track the progress of tasks and gives the ability to abort tasks when needed.
2295
- 1. Recursive Character Splitter: A feature to split text into characters recursively for more detailed text analysis.
2296
- 1. Recursive Text Mapping: This enables recursive mapping of text, beneficial for tasks like summarization or extraction.
2297
- 1. Split-Map-Filter-Reduce for Text Processing: A process chain developed for sophisticated text handling, allowing operations to split, map, filter, and reduce text data.
2298
-
2299
- ```
2300
-
2301
- ```