modelfusion 0.39.0 → 0.40.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/model-provider/cohere/CohereTextGenerationModel.cjs +4 -1
- package/model-provider/cohere/CohereTextGenerationModel.js +4 -1
- package/model-provider/llamacpp/LlamaCppTextGenerationModel.cjs +4 -1
- package/model-provider/llamacpp/LlamaCppTextGenerationModel.js +4 -1
- package/model-provider/openai/OpenAITextGenerationModel.cjs +4 -1
- package/model-provider/openai/OpenAITextGenerationModel.js +4 -1
- package/model-provider/openai/chat/OpenAIChatModel.cjs +6 -1
- package/model-provider/openai/chat/OpenAIChatModel.js +6 -1
- package/package.json +1 -10
- package/prompt/PromptFormatTextGenerationModel.cjs +4 -1
- package/prompt/PromptFormatTextGenerationModel.js +4 -1
- package/vector-index/index.cjs +0 -1
- package/vector-index/index.d.ts +0 -1
- package/vector-index/index.js +0 -1
- package/vector-index/pinecone/PineconeVectorIndex.cjs +0 -66
- package/vector-index/pinecone/PineconeVectorIndex.d.ts +0 -29
- package/vector-index/pinecone/PineconeVectorIndex.js +0 -62
@@ -142,7 +142,10 @@ class CohereTextGenerationModel extends AbstractModel_js_1.AbstractModel {
|
|
142
142
|
withPromptFormat(promptFormat) {
|
143
143
|
return new PromptFormatTextGenerationModel_js_1.PromptFormatTextGenerationModel({
|
144
144
|
model: this.withSettings({
|
145
|
-
stopSequences:
|
145
|
+
stopSequences: [
|
146
|
+
...(this.settings.stopSequences ?? []),
|
147
|
+
...promptFormat.stopSequences,
|
148
|
+
],
|
146
149
|
}),
|
147
150
|
promptFormat,
|
148
151
|
});
|
@@ -136,7 +136,10 @@ export class CohereTextGenerationModel extends AbstractModel {
|
|
136
136
|
withPromptFormat(promptFormat) {
|
137
137
|
return new PromptFormatTextGenerationModel({
|
138
138
|
model: this.withSettings({
|
139
|
-
stopSequences:
|
139
|
+
stopSequences: [
|
140
|
+
...(this.settings.stopSequences ?? []),
|
141
|
+
...promptFormat.stopSequences,
|
142
|
+
],
|
140
143
|
}),
|
141
144
|
promptFormat,
|
142
145
|
});
|
@@ -108,7 +108,10 @@ class LlamaCppTextGenerationModel extends AbstractModel_js_1.AbstractModel {
|
|
108
108
|
withPromptFormat(promptFormat) {
|
109
109
|
return new PromptFormatTextGenerationModel_js_1.PromptFormatTextGenerationModel({
|
110
110
|
model: this.withSettings({
|
111
|
-
stopSequences:
|
111
|
+
stopSequences: [
|
112
|
+
...(this.settings.stopSequences ?? []),
|
113
|
+
...promptFormat.stopSequences,
|
114
|
+
],
|
112
115
|
}),
|
113
116
|
promptFormat,
|
114
117
|
});
|
@@ -102,7 +102,10 @@ export class LlamaCppTextGenerationModel extends AbstractModel {
|
|
102
102
|
withPromptFormat(promptFormat) {
|
103
103
|
return new PromptFormatTextGenerationModel({
|
104
104
|
model: this.withSettings({
|
105
|
-
stopSequences:
|
105
|
+
stopSequences: [
|
106
|
+
...(this.settings.stopSequences ?? []),
|
107
|
+
...promptFormat.stopSequences,
|
108
|
+
],
|
106
109
|
}),
|
107
110
|
promptFormat,
|
108
111
|
});
|
@@ -242,7 +242,10 @@ class OpenAITextGenerationModel extends AbstractModel_js_1.AbstractModel {
|
|
242
242
|
withPromptFormat(promptFormat) {
|
243
243
|
return new PromptFormatTextGenerationModel_js_1.PromptFormatTextGenerationModel({
|
244
244
|
model: this.withSettings({
|
245
|
-
stopSequences:
|
245
|
+
stopSequences: [
|
246
|
+
...(this.settings.stopSequences ?? []),
|
247
|
+
...promptFormat.stopSequences,
|
248
|
+
],
|
246
249
|
}),
|
247
250
|
promptFormat,
|
248
251
|
});
|
@@ -233,7 +233,10 @@ export class OpenAITextGenerationModel extends AbstractModel {
|
|
233
233
|
withPromptFormat(promptFormat) {
|
234
234
|
return new PromptFormatTextGenerationModel({
|
235
235
|
model: this.withSettings({
|
236
|
-
stopSequences:
|
236
|
+
stopSequences: [
|
237
|
+
...(this.settings.stopSequences ?? []),
|
238
|
+
...promptFormat.stopSequences,
|
239
|
+
],
|
237
240
|
}),
|
238
241
|
promptFormat,
|
239
242
|
});
|
@@ -329,7 +329,12 @@ class OpenAIChatModel extends AbstractModel_js_1.AbstractModel {
|
|
329
329
|
}
|
330
330
|
withPromptFormat(promptFormat) {
|
331
331
|
return new PromptFormatTextGenerationModel_js_1.PromptFormatTextGenerationModel({
|
332
|
-
model: this.withSettings({
|
332
|
+
model: this.withSettings({
|
333
|
+
stopSequences: [
|
334
|
+
...(this.settings.stopSequences ?? []),
|
335
|
+
...promptFormat.stopSequences,
|
336
|
+
],
|
337
|
+
}),
|
333
338
|
promptFormat,
|
334
339
|
});
|
335
340
|
}
|
@@ -320,7 +320,12 @@ export class OpenAIChatModel extends AbstractModel {
|
|
320
320
|
}
|
321
321
|
withPromptFormat(promptFormat) {
|
322
322
|
return new PromptFormatTextGenerationModel({
|
323
|
-
model: this.withSettings({
|
323
|
+
model: this.withSettings({
|
324
|
+
stopSequences: [
|
325
|
+
...(this.settings.stopSequences ?? []),
|
326
|
+
...promptFormat.stopSequences,
|
327
|
+
],
|
328
|
+
}),
|
324
329
|
promptFormat,
|
325
330
|
});
|
326
331
|
}
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "modelfusion",
|
3
3
|
"description": "Build multimodal applications, chatbots, and agents with JavaScript and TypeScript.",
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.40.1",
|
5
5
|
"author": "Lars Grammel",
|
6
6
|
"license": "MIT",
|
7
7
|
"keywords": [
|
@@ -61,7 +61,6 @@
|
|
61
61
|
"zod-to-json-schema": "3.21.4"
|
62
62
|
},
|
63
63
|
"devDependencies": {
|
64
|
-
"@pinecone-database/pinecone": "^0.1.6",
|
65
64
|
"@tsconfig/recommended": "1.0.3",
|
66
65
|
"@types/deep-equal": "^1.0.2",
|
67
66
|
"@types/node": "18.11.9",
|
@@ -76,13 +75,5 @@
|
|
76
75
|
"rimraf": "5.0.5",
|
77
76
|
"typescript": "5.2.2",
|
78
77
|
"vitest": "^0.34.5"
|
79
|
-
},
|
80
|
-
"peerDependencies": {
|
81
|
-
"@pinecone-database/pinecone": "0.1.6"
|
82
|
-
},
|
83
|
-
"peerDependenciesMeta": {
|
84
|
-
"@pinecone-database/pinecone": {
|
85
|
-
"optional": true
|
86
|
-
}
|
87
78
|
}
|
88
79
|
}
|
@@ -60,7 +60,10 @@ class PromptFormatTextGenerationModel {
|
|
60
60
|
withPromptFormat(promptFormat) {
|
61
61
|
return new PromptFormatTextGenerationModel({
|
62
62
|
model: this.withSettings({
|
63
|
-
stopSequences:
|
63
|
+
stopSequences: [
|
64
|
+
...(this.settings.stopSequences ?? []),
|
65
|
+
...promptFormat.stopSequences,
|
66
|
+
],
|
64
67
|
}),
|
65
68
|
promptFormat,
|
66
69
|
});
|
@@ -57,7 +57,10 @@ export class PromptFormatTextGenerationModel {
|
|
57
57
|
withPromptFormat(promptFormat) {
|
58
58
|
return new PromptFormatTextGenerationModel({
|
59
59
|
model: this.withSettings({
|
60
|
-
stopSequences:
|
60
|
+
stopSequences: [
|
61
|
+
...(this.settings.stopSequences ?? []),
|
62
|
+
...promptFormat.stopSequences,
|
63
|
+
],
|
61
64
|
}),
|
62
65
|
promptFormat,
|
63
66
|
});
|
package/vector-index/index.cjs
CHANGED
@@ -17,5 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./VectorIndex.cjs"), exports);
|
18
18
|
__exportStar(require("./VectorIndexRetriever.cjs"), exports);
|
19
19
|
__exportStar(require("./memory/MemoryVectorIndex.cjs"), exports);
|
20
|
-
__exportStar(require("./pinecone/PineconeVectorIndex.cjs"), exports);
|
21
20
|
__exportStar(require("./upsertIntoVectorIndex.cjs"), exports);
|
package/vector-index/index.d.ts
CHANGED
package/vector-index/index.js
CHANGED
@@ -1,66 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.PineconeVectorIndex = void 0;
|
4
|
-
class PineconeVectorIndex {
|
5
|
-
constructor({ index, namespace, schema, }) {
|
6
|
-
Object.defineProperty(this, "index", {
|
7
|
-
enumerable: true,
|
8
|
-
configurable: true,
|
9
|
-
writable: true,
|
10
|
-
value: void 0
|
11
|
-
});
|
12
|
-
Object.defineProperty(this, "namespace", {
|
13
|
-
enumerable: true,
|
14
|
-
configurable: true,
|
15
|
-
writable: true,
|
16
|
-
value: void 0
|
17
|
-
});
|
18
|
-
Object.defineProperty(this, "schema", {
|
19
|
-
enumerable: true,
|
20
|
-
configurable: true,
|
21
|
-
writable: true,
|
22
|
-
value: void 0
|
23
|
-
});
|
24
|
-
this.index = index;
|
25
|
-
this.namespace = namespace;
|
26
|
-
this.schema = schema;
|
27
|
-
}
|
28
|
-
async upsertMany(data) {
|
29
|
-
this.index.upsert({
|
30
|
-
upsertRequest: {
|
31
|
-
namespace: this.namespace,
|
32
|
-
vectors: data.map((entry) => ({
|
33
|
-
id: entry.id,
|
34
|
-
values: entry.vector,
|
35
|
-
metadata: entry.data,
|
36
|
-
})),
|
37
|
-
},
|
38
|
-
});
|
39
|
-
}
|
40
|
-
async queryByVector({ queryVector, similarityThreshold, maxResults, }) {
|
41
|
-
const { matches } = await this.index.query({
|
42
|
-
queryRequest: {
|
43
|
-
namespace: this.namespace,
|
44
|
-
vector: queryVector,
|
45
|
-
topK: maxResults,
|
46
|
-
includeMetadata: true,
|
47
|
-
},
|
48
|
-
});
|
49
|
-
if (matches == undefined) {
|
50
|
-
return [];
|
51
|
-
}
|
52
|
-
return matches
|
53
|
-
.filter((match) => similarityThreshold == undefined ||
|
54
|
-
match.score == undefined ||
|
55
|
-
match.score > similarityThreshold)
|
56
|
-
.map((match) => ({
|
57
|
-
id: match.id,
|
58
|
-
data: this.schema.parse(match.metadata),
|
59
|
-
similarity: match.score,
|
60
|
-
}));
|
61
|
-
}
|
62
|
-
asIndex() {
|
63
|
-
return this;
|
64
|
-
}
|
65
|
-
}
|
66
|
-
exports.PineconeVectorIndex = PineconeVectorIndex;
|
@@ -1,29 +0,0 @@
|
|
1
|
-
import { VectorOperationsApi } from "@pinecone-database/pinecone/dist/pinecone-generated-ts-fetch/index.js";
|
2
|
-
import { z } from "zod";
|
3
|
-
import { Vector } from "../../core/Vector.js";
|
4
|
-
import { VectorIndex } from "../VectorIndex.js";
|
5
|
-
export declare class PineconeVectorIndex<DATA extends object | undefined> implements VectorIndex<DATA, PineconeVectorIndex<DATA>, null> {
|
6
|
-
readonly index: VectorOperationsApi;
|
7
|
-
readonly namespace?: string;
|
8
|
-
readonly schema: z.ZodSchema<DATA>;
|
9
|
-
constructor({ index, namespace, schema, }: {
|
10
|
-
index: VectorOperationsApi;
|
11
|
-
namespace?: string;
|
12
|
-
schema: z.ZodSchema<DATA>;
|
13
|
-
});
|
14
|
-
upsertMany(data: Array<{
|
15
|
-
id: string;
|
16
|
-
vector: Vector;
|
17
|
-
data: DATA;
|
18
|
-
}>): Promise<void>;
|
19
|
-
queryByVector({ queryVector, similarityThreshold, maxResults, }: {
|
20
|
-
queryVector: Vector;
|
21
|
-
maxResults: number;
|
22
|
-
similarityThreshold?: number;
|
23
|
-
}): Promise<Array<{
|
24
|
-
id: string;
|
25
|
-
data: DATA;
|
26
|
-
similarity?: number;
|
27
|
-
}>>;
|
28
|
-
asIndex(): PineconeVectorIndex<DATA>;
|
29
|
-
}
|
@@ -1,62 +0,0 @@
|
|
1
|
-
export class PineconeVectorIndex {
|
2
|
-
constructor({ index, namespace, schema, }) {
|
3
|
-
Object.defineProperty(this, "index", {
|
4
|
-
enumerable: true,
|
5
|
-
configurable: true,
|
6
|
-
writable: true,
|
7
|
-
value: void 0
|
8
|
-
});
|
9
|
-
Object.defineProperty(this, "namespace", {
|
10
|
-
enumerable: true,
|
11
|
-
configurable: true,
|
12
|
-
writable: true,
|
13
|
-
value: void 0
|
14
|
-
});
|
15
|
-
Object.defineProperty(this, "schema", {
|
16
|
-
enumerable: true,
|
17
|
-
configurable: true,
|
18
|
-
writable: true,
|
19
|
-
value: void 0
|
20
|
-
});
|
21
|
-
this.index = index;
|
22
|
-
this.namespace = namespace;
|
23
|
-
this.schema = schema;
|
24
|
-
}
|
25
|
-
async upsertMany(data) {
|
26
|
-
this.index.upsert({
|
27
|
-
upsertRequest: {
|
28
|
-
namespace: this.namespace,
|
29
|
-
vectors: data.map((entry) => ({
|
30
|
-
id: entry.id,
|
31
|
-
values: entry.vector,
|
32
|
-
metadata: entry.data,
|
33
|
-
})),
|
34
|
-
},
|
35
|
-
});
|
36
|
-
}
|
37
|
-
async queryByVector({ queryVector, similarityThreshold, maxResults, }) {
|
38
|
-
const { matches } = await this.index.query({
|
39
|
-
queryRequest: {
|
40
|
-
namespace: this.namespace,
|
41
|
-
vector: queryVector,
|
42
|
-
topK: maxResults,
|
43
|
-
includeMetadata: true,
|
44
|
-
},
|
45
|
-
});
|
46
|
-
if (matches == undefined) {
|
47
|
-
return [];
|
48
|
-
}
|
49
|
-
return matches
|
50
|
-
.filter((match) => similarityThreshold == undefined ||
|
51
|
-
match.score == undefined ||
|
52
|
-
match.score > similarityThreshold)
|
53
|
-
.map((match) => ({
|
54
|
-
id: match.id,
|
55
|
-
data: this.schema.parse(match.metadata),
|
56
|
-
similarity: match.score,
|
57
|
-
}));
|
58
|
-
}
|
59
|
-
asIndex() {
|
60
|
-
return this;
|
61
|
-
}
|
62
|
-
}
|