modelfusion 0.74.0 → 0.75.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -32
- package/guard/fixStructure.cjs +1 -1
- package/guard/fixStructure.d.ts +1 -1
- package/guard/fixStructure.js +1 -1
- package/model-function/embed/EmbeddingModel.d.ts +1 -1
- package/model-function/embed/embed.cjs +1 -1
- package/model-function/embed/embed.d.ts +2 -2
- package/model-function/embed/embed.js +1 -1
- package/model-function/generate-image/generateImage.d.ts +1 -1
- package/model-function/generate-speech/generateSpeech.d.ts +1 -1
- package/model-function/generate-speech/streamSpeech.d.ts +1 -1
- package/model-function/generate-structure/generateStructure.d.ts +1 -1
- package/model-function/generate-structure/streamStructure.d.ts +1 -1
- package/model-function/generate-text/generateText.d.ts +1 -1
- package/model-function/generate-text/streamText.d.ts +1 -1
- package/model-function/generate-transcription/generateTranscription.d.ts +1 -1
- package/model-provider/anthropic/AnthropicFacade.cjs +15 -0
- package/model-provider/anthropic/AnthropicFacade.d.ts +9 -0
- package/model-provider/anthropic/AnthropicFacade.js +11 -0
- package/model-provider/anthropic/index.cjs +2 -1
- package/model-provider/anthropic/index.d.ts +1 -0
- package/model-provider/anthropic/index.js +1 -0
- package/model-provider/automatic1111/Automatic1111Facade.cjs +15 -0
- package/model-provider/automatic1111/Automatic1111Facade.d.ts +9 -0
- package/model-provider/automatic1111/Automatic1111Facade.js +11 -0
- package/model-provider/automatic1111/index.cjs +14 -1
- package/model-provider/automatic1111/index.d.ts +1 -0
- package/model-provider/automatic1111/index.js +1 -0
- package/model-provider/cohere/CohereFacade.cjs +71 -0
- package/model-provider/cohere/CohereFacade.d.ts +59 -0
- package/model-provider/cohere/CohereFacade.js +65 -0
- package/model-provider/cohere/CohereTextEmbeddingModel.cjs +1 -1
- package/model-provider/cohere/CohereTextEmbeddingModel.d.ts +1 -1
- package/model-provider/cohere/CohereTextEmbeddingModel.js +1 -1
- package/model-provider/cohere/index.cjs +14 -1
- package/model-provider/cohere/index.d.ts +1 -0
- package/model-provider/cohere/index.js +1 -0
- package/model-provider/elevenlabs/ElevenLabsFacade.cjs +18 -0
- package/model-provider/elevenlabs/ElevenLabsFacade.d.ts +12 -0
- package/model-provider/elevenlabs/ElevenLabsFacade.js +14 -0
- package/model-provider/elevenlabs/index.cjs +14 -0
- package/model-provider/elevenlabs/index.d.ts +1 -0
- package/model-provider/elevenlabs/index.js +1 -0
- package/model-provider/huggingface/HuggingFaceFacade.cjs +55 -0
- package/model-provider/huggingface/HuggingFaceFacade.d.ts +46 -0
- package/model-provider/huggingface/HuggingFaceFacade.js +50 -0
- package/model-provider/huggingface/HuggingFaceTextEmbeddingModel.cjs +1 -1
- package/model-provider/huggingface/HuggingFaceTextEmbeddingModel.d.ts +1 -1
- package/model-provider/huggingface/HuggingFaceTextEmbeddingModel.js +1 -1
- package/model-provider/huggingface/index.cjs +14 -2
- package/model-provider/huggingface/index.d.ts +1 -1
- package/model-provider/huggingface/index.js +1 -1
- package/model-provider/llamacpp/LlamaCppFacade.cjs +19 -0
- package/model-provider/llamacpp/LlamaCppFacade.d.ts +7 -0
- package/model-provider/llamacpp/LlamaCppFacade.js +13 -0
- package/model-provider/llamacpp/LlamaCppTextEmbeddingModel.cjs +2 -2
- package/model-provider/llamacpp/LlamaCppTextEmbeddingModel.d.ts +2 -2
- package/model-provider/llamacpp/LlamaCppTextEmbeddingModel.js +2 -2
- package/model-provider/llamacpp/index.cjs +2 -1
- package/model-provider/llamacpp/index.d.ts +1 -0
- package/model-provider/llamacpp/index.js +1 -0
- package/model-provider/lmnt/LmntFacade.cjs +15 -0
- package/model-provider/lmnt/LmntFacade.d.ts +9 -0
- package/model-provider/lmnt/LmntFacade.js +11 -0
- package/model-provider/lmnt/index.cjs +14 -0
- package/model-provider/lmnt/index.d.ts +1 -0
- package/model-provider/lmnt/index.js +1 -0
- package/model-provider/ollama/OllamaFacade.cjs +13 -0
- package/model-provider/ollama/OllamaFacade.d.ts +4 -0
- package/model-provider/ollama/OllamaFacade.js +8 -0
- package/model-provider/ollama/OllamaTextEmbeddingModel.cjs +2 -2
- package/model-provider/ollama/OllamaTextEmbeddingModel.d.ts +2 -2
- package/model-provider/ollama/OllamaTextEmbeddingModel.js +2 -2
- package/model-provider/ollama/index.cjs +14 -1
- package/model-provider/ollama/index.d.ts +1 -0
- package/model-provider/ollama/index.js +1 -0
- package/model-provider/openai/OpenAIFacade.cjs +148 -0
- package/model-provider/openai/OpenAIFacade.d.ts +124 -0
- package/model-provider/openai/OpenAIFacade.js +138 -0
- package/model-provider/openai/OpenAITextEmbeddingModel.cjs +1 -1
- package/model-provider/openai/OpenAITextEmbeddingModel.d.ts +1 -1
- package/model-provider/openai/OpenAITextEmbeddingModel.js +1 -1
- package/model-provider/openai/TikTokenTokenizer.cjs +2 -2
- package/model-provider/openai/TikTokenTokenizer.d.ts +4 -3
- package/model-provider/openai/TikTokenTokenizer.js +2 -2
- package/model-provider/openai/chat/OpenAIChatStreamIterable.cjs +22 -7
- package/model-provider/openai/chat/OpenAIChatStreamIterable.js +22 -7
- package/model-provider/openai/index.cjs +2 -1
- package/model-provider/openai/index.d.ts +1 -0
- package/model-provider/openai/index.js +1 -0
- package/model-provider/stability/StabilityFacade.cjs +32 -0
- package/model-provider/stability/StabilityFacade.d.ts +26 -0
- package/model-provider/stability/StabilityFacade.js +28 -0
- package/model-provider/stability/index.cjs +14 -1
- package/model-provider/stability/index.d.ts +1 -0
- package/model-provider/stability/index.js +1 -0
- package/package.json +1 -1
- package/model-provider/huggingface/HuggingFaceImageDescriptionModel.cjs +0 -94
- package/model-provider/huggingface/HuggingFaceImageDescriptionModel.d.ts +0 -44
- package/model-provider/huggingface/HuggingFaceImageDescriptionModel.js +0 -90
package/README.md
CHANGED
@@ -51,7 +51,7 @@ You can use [prompt formats](https://modelfusion.dev/guide/function/generate-tex
|
|
51
51
|
|
52
52
|
```ts
|
53
53
|
const text = await generateText(
|
54
|
-
|
54
|
+
openai.CompletionTextGenerator({ model: "gpt-3.5-turbo-instruct" }),
|
55
55
|
"Write a short story about a robot learning to love:\n\n"
|
56
56
|
);
|
57
57
|
```
|
@@ -62,7 +62,7 @@ Providers: [OpenAI](https://modelfusion.dev/integration/model-provider/openai),
|
|
62
62
|
|
63
63
|
```ts
|
64
64
|
const textStream = await streamText(
|
65
|
-
|
65
|
+
openai.CompletionTextGenerator({ model: "gpt-3.5-turbo-instruct" }),
|
66
66
|
"Write a short story about a robot learning to love:\n\n"
|
67
67
|
);
|
68
68
|
|
@@ -79,7 +79,7 @@ Multi-modal vision models such as GPT 4 Vision can process images as part of the
|
|
79
79
|
|
80
80
|
```ts
|
81
81
|
const textStream = await streamText(
|
82
|
-
|
82
|
+
openai.ChatTextGenerator({ model: "gpt-4-vision-preview" }),
|
83
83
|
[
|
84
84
|
OpenAIChatMessage.user("Describe the image in detail:", {
|
85
85
|
image: { base64Content: image, mimeType: "image/png" },
|
@@ -96,7 +96,7 @@ Generate an image from a prompt.
|
|
96
96
|
|
97
97
|
```ts
|
98
98
|
const image = await generateImage(
|
99
|
-
|
99
|
+
openai.ImageGenerator({ model: "dall-e-3", size: "1024x1024" }),
|
100
100
|
"the wicked witch of the west in the style of early 19th century painting"
|
101
101
|
);
|
102
102
|
```
|
@@ -114,7 +114,7 @@ Synthesize speech (audio) from text. Also called TTS (text-to-speech).
|
|
114
114
|
```ts
|
115
115
|
// `speech` is a Buffer with MP3 audio data
|
116
116
|
const speech = await generateSpeech(
|
117
|
-
|
117
|
+
lmnt.Speech({
|
118
118
|
voice: "034b632b-df71-46c8-b440-86a42ffc3cf3", // Henry
|
119
119
|
}),
|
120
120
|
"Good evening, ladies and gentlemen! Exciting news on the airwaves tonight " +
|
@@ -134,7 +134,7 @@ Providers: [Eleven Labs](https://modelfusion.dev/integration/model-provider/elev
|
|
134
134
|
const textStream = await streamText(/* ... */);
|
135
135
|
|
136
136
|
const speechStream = await streamSpeech(
|
137
|
-
|
137
|
+
elevenlabs.Speech({
|
138
138
|
model: "eleven_turbo_v2",
|
139
139
|
voice: "pNInz6obpgDQGcFmaJgB", // Adam
|
140
140
|
optimizeStreamingLatency: 1,
|
@@ -159,7 +159,7 @@ Transcribe speech (audio) data into text. Also called speech-to-text (STT).
|
|
159
159
|
|
160
160
|
```ts
|
161
161
|
const transcription = await generateTranscription(
|
162
|
-
|
162
|
+
openai.Transcription({ model: "whisper-1" }),
|
163
163
|
{
|
164
164
|
type: "mp3",
|
165
165
|
data: await fs.promises.readFile("data/test.mp3"),
|
@@ -179,7 +179,7 @@ Generate a structure that matches a schema.
|
|
179
179
|
|
180
180
|
```ts
|
181
181
|
const sentiment = await generateStructure(
|
182
|
-
|
182
|
+
openai.ChatTextGenerator({
|
183
183
|
model: "gpt-3.5-turbo",
|
184
184
|
temperature: 0,
|
185
185
|
maxCompletionTokens: 50,
|
@@ -214,7 +214,7 @@ Stream a structure that matches a schema. Partial structures before the final pa
|
|
214
214
|
|
215
215
|
```ts
|
216
216
|
const structureStream = await streamStructure(
|
217
|
-
|
217
|
+
openai.ChatTextGenerator({
|
218
218
|
model: "gpt-3.5-turbo",
|
219
219
|
temperature: 0,
|
220
220
|
maxCompletionTokens: 2000,
|
@@ -261,13 +261,13 @@ Create embeddings for text and other values. Embeddings are vectors that represe
|
|
261
261
|
```ts
|
262
262
|
// embed single value:
|
263
263
|
const embedding = await embed(
|
264
|
-
|
264
|
+
openai.TextEmbedder({ model: "text-embedding-ada-002" }),
|
265
265
|
"At first, Nox didn't know what to do with the pup."
|
266
266
|
);
|
267
267
|
|
268
268
|
// embed many values:
|
269
269
|
const embeddings = await embedMany(
|
270
|
-
|
270
|
+
openai.TextEmbedder({ model: "text-embedding-ada-002" }),
|
271
271
|
[
|
272
272
|
"At first, Nox didn't know what to do with the pup.",
|
273
273
|
"He keenly observed and absorbed everything around him, from the birds in the sky to the trees in the forest.",
|
@@ -282,7 +282,7 @@ Providers: [OpenAI](https://modelfusion.dev/integration/model-provider/openai),
|
|
282
282
|
Split text into tokens and reconstruct the text from tokens.
|
283
283
|
|
284
284
|
```ts
|
285
|
-
const tokenizer =
|
285
|
+
const tokenizer = openai.Tokenizer({ model: "gpt-4" });
|
286
286
|
|
287
287
|
const text = "At first, Nox didn't know what to do with the pup.";
|
288
288
|
|
@@ -305,7 +305,7 @@ Guard functions can be used to implement retry on error, redacting and changing
|
|
305
305
|
const result = await guard(
|
306
306
|
(input, options) =>
|
307
307
|
generateStructure(
|
308
|
-
|
308
|
+
openai.ChatTextGenerator({
|
309
309
|
// ...
|
310
310
|
}),
|
311
311
|
new ZodStructureDefinition({
|
@@ -379,7 +379,7 @@ With `generateToolCall`, you can generate a tool call for a specific tool with a
|
|
379
379
|
|
380
380
|
```ts
|
381
381
|
const { id, name, args } = await generateToolCall(
|
382
|
-
|
382
|
+
openai.ChatTextGenerator({ model: "gpt-3.5-turbo" }),
|
383
383
|
calculator,
|
384
384
|
[OpenAIChatMessage.user("What's fourteen times twelve?")]
|
385
385
|
);
|
@@ -391,7 +391,7 @@ With `generateToolCallsOrText`, you can ask a language model to generate several
|
|
391
391
|
|
392
392
|
```ts
|
393
393
|
const { text, toolCalls } = await generateToolCallsOrText(
|
394
|
-
|
394
|
+
openai.ChatTextGenerator({ model: "gpt-3.5-turbo" }),
|
395
395
|
[toolA, toolB, toolC],
|
396
396
|
[OpenAIChatMessage.user(query)]
|
397
397
|
);
|
@@ -415,7 +415,7 @@ With `useTool`, you can use a tool with a language model that supports tools cal
|
|
415
415
|
|
416
416
|
```ts
|
417
417
|
const { tool, toolCall, args, ok, result } = await useTool(
|
418
|
-
|
418
|
+
openai.ChatTextGenerator({ model: "gpt-3.5-turbo" }),
|
419
419
|
calculator,
|
420
420
|
[OpenAIChatMessage.user("What's fourteen times twelve?")]
|
421
421
|
);
|
@@ -433,7 +433,7 @@ With `useToolsOrGenerateText`, you can ask a language model to generate several
|
|
433
433
|
|
434
434
|
```ts
|
435
435
|
const { text, toolResults } = await useToolsOrGenerateText(
|
436
|
-
|
436
|
+
openai.ChatTextGenerator({ model: "gpt-3.5-turbo" }),
|
437
437
|
[calculator /* ... */],
|
438
438
|
[OpenAIChatMessage.user("What's fourteen times twelve?")]
|
439
439
|
);
|
@@ -453,7 +453,7 @@ const texts = [
|
|
453
453
|
];
|
454
454
|
|
455
455
|
const vectorIndex = new MemoryVectorIndex<string>();
|
456
|
-
const embeddingModel =
|
456
|
+
const embeddingModel = openai.TextEmbedder({
|
457
457
|
model: "text-embedding-ada-002",
|
458
458
|
});
|
459
459
|
|
@@ -487,9 +487,11 @@ Prompt formats let you use higher level prompt structures (such as text, instruc
|
|
487
487
|
|
488
488
|
```ts
|
489
489
|
const text = await generateText(
|
490
|
-
|
491
|
-
|
492
|
-
|
490
|
+
anthropic
|
491
|
+
.TextGenerator({
|
492
|
+
model: "claude-instant-1",
|
493
|
+
})
|
494
|
+
.withTextPrompt(),
|
493
495
|
"Write a short story about a robot learning to love"
|
494
496
|
);
|
495
497
|
```
|
@@ -499,10 +501,12 @@ const text = await generateText(
|
|
499
501
|
```ts
|
500
502
|
// example assumes you are running https://huggingface.co/TheBloke/Llama-2-7B-GGUF with llama.cpp
|
501
503
|
const text = await generateText(
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
504
|
+
llamacpp
|
505
|
+
.TextGenerator({
|
506
|
+
contextWindowSize: 4096, // Llama 2 context window size
|
507
|
+
maxCompletionTokens: 1000,
|
508
|
+
})
|
509
|
+
.withTextPromptFormat(Llama2PromptFormat.instruction()),
|
506
510
|
{
|
507
511
|
system: "You are a story writer.",
|
508
512
|
instruction: "Write a short story about a robot learning to love.",
|
@@ -516,9 +520,11 @@ They can also be accessed through the shorthand methods `.withTextPrompt()`, `.w
|
|
516
520
|
|
517
521
|
```ts
|
518
522
|
const textStream = await streamText(
|
519
|
-
|
520
|
-
|
521
|
-
|
523
|
+
openai
|
524
|
+
.ChatTextGenerator({
|
525
|
+
model: "gpt-3.5-turbo",
|
526
|
+
})
|
527
|
+
.withChatPrompt(),
|
522
528
|
{
|
523
529
|
system: "You are a celebrated poet.",
|
524
530
|
messages: [
|
@@ -555,9 +561,11 @@ You an use prompt formats with image models as well, e.g. to use a basic text pr
|
|
555
561
|
|
556
562
|
```ts
|
557
563
|
const image = await generateImage(
|
558
|
-
|
559
|
-
|
560
|
-
|
564
|
+
stability
|
565
|
+
.ImageGenerator({
|
566
|
+
//...
|
567
|
+
})
|
568
|
+
.withBasicPrompt(),
|
561
569
|
"the wicked witch of the west in the style of early 19th century painting"
|
562
570
|
);
|
563
571
|
```
|
@@ -574,7 +582,7 @@ ModelFusion model functions return rich results that include the original respon
|
|
574
582
|
```ts
|
575
583
|
// access the full response (needs to be typed) and the metadata:
|
576
584
|
const { value, response, metadata } = await generateText(
|
577
|
-
|
585
|
+
openai.CompletionTextGenerator({
|
578
586
|
model: "gpt-3.5-turbo-instruct",
|
579
587
|
maxCompletionTokens: 1000,
|
580
588
|
n: 2, // generate 2 completions
|
package/guard/fixStructure.cjs
CHANGED
@@ -29,7 +29,7 @@ const StructureValidationError_js_1 = require("../model-function/generate-struct
|
|
29
29
|
* const result = await guard(
|
30
30
|
* (input) =>
|
31
31
|
* generateStructure(
|
32
|
-
*
|
32
|
+
* openai.ChatTextGenerator({
|
33
33
|
* // ...
|
34
34
|
* }),
|
35
35
|
* new ZodStructureDefinition({
|
package/guard/fixStructure.d.ts
CHANGED
package/guard/fixStructure.js
CHANGED
@@ -26,7 +26,7 @@ import { StructureValidationError } from "../model-function/generate-structure/S
|
|
26
26
|
* const result = await guard(
|
27
27
|
* (input) =>
|
28
28
|
* generateStructure(
|
29
|
-
*
|
29
|
+
* openai.ChatTextGenerator({
|
30
30
|
* // ...
|
31
31
|
* }),
|
32
32
|
* new ZodStructureDefinition({
|
@@ -15,7 +15,7 @@ export interface EmbeddingModel<VALUE, SETTINGS extends EmbeddingModelSettings =
|
|
15
15
|
/**
|
16
16
|
* True if the model can handle multiple embedding calls in parallel.
|
17
17
|
*/
|
18
|
-
readonly
|
18
|
+
readonly isParallelizable: boolean;
|
19
19
|
doEmbedValues(values: VALUE[], options?: FunctionOptions): PromiseLike<{
|
20
20
|
response: unknown;
|
21
21
|
embeddings: Vector[];
|
@@ -22,7 +22,7 @@ async function embedMany(model, values, options) {
|
|
22
22
|
}
|
23
23
|
// call the model for each group:
|
24
24
|
let responses;
|
25
|
-
if (model.
|
25
|
+
if (model.isParallelizable) {
|
26
26
|
responses = await Promise.all(valueGroups.map((valueGroup) => model.doEmbedValues(valueGroup, options)));
|
27
27
|
}
|
28
28
|
else {
|
@@ -9,7 +9,7 @@ import { EmbeddingModel, EmbeddingModelSettings } from "./EmbeddingModel.js";
|
|
9
9
|
*
|
10
10
|
* @example
|
11
11
|
* const embeddings = await embedMany(
|
12
|
-
*
|
12
|
+
* openai.TextEmbedder(...),
|
13
13
|
* [
|
14
14
|
* "At first, Nox didn't know what to do with the pup.",
|
15
15
|
* "He keenly observed and absorbed everything around him, from the birds in the sky to the trees in the forest.",
|
@@ -39,7 +39,7 @@ export declare function embedMany<VALUE>(model: EmbeddingModel<VALUE, EmbeddingM
|
|
39
39
|
*
|
40
40
|
* @example
|
41
41
|
* const embedding = await embed(
|
42
|
-
*
|
42
|
+
* openai.TextEmbedder(...),
|
43
43
|
* "At first, Nox didn't know what to do with the pup."
|
44
44
|
* );
|
45
45
|
*
|
@@ -19,7 +19,7 @@ export async function embedMany(model, values, options) {
|
|
19
19
|
}
|
20
20
|
// call the model for each group:
|
21
21
|
let responses;
|
22
|
-
if (model.
|
22
|
+
if (model.isParallelizable) {
|
23
23
|
responses = await Promise.all(valueGroups.map((valueGroup) => model.doEmbedValues(valueGroup, options)));
|
24
24
|
}
|
25
25
|
else {
|
@@ -12,7 +12,7 @@ import { ImageGenerationModel, ImageGenerationModelSettings } from "./ImageGener
|
|
12
12
|
*
|
13
13
|
* @example
|
14
14
|
* const image = await generateImage(
|
15
|
-
*
|
15
|
+
* stability.ImageGenerator(...),
|
16
16
|
* [
|
17
17
|
* { text: "the wicked witch of the west" },
|
18
18
|
* { text: "style of early 19th century painting", weight: 0.5 },
|
@@ -9,7 +9,7 @@ import { SpeechGenerationModel, SpeechGenerationModelSettings } from "./SpeechGe
|
|
9
9
|
*
|
10
10
|
* @example
|
11
11
|
* const speech = await generateSpeech(
|
12
|
-
*
|
12
|
+
* lmnt.Speech(...),
|
13
13
|
* "Good evening, ladies and gentlemen! Exciting news on the airwaves tonight " +
|
14
14
|
* "as The Rolling Stones unveil 'Hackney Diamonds.'
|
15
15
|
* );
|
@@ -12,7 +12,7 @@ import { SpeechGenerationModelSettings, StreamingSpeechGenerationModel } from ".
|
|
12
12
|
* const textStream = await streamText(...);
|
13
13
|
*
|
14
14
|
* const speechStream = await streamSpeech(
|
15
|
-
*
|
15
|
+
* elevenlabs.Speech(...),
|
16
16
|
* textStream
|
17
17
|
* );
|
18
18
|
*
|
@@ -12,7 +12,7 @@ import { StructureGenerationModel, StructureGenerationModelSettings } from "./St
|
|
12
12
|
*
|
13
13
|
* @example
|
14
14
|
* const sentiment = await generateStructure(
|
15
|
-
*
|
15
|
+
* openai.ChatTextGenerator(...),
|
16
16
|
* new ZodStructureDefinition({
|
17
17
|
* name: "sentiment",
|
18
18
|
* description: "Write the sentiment analysis",
|
@@ -12,7 +12,7 @@ import { TextGenerationModel, TextGenerationModelSettings } from "./TextGenerati
|
|
12
12
|
*
|
13
13
|
* @example
|
14
14
|
* const text = await generateText(
|
15
|
-
*
|
15
|
+
* openai.CompletionTextGenerator(...),
|
16
16
|
* "Write a short story about a robot learning to love:\n\n"
|
17
17
|
* );
|
18
18
|
*
|
@@ -12,7 +12,7 @@ import { TextStreamingModel } from "./TextGenerationModel.js";
|
|
12
12
|
*
|
13
13
|
* @example
|
14
14
|
* const textStream = await streamText(
|
15
|
-
*
|
15
|
+
* openai.CompletionTextGenerator(...),
|
16
16
|
* "Write a short story about a robot learning to love:\n\n"
|
17
17
|
* );
|
18
18
|
*
|
@@ -10,7 +10,7 @@ import { TranscriptionModel, TranscriptionModelSettings } from "./TranscriptionM
|
|
10
10
|
* const data = await fs.promises.readFile("data/test.mp3");
|
11
11
|
*
|
12
12
|
* const transcription = await generateTranscription(
|
13
|
-
*
|
13
|
+
* openai.Transcription({ model: "whisper-1" }),
|
14
14
|
* { type: "mp3", data }
|
15
15
|
* );
|
16
16
|
*
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.TextGenerator = void 0;
|
4
|
+
const AnthropicTextGenerationModel_js_1 = require("./AnthropicTextGenerationModel.cjs");
|
5
|
+
/**
|
6
|
+
* Create a text generation model that calls the Anthropic API.
|
7
|
+
*
|
8
|
+
* @see https://docs.anthropic.com/claude/reference/complete_post
|
9
|
+
*
|
10
|
+
* @return A new instance of {@link AnthropicTextGenerationModel}.
|
11
|
+
*/
|
12
|
+
function TextGenerator(settings) {
|
13
|
+
return new AnthropicTextGenerationModel_js_1.AnthropicTextGenerationModel(settings);
|
14
|
+
}
|
15
|
+
exports.TextGenerator = TextGenerator;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { AnthropicTextGenerationModel, AnthropicTextGenerationModelSettings } from "./AnthropicTextGenerationModel.js";
|
2
|
+
/**
|
3
|
+
* Create a text generation model that calls the Anthropic API.
|
4
|
+
*
|
5
|
+
* @see https://docs.anthropic.com/claude/reference/complete_post
|
6
|
+
*
|
7
|
+
* @return A new instance of {@link AnthropicTextGenerationModel}.
|
8
|
+
*/
|
9
|
+
export declare function TextGenerator(settings: AnthropicTextGenerationModelSettings): AnthropicTextGenerationModel;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { AnthropicTextGenerationModel, } from "./AnthropicTextGenerationModel.js";
|
2
|
+
/**
|
3
|
+
* Create a text generation model that calls the Anthropic API.
|
4
|
+
*
|
5
|
+
* @see https://docs.anthropic.com/claude/reference/complete_post
|
6
|
+
*
|
7
|
+
* @return A new instance of {@link AnthropicTextGenerationModel}.
|
8
|
+
*/
|
9
|
+
export function TextGenerator(settings) {
|
10
|
+
return new AnthropicTextGenerationModel(settings);
|
11
|
+
}
|
@@ -26,10 +26,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
26
|
return result;
|
27
27
|
};
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
-
exports.AnthropicPromptFormat = exports.anthropicErrorDataSchema = exports.AnthropicError = void 0;
|
29
|
+
exports.AnthropicPromptFormat = exports.anthropic = exports.anthropicErrorDataSchema = exports.AnthropicError = void 0;
|
30
30
|
__exportStar(require("./AnthropicApiConfiguration.cjs"), exports);
|
31
31
|
var AnthropicError_js_1 = require("./AnthropicError.cjs");
|
32
32
|
Object.defineProperty(exports, "AnthropicError", { enumerable: true, get: function () { return AnthropicError_js_1.AnthropicError; } });
|
33
33
|
Object.defineProperty(exports, "anthropicErrorDataSchema", { enumerable: true, get: function () { return AnthropicError_js_1.anthropicErrorDataSchema; } });
|
34
|
+
exports.anthropic = __importStar(require("./AnthropicFacade.cjs"));
|
34
35
|
exports.AnthropicPromptFormat = __importStar(require("./AnthropicPromptFormat.cjs"));
|
35
36
|
__exportStar(require("./AnthropicTextGenerationModel.cjs"), exports);
|
@@ -1,4 +1,5 @@
|
|
1
1
|
export * from "./AnthropicApiConfiguration.js";
|
2
2
|
export { AnthropicError, anthropicErrorDataSchema } from "./AnthropicError.js";
|
3
|
+
export * as anthropic from "./AnthropicFacade.js";
|
3
4
|
export * as AnthropicPromptFormat from "./AnthropicPromptFormat.js";
|
4
5
|
export * from "./AnthropicTextGenerationModel.js";
|
@@ -1,4 +1,5 @@
|
|
1
1
|
export * from "./AnthropicApiConfiguration.js";
|
2
2
|
export { AnthropicError, anthropicErrorDataSchema } from "./AnthropicError.js";
|
3
|
+
export * as anthropic from "./AnthropicFacade.js";
|
3
4
|
export * as AnthropicPromptFormat from "./AnthropicPromptFormat.js";
|
4
5
|
export * from "./AnthropicTextGenerationModel.js";
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ImageGenerator = void 0;
|
4
|
+
const Automatic1111ImageGenerationModel_js_1 = require("./Automatic1111ImageGenerationModel.cjs");
|
5
|
+
/**
|
6
|
+
* Create an image generation model that calls the AUTOMATIC1111 Stable Diffusion Web UI API.
|
7
|
+
*
|
8
|
+
* @see https://github.com/AUTOMATIC1111/stable-diffusion-webui
|
9
|
+
*
|
10
|
+
* @return A new instance of ${@link Automatic1111ImageGenerationModel}.
|
11
|
+
*/
|
12
|
+
function ImageGenerator(settings) {
|
13
|
+
return new Automatic1111ImageGenerationModel_js_1.Automatic1111ImageGenerationModel(settings);
|
14
|
+
}
|
15
|
+
exports.ImageGenerator = ImageGenerator;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { Automatic1111ImageGenerationModel, Automatic1111ImageGenerationSettings } from "./Automatic1111ImageGenerationModel.js";
|
2
|
+
/**
|
3
|
+
* Create an image generation model that calls the AUTOMATIC1111 Stable Diffusion Web UI API.
|
4
|
+
*
|
5
|
+
* @see https://github.com/AUTOMATIC1111/stable-diffusion-webui
|
6
|
+
*
|
7
|
+
* @return A new instance of ${@link Automatic1111ImageGenerationModel}.
|
8
|
+
*/
|
9
|
+
export declare function ImageGenerator(settings: Automatic1111ImageGenerationSettings): Automatic1111ImageGenerationModel;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { Automatic1111ImageGenerationModel, } from "./Automatic1111ImageGenerationModel.js";
|
2
|
+
/**
|
3
|
+
* Create an image generation model that calls the AUTOMATIC1111 Stable Diffusion Web UI API.
|
4
|
+
*
|
5
|
+
* @see https://github.com/AUTOMATIC1111/stable-diffusion-webui
|
6
|
+
*
|
7
|
+
* @return A new instance of ${@link Automatic1111ImageGenerationModel}.
|
8
|
+
*/
|
9
|
+
export function ImageGenerator(settings) {
|
10
|
+
return new Automatic1111ImageGenerationModel(settings);
|
11
|
+
}
|
@@ -10,13 +10,26 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
11
11
|
o[k2] = m[k];
|
12
12
|
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
13
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
20
|
};
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
22
|
+
if (mod && mod.__esModule) return mod;
|
23
|
+
var result = {};
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
25
|
+
__setModuleDefault(result, mod);
|
26
|
+
return result;
|
27
|
+
};
|
16
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
exports.Automatic1111Error = void 0;
|
29
|
+
exports.automatic1111 = exports.Automatic1111Error = void 0;
|
18
30
|
__exportStar(require("./Automatic1111ApiConfiguration.cjs"), exports);
|
19
31
|
var Automatic1111Error_js_1 = require("./Automatic1111Error.cjs");
|
20
32
|
Object.defineProperty(exports, "Automatic1111Error", { enumerable: true, get: function () { return Automatic1111Error_js_1.Automatic1111Error; } });
|
33
|
+
exports.automatic1111 = __importStar(require("./Automatic1111Facade.cjs"));
|
21
34
|
__exportStar(require("./Automatic1111ImageGenerationModel.cjs"), exports);
|
22
35
|
__exportStar(require("./Automatic1111ImageGenerationPrompt.cjs"), exports);
|
@@ -1,4 +1,5 @@
|
|
1
1
|
export * from "./Automatic1111ApiConfiguration.js";
|
2
2
|
export { Automatic1111Error, Automatic1111ErrorData, } from "./Automatic1111Error.js";
|
3
|
+
export * as automatic1111 from "./Automatic1111Facade.js";
|
3
4
|
export * from "./Automatic1111ImageGenerationModel.js";
|
4
5
|
export * from "./Automatic1111ImageGenerationPrompt.js";
|
@@ -1,4 +1,5 @@
|
|
1
1
|
export * from "./Automatic1111ApiConfiguration.js";
|
2
2
|
export { Automatic1111Error, } from "./Automatic1111Error.js";
|
3
|
+
export * as automatic1111 from "./Automatic1111Facade.js";
|
3
4
|
export * from "./Automatic1111ImageGenerationModel.js";
|
4
5
|
export * from "./Automatic1111ImageGenerationPrompt.js";
|
@@ -0,0 +1,71 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Tokenizer = exports.TextEmbedder = exports.TextGenerator = void 0;
|
4
|
+
const CohereTextEmbeddingModel_js_1 = require("./CohereTextEmbeddingModel.cjs");
|
5
|
+
const CohereTextGenerationModel_js_1 = require("./CohereTextGenerationModel.cjs");
|
6
|
+
const CohereTokenizer_js_1 = require("./CohereTokenizer.cjs");
|
7
|
+
/**
|
8
|
+
* Create a text generation model that calls the Cohere Co.Generate API.
|
9
|
+
*
|
10
|
+
* @see https://docs.cohere.com/reference/generate
|
11
|
+
*
|
12
|
+
* @example
|
13
|
+
* const model = cohere.TextGenerator({
|
14
|
+
* model: "command-nightly",
|
15
|
+
* temperature: 0.7,
|
16
|
+
* maxCompletionTokens: 500,
|
17
|
+
* });
|
18
|
+
*
|
19
|
+
* const text = await generateText(
|
20
|
+
* model,
|
21
|
+
* "Write a short story about a robot learning to love:\n\n"
|
22
|
+
* );
|
23
|
+
*
|
24
|
+
* @returns A new instance of {@link CohereTextGenerationModel}.
|
25
|
+
*/
|
26
|
+
function TextGenerator(settings) {
|
27
|
+
return new CohereTextGenerationModel_js_1.CohereTextGenerationModel(settings);
|
28
|
+
}
|
29
|
+
exports.TextGenerator = TextGenerator;
|
30
|
+
/**
|
31
|
+
* Create a text embedding model that calls the Cohere Co.Embed API.
|
32
|
+
*
|
33
|
+
* @see https://docs.cohere.com/reference/embed
|
34
|
+
*
|
35
|
+
* @example
|
36
|
+
* const embeddings = await embedMany(
|
37
|
+
* cohere.TextEmbedder({ model: "embed-english-light-v2.0" }),
|
38
|
+
* [
|
39
|
+
* "At first, Nox didn't know what to do with the pup.",
|
40
|
+
* "He keenly observed and absorbed everything around him, from the birds in the sky to the trees in the forest.",
|
41
|
+
* ]
|
42
|
+
* );
|
43
|
+
*
|
44
|
+
* @returns A new instance of {@link CohereTextEmbeddingModel}.
|
45
|
+
*/
|
46
|
+
function TextEmbedder(settings) {
|
47
|
+
return new CohereTextEmbeddingModel_js_1.CohereTextEmbeddingModel(settings);
|
48
|
+
}
|
49
|
+
exports.TextEmbedder = TextEmbedder;
|
50
|
+
/**
|
51
|
+
* Tokenizer for the Cohere models. It uses the Co.Tokenize and Co.Detokenize APIs.
|
52
|
+
*
|
53
|
+
* @see https://docs.cohere.com/reference/tokenize
|
54
|
+
* @see https://docs.cohere.com/reference/detokenize-1
|
55
|
+
*
|
56
|
+
* @example
|
57
|
+
* const tokenizer = cohere.Tokenizer({ model: "command-nightly" });
|
58
|
+
*
|
59
|
+
* const text = "At first, Nox didn't know what to do with the pup.";
|
60
|
+
*
|
61
|
+
* const tokenCount = await countTokens(tokenizer, text);
|
62
|
+
* const tokens = await tokenizer.tokenize(text);
|
63
|
+
* const tokensAndTokenTexts = await tokenizer.tokenizeWithTexts(text);
|
64
|
+
* const reconstructedText = await tokenizer.detokenize(tokens);
|
65
|
+
*
|
66
|
+
* @returns A new instance of {@link CohereTokenizer}.
|
67
|
+
*/
|
68
|
+
function Tokenizer(settings) {
|
69
|
+
return new CohereTokenizer_js_1.CohereTokenizer(settings);
|
70
|
+
}
|
71
|
+
exports.Tokenizer = Tokenizer;
|