modelfusion 0.1.0 → 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.
- package/README.md +56 -52
- package/package.json +2 -2
package/README.md
CHANGED
@@ -2,23 +2,27 @@
|
|
2
2
|
|
3
3
|
> ### Build AI applications, chatbots, and agents with JavaScript and TypeScript.
|
4
4
|
|
5
|
-
[](https://twitter.com/lgrammel)
|
6
5
|
[](https://www.npmjs.com/package/modelfusion)
|
7
6
|
[](https://opensource.org/licenses/MIT)
|
7
|
+
[](https://modelfusion.dev)
|
8
|
+
[](https://discord.gg/GqCwYZATem)
|
9
|
+
[](https://twitter.com/lgrammel)
|
8
10
|
|
9
|
-
[Introduction](#introduction) | [Quick Install](#quick-install) | [Usage](#usage-examples) | [Features](#features) | [Integrations](#integrations) | [Documentation](#documentation) | [Examples](#more-examples) | [
|
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
|
-
ModelFusion is
|
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
|
-
ModelFusion is a library for building AI apps, chatbots, and agents. It provides abstractions for
|
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
|
-
- **
|
20
|
-
- **Flexibility and control**: AI application development can be complex and unique to each project. With ModelFusion, you have complete control over the prompts
|
21
|
-
- **
|
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
|
|
@@ -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://
|
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://
|
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://
|
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://
|
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(
|
@@ -111,7 +115,7 @@ const { text, response, metadata } = await generateText(
|
|
111
115
|
);
|
112
116
|
```
|
113
117
|
|
114
|
-
### [Generate JSON](https://
|
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://
|
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://
|
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://
|
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://
|
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://
|
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://
|
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://
|
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,55 +334,55 @@ const { chunks } = await retrieveTextChunks(
|
|
330
334
|
|
331
335
|
## Features
|
332
336
|
|
333
|
-
- [Model Functions](https://
|
334
|
-
- [Generate and stream text](https://
|
335
|
-
- [Generate JSON](https://
|
336
|
-
- [Generate JSON or text](https://
|
337
|
-
- [Embed Text](https://
|
338
|
-
- [Tokenize Text](https://
|
339
|
-
- [Transcribe Audio](https://
|
340
|
-
- [Generate images](https://
|
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://
|
344
|
-
- [Text Chunks](https://
|
345
|
-
- [Run abstraction](https://
|
346
|
-
- [Abort signals](https://
|
347
|
-
- [Cost calculation](https://
|
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://
|
351
|
-
- [Throttling strategies](https://
|
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
|
-
|
|
359
|
-
|
|
360
|
-
| Hosting
|
361
|
-
| [Generate text](https://
|
362
|
-
| [Stream text](https://
|
363
|
-
| [Generate JSON](https://
|
364
|
-
| [Generate JSON or Text](https://
|
365
|
-
| [Embed text](https://
|
366
|
-
| [Tokenize text](https://
|
367
|
-
| [Generate image](https://
|
368
|
-
| [Transcribe audio](https://
|
369
|
-
| [Cost calculation](https://
|
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://
|
374
|
-
- [Pinecone](https://
|
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://
|
379
|
-
- [Examples & Tutorials](https://
|
380
|
-
- [Integrations](https://
|
381
|
-
- [API Reference](https://
|
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
|
|
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.1.
|
4
|
+
"version": "0.1.1",
|
5
5
|
"author": "Lars Grammel",
|
6
6
|
"license": "MIT",
|
7
7
|
"keywords": [
|
@@ -17,7 +17,7 @@
|
|
17
17
|
"chatbot",
|
18
18
|
"ai"
|
19
19
|
],
|
20
|
-
"homepage": "https://
|
20
|
+
"homepage": "https://modelfusion.dev/",
|
21
21
|
"repository": {
|
22
22
|
"type": "git",
|
23
23
|
"url": "https://github.com/lgrammel/modelfusion"
|