modelfusion 0.0.44 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +68 -64
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,29 +1,33 @@
1
- # ai-utils.js
1
+ # ModelFusion
2
2
 
3
3
  > ### Build AI applications, chatbots, and agents with JavaScript and TypeScript.
4
4
 
5
+ [![NPM Version](https://img.shields.io/npm/v/modelfusion?color=33cd56&logo=npm)](https://www.npmjs.com/package/modelfusion)
6
+ [![MIT License](https://img.shields.io/github/license/lgrammel/modelfusion)](https://opensource.org/licenses/MIT)
7
+ [![Docs](https://img.shields.io/badge/docs-modelfusion.dev-blue)](https://modelfusion.dev)
8
+ [![Discord](https://discordapp.com/api/guilds/1136309340740006029/widget.png?style=shield)](https://discord.gg/GqCwYZATem)
5
9
  [![Created by Lars Grammel](https://img.shields.io/badge/created%20by-@lgrammel-4BBAAB.svg)](https://twitter.com/lgrammel)
6
- [![NPM Version](https://img.shields.io/npm/v/ai-utils.js?color=33cd56&logo=npm)](https://www.npmjs.com/package/ai-utils.js)
7
- [![MIT License](https://img.shields.io/github/license/lgrammel/ai-utils.js)](https://opensource.org/licenses/MIT)
8
10
 
9
- [Introduction](#introduction) | [Quick Install](#quick-install) | [Usage](#usage-examples) | [Features](#features) | [Integrations](#integrations) | [Documentation](#documentation) | [Examples](#more-examples) | [ai-utils.dev](https://ai-utils.dev)
11
+ [Introduction](#introduction) | [Quick Install](#quick-install) | [Usage](#usage-examples) | [Features](#features) | [Integrations](#integrations) | [Documentation](#documentation) | [Examples](#more-examples) | [modelfusion.dev](https://modelfusion.dev)
10
12
 
11
13
  ## Disclaimer
12
14
 
13
- `ai-utils.js` is currently in its initial development phase. **Until version 0.1 there may be frequent breaking changes.**
15
+ ModelFusion is in its initial development phase. Until version 1.0 there may be breaking changes.
14
16
 
15
17
  ## Introduction
16
18
 
17
- `ai-utils.js` is a library for building AI apps, chatbots, and agents. It provides abstractions for working with AI models, vector indices, and tools. It was designed with the following goals in mind:
19
+ ModelFusion is a library for building AI apps, chatbots, and agents. It provides abstractions for AI models, vector indices, and tools.
18
20
 
19
- - **Provide type inference and validation**: `ai-utils.js` uses TypeScript and [Zod](https://github.com/colinhacks/zod) to infer types whereever possible and to validate AI responses.
20
- - **Flexibility and control**: AI application development can be complex and unique to each project. With `ai-utils.js`, you have complete control over the prompts, the model settings, and the control flow of your application. You can also access the full responses from the models and metadata easily to build what you need.
21
- - **Integrate support features**: Essential features like logging, retries, throttling, and error handling are integrated and easily configurable.
21
+ - **Type inference and validation**: ModelFusion uses TypeScript and [Zod](https://github.com/colinhacks/zod) to infer types wherever possible and to validate model responses.
22
+ - **Flexibility and control**: AI application development can be complex and unique to each project. With ModelFusion, you have complete control over the prompts and model settings, and you can access the raw responses from the models quickly to build what you need.
23
+ - **No chains and predefined prompts**: Use the concepts provided by JavaScript (variables, functions, etc.) and explicit prompts to build applications you can easily understand and control. Not black magic.
24
+ - **More than LLMs**: ModelFusion supports other models, e.g., text-to-image and voice-to-text, to help you build rich AI applications that go beyond just text.
25
+ - **Integrated support features**: Essential features like logging, retries, throttling, tracing, and error handling are built-in, helping you focus more on building your application.
22
26
 
23
27
  ## Quick Install
24
28
 
25
29
  ```sh
26
- npm install ai-utils.js
30
+ npm install modelfusion
27
31
  ```
28
32
 
29
33
  You need to install `zod` and a matching version of `zod-to-json-schema` (peer dependencies):
@@ -34,13 +38,13 @@ npm install zod zod-to-json-schema
34
38
 
35
39
  ## Usage Examples
36
40
 
37
- You can provide API keys for the different [integrations](https://ai-utils.dev/integration/model-provider/) using environment variables (e.g., `OPENAI_API_KEY`) or pass them into the model constructors as options.
41
+ You can provide API keys for the different [integrations](https://modelfusion.dev/integration/model-provider/) using environment variables (e.g., `OPENAI_API_KEY`) or pass them into the model constructors as options.
38
42
 
39
- ### [Generate Text](https://ai-utils.dev/guide/function/generate-text)
43
+ ### [Generate Text](https://modelfusion.dev/guide/function/generate-text)
40
44
 
41
45
  Generate text using a language model and a prompt.
42
46
  You can stream the text if it is supported by the model.
43
- You can use [prompt mappings](https://ai-utils.dev/guide/function/generate-text/prompt-mapping) to change the prompt format of a model.
47
+ You can use [prompt mappings](https://modelfusion.dev/guide/function/generate-text/prompt-mapping) to change the prompt format of a model.
44
48
 
45
49
  #### generateText
46
50
 
@@ -69,7 +73,7 @@ for await (const textFragment of textStream) {
69
73
 
70
74
  #### Prompt Mapping
71
75
 
72
- [Prompt mapping](https://ai-utils.dev/guide/function/generate-text/prompt-mapping) lets you use higher level prompt structures (such as instruction or chat prompts) for different models.
76
+ [Prompt mapping](https://modelfusion.dev/guide/function/generate-text/prompt-mapping) lets you use higher level prompt structures (such as instruction or chat prompts) for different models.
73
77
 
74
78
  ```ts
75
79
  const { text } = await generateText(
@@ -100,7 +104,7 @@ const { textStream } = await streamText(
100
104
 
101
105
  #### Metadata and original responses
102
106
 
103
- Most `ai-utils.js` model functions return rich results that include the original response and metadata.
107
+ Most ModelFusion model functions return rich results that include the original response and metadata.
104
108
 
105
109
  ```ts
106
110
  const { text, response, metadata } = await generateText(
@@ -111,7 +115,7 @@ const { text, response, metadata } = await generateText(
111
115
  );
112
116
  ```
113
117
 
114
- ### [Generate JSON](https://ai-utils.dev/guide/function/generate-json)
118
+ ### [Generate JSON](https://modelfusion.dev/guide/function/generate-json)
115
119
 
116
120
  Generate JSON value that matches a schema.
117
121
 
@@ -144,7 +148,7 @@ const { value } = await generateJson(
144
148
  );
145
149
  ```
146
150
 
147
- ### [Generate JSON or Text](https://ai-utils.dev/guide/function/generate-json-or-text)
151
+ ### [Generate JSON or Text](https://modelfusion.dev/guide/function/generate-json-or-text)
148
152
 
149
153
  Generate JSON (or text as a fallback) using a prompt and multiple schemas.
150
154
  It either matches one of the schemas or is text reponse.
@@ -175,7 +179,7 @@ const { schema, value, text } = await generateJsonOrText(
175
179
  );
176
180
  ```
177
181
 
178
- ### [Tools](https://ai-utils.dev/guide/tools)
182
+ ### [Tools](https://modelfusion.dev/guide/tools)
179
183
 
180
184
  Tools are functions that can be executed by an AI model. They are useful for building chatbots and agents.
181
185
 
@@ -240,7 +244,7 @@ const { tool, parameters, result, text } = await useToolOrGenerateText(
240
244
  );
241
245
  ```
242
246
 
243
- ### [Transcribe Audio](https://ai-utils.dev/guide/function/transcribe-audio)
247
+ ### [Transcribe Audio](https://modelfusion.dev/guide/function/transcribe-audio)
244
248
 
245
249
  Turn audio (voice) into text.
246
250
 
@@ -254,7 +258,7 @@ const { transcription } = await transcribe(
254
258
  );
255
259
  ```
256
260
 
257
- ### [Generate Image](https://ai-utils.dev/guide/function/generate-image)
261
+ ### [Generate Image](https://modelfusion.dev/guide/function/generate-image)
258
262
 
259
263
  Generate a base64-encoded image from a prompt.
260
264
 
@@ -265,7 +269,7 @@ const { image } = await generateImage(
265
269
  );
266
270
  ```
267
271
 
268
- ### [Embed Text](https://ai-utils.dev/guide/function/embed-text)
272
+ ### [Embed Text](https://modelfusion.dev/guide/function/embed-text)
269
273
 
270
274
  Create embeddings for text. Embeddings are vectors that represent the meaning of the text.
271
275
 
@@ -279,7 +283,7 @@ const { embeddings } = await embedTexts(
279
283
  );
280
284
  ```
281
285
 
282
- ### [Tokenize Text](https://ai-utils.dev/guide/function/tokenize-text)
286
+ ### [Tokenize Text](https://modelfusion.dev/guide/function/tokenize-text)
283
287
 
284
288
  Split text into tokens and reconstruct the text from tokens.
285
289
 
@@ -295,7 +299,7 @@ const tokensAndTokenTexts = await tokenizer.tokenizeWithTexts(text);
295
299
  const reconstructedText = await tokenizer.detokenize(tokens);
296
300
  ```
297
301
 
298
- ### [Upserting and Retrieving Text Chunks from Vector Indices](https://ai-utils.dev/guide/text-chunks)
302
+ ### [Upserting and Retrieving Text Chunks from Vector Indices](https://modelfusion.dev/guide/text-chunks)
299
303
 
300
304
  ```ts
301
305
  const texts = [
@@ -330,99 +334,99 @@ const { chunks } = await retrieveTextChunks(
330
334
 
331
335
  ## Features
332
336
 
333
- - [Model Functions](https://ai-utils.dev/guide/function/)
334
- - [Generate and stream text](https://ai-utils.dev/guide/function/generate-text)
335
- - [Generate JSON](https://ai-utils.dev/guide/function/generate-json)
336
- - [Generate JSON or text](https://ai-utils.dev/guide/function/generate-json-or-text)
337
- - [Embed Text](https://ai-utils.dev/guide/function/embed-text)
338
- - [Tokenize Text](https://ai-utils.dev/guide/function/tokenize-text)
339
- - [Transcribe Audio](https://ai-utils.dev/guide/function/transcribe-audio)
340
- - [Generate images](https://ai-utils.dev/guide/function/generate-image)
337
+ - [Model Functions](https://modelfusion.dev/guide/function/)
338
+ - [Generate and stream text](https://modelfusion.dev/guide/function/generate-text)
339
+ - [Generate JSON](https://modelfusion.dev/guide/function/generate-json)
340
+ - [Generate JSON or text](https://modelfusion.dev/guide/function/generate-json-or-text)
341
+ - [Embed Text](https://modelfusion.dev/guide/function/embed-text)
342
+ - [Tokenize Text](https://modelfusion.dev/guide/function/tokenize-text)
343
+ - [Transcribe Audio](https://modelfusion.dev/guide/function/transcribe-audio)
344
+ - [Generate images](https://modelfusion.dev/guide/function/generate-image)
341
345
  - Summarize text
342
346
  - Split text
343
- - [Tools](https://ai-utils.dev/guide/tools)
344
- - [Text Chunks](https://ai-utils.dev/guide/text-chunks)
345
- - [Run abstraction](https://ai-utils.dev/guide/run/)
346
- - [Abort signals](https://ai-utils.dev/guide/run/abort)
347
- - [Cost calculation](https://ai-utils.dev/guide/run/cost-calculation)
347
+ - [Tools](https://modelfusion.dev/guide/tools)
348
+ - [Text Chunks](https://modelfusion.dev/guide/text-chunks)
349
+ - [Run abstraction](https://modelfusion.dev/guide/run/)
350
+ - [Abort signals](https://modelfusion.dev/guide/run/abort)
351
+ - [Cost calculation](https://modelfusion.dev/guide/run/cost-calculation)
348
352
  - Call recording
349
353
  - Utilities
350
- - [Retry strategies](https://ai-utils.dev/guide/util/retry)
351
- - [Throttling strategies](https://ai-utils.dev/guide/util/throttle)
354
+ - [Retry strategies](https://modelfusion.dev/guide/util/retry)
355
+ - [Throttling strategies](https://modelfusion.dev/guide/util/throttle)
352
356
  - Error handling
353
357
 
354
358
  ## Integrations
355
359
 
356
360
  ### Model Providers
357
361
 
358
- | | [OpenAI](https://ai-utils.dev/integration/model-provider/openai) | [Cohere](https://ai-utils.dev/integration/model-provider/cohere) | [Llama.cpp](https://ai-utils.dev/integration/model-provider/llamacpp) | [Hugging Face](https://ai-utils.dev/integration/model-provider/huggingface) | [Stability AI](https://ai-utils.dev/integration/model-provider/stability) | [Automatic1111](https://ai-utils.dev/integration/model-provider/automatic1111) |
359
- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
360
- | Hosting | cloud | cloud | server (local) | cloud | cloud | server (local) |
361
- | [Generate text](https://ai-utils.dev/guide/function/generate-text) | ✅ | ✅ | ✅ | ✅ | | |
362
- | [Stream text](https://ai-utils.dev/guide/function/generate-text) | ✅ | ✅ | ✅ | | | |
363
- | [Generate JSON](https://ai-utils.dev/guide/function/generate-json) | chat models | | | | | |
364
- | [Generate JSON or Text](https://ai-utils.dev/guide/function/generate-json-or-text) | chat models | | | | | |
365
- | [Embed text](https://ai-utils.dev/guide/function/embed-text) | ✅ | ✅ | ✅ | | | |
366
- | [Tokenize text](https://ai-utils.dev/guide/function/tokenize-text) | full | full | basic | | | |
367
- | [Generate image](https://ai-utils.dev/guide/function/generate-image) | ✅ | | | | ✅ | ✅ |
368
- | [Transcribe audio](https://ai-utils.dev/guide/function/transcribe-audio) | ✅ | | | | | |
369
- | [Cost calculation](https://ai-utils.dev/guide/run/cost-calculation) | ✅ | | | | | |
362
+ | | [OpenAI](https://modelfusion.dev/integration/model-provider/openai) | [Cohere](https://modelfusion.dev/integration/model-provider/cohere) | [Llama.cpp](https://modelfusion.dev/integration/model-provider/llamacpp) | [Hugging Face](https://modelfusion.dev/integration/model-provider/huggingface) | [Stability AI](https://modelfusion.dev/integration/model-provider/stability) | [Automatic1111](https://modelfusion.dev/integration/model-provider/automatic1111) |
363
+ | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ---------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
364
+ | Hosting | cloud | cloud | server (local) | cloud | cloud | server (local) |
365
+ | [Generate text](https://modelfusion.dev/guide/function/generate-text) | ✅ | ✅ | ✅ | ✅ | | |
366
+ | [Stream text](https://modelfusion.dev/guide/function/generate-text) | ✅ | ✅ | ✅ | | | |
367
+ | [Generate JSON](https://modelfusion.dev/guide/function/generate-json) | chat models | | | | | |
368
+ | [Generate JSON or Text](https://modelfusion.dev/guide/function/generate-json-or-text) | chat models | | | | | |
369
+ | [Embed text](https://modelfusion.dev/guide/function/embed-text) | ✅ | ✅ | ✅ | | | |
370
+ | [Tokenize text](https://modelfusion.dev/guide/function/tokenize-text) | full | full | basic | | | |
371
+ | [Generate image](https://modelfusion.dev/guide/function/generate-image) | ✅ | | | | | ✅ |
372
+ | [Transcribe audio](https://modelfusion.dev/guide/function/transcribe-audio) | ✅ | | | | | |
373
+ | [Cost calculation](https://modelfusion.dev/guide/run/cost-calculation) | ✅ | | | | | |
370
374
 
371
375
  ### Vector Indices
372
376
 
373
- - [Memory](https://ai-utils.dev/integration/vector-index/memory)
374
- - [Pinecone](https://ai-utils.dev/integration/vector-index/pinecone)
377
+ - [Memory](https://modelfusion.dev/integration/vector-index/memory)
378
+ - [Pinecone](https://modelfusion.dev/integration/vector-index/pinecone)
375
379
 
376
380
  ## Documentation
377
381
 
378
- - [Guide](https://ai-utils.dev/guide)
379
- - [Examples & Tutorials](https://ai-utils.dev/tutorial)
380
- - [Integrations](https://ai-utils.dev/integration/model-provider)
381
- - [API Reference](https://ai-utils.dev/api/modules)
382
+ - [Guide](https://modelfusion.dev/guide)
383
+ - [Examples & Tutorials](https://modelfusion.dev/tutorial)
384
+ - [Integrations](https://modelfusion.dev/integration/model-provider)
385
+ - [API Reference](https://modelfusion.dev/api/modules)
382
386
 
383
387
  ## More Examples
384
388
 
385
- ### [Basic Examples](https://github.com/lgrammel/ai-utils.js/tree/main/examples/basic)
389
+ ### [Basic Examples](https://github.com/lgrammel/modelfusion/tree/main/examples/basic)
386
390
 
387
391
  Examples for the individual functions and objects.
388
392
 
389
- ### [PDF to Tweet](https://github.com/lgrammel/ai-utils.js/tree/main/examples/pdf-to-tweet)
393
+ ### [PDF to Tweet](https://github.com/lgrammel/modelfusion/tree/main/examples/pdf-to-tweet)
390
394
 
391
395
  > _terminal app_, _PDF parsing_, _recursive information extraction_, _in memory vector index, \_style example retrieval_, _OpenAI GPT-4_, _cost calculation_
392
396
 
393
397
  Extracts information about a topic from a PDF and writes a tweet in your own style about it.
394
398
 
395
- ### [AI Chat (Next.JS)](https://github.com/lgrammel/ai-utils.js/tree/main/examples/ai-chat-next-js)
399
+ ### [AI Chat (Next.JS)](https://github.com/lgrammel/modelfusion/tree/main/examples/ai-chat-next-js)
396
400
 
397
401
  > _Next.js app_, _OpenAI GPT-3.5-turbo_, _streaming_, _abort handling_
398
402
 
399
403
  A basic web chat with an AI assistant, implemented as a Next.js app.
400
404
 
401
- ### [Image generator (Next.js)](https://github.com/lgrammel/ai-utils.js/tree/main/examples/image-generator-next-js)
405
+ ### [Image generator (Next.js)](https://github.com/lgrammel/modelfusion/tree/main/examples/image-generator-next-js)
402
406
 
403
407
  > _Next.js app_, _Stability AI image generation_
404
408
 
405
409
  Create an 19th century painting image for your input.
406
410
 
407
- ### [Voice recording and transcription (Next.js)](https://github.com/lgrammel/ai-utils.js/tree/main/examples/voice-recording-next-js)
411
+ ### [Voice recording and transcription (Next.js)](https://github.com/lgrammel/modelfusion/tree/main/examples/voice-recording-next-js)
408
412
 
409
413
  > _Next.js app_, _OpenAI Whisper_
410
414
 
411
415
  Record audio with push-to-talk and transcribe it using Whisper, implemented as a Next.js app. The app shows a list of the transcriptions.
412
416
 
413
- ### [BabyAGI Classic](https://github.com/lgrammel/ai-utils.js/tree/main/examples/baby-agi)
417
+ ### [BabyAGI Classic](https://github.com/lgrammel/modelfusion/tree/main/examples/baby-agi)
414
418
 
415
419
  > _terminal app_, _agent_, _BabyAGI_, _OpenAI text-davinci-003_
416
420
 
417
421
  TypeScript implementation of the classic [BabyAGI](https://github.com/yoheinakajima/babyagi/blob/main/classic/babyagi.py) by [@yoheinakajima](https://twitter.com/yoheinakajima) without embeddings.
418
422
 
419
- ### [Middle school math](https://github.com/lgrammel/ai-utils.js/tree/main/examples/middle-school-math)
423
+ ### [Middle school math](https://github.com/lgrammel/modelfusion/tree/main/examples/middle-school-math)
420
424
 
421
425
  > _terminal app_, _agent_, _tools_, _GPT-4_
422
426
 
423
427
  Small agent that solves middle school math problems. It uses a calculator tool to solve the problems.
424
428
 
425
- ### [Terminal Chat (llama.cpp)](https://github.com/lgrammel/ai-utils.js/tree/main/examples/terminal-chat-llamacpp)
429
+ ### [Terminal Chat (llama.cpp)](https://github.com/lgrammel/modelfusion/tree/main/examples/terminal-chat-llamacpp)
426
430
 
427
431
  > _Terminal app_, _chat_, _llama.cpp_
428
432
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modelfusion",
3
3
  "description": "Build AI applications, chatbots, and agents with JavaScript and TypeScript.",
4
- "version": "0.0.44",
4
+ "version": "0.1.1",
5
5
  "author": "Lars Grammel",
6
6
  "license": "MIT",
7
7
  "keywords": [
@@ -17,13 +17,13 @@
17
17
  "chatbot",
18
18
  "ai"
19
19
  ],
20
- "homepage": "https://ai-utils.dev/",
20
+ "homepage": "https://modelfusion.dev/",
21
21
  "repository": {
22
22
  "type": "git",
23
- "url": "https://github.com/lgrammel/ai-utils.js"
23
+ "url": "https://github.com/lgrammel/modelfusion"
24
24
  },
25
25
  "bugs": {
26
- "url": "https://github.com/lgrammel/ai-utils.js/issues"
26
+ "url": "https://github.com/lgrammel/modelfusion/issues"
27
27
  },
28
28
  "type": "module",
29
29
  "sideEffects": false,