langchain 0.0.137 → 0.0.139
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/chat_models/minimax.cjs +1 -0
- package/chat_models/minimax.d.ts +1 -0
- package/chat_models/minimax.js +1 -0
- package/dist/agents/initialize.cjs +11 -0
- package/dist/agents/initialize.d.ts +4 -0
- package/dist/agents/initialize.js +11 -0
- package/dist/agents/xml/index.cjs +119 -0
- package/dist/agents/xml/index.d.ts +51 -0
- package/dist/agents/xml/index.js +114 -0
- package/dist/agents/xml/prompt.cjs +23 -0
- package/dist/agents/xml/prompt.d.ts +1 -0
- package/dist/agents/xml/prompt.js +20 -0
- package/dist/callbacks/base.d.ts +12 -4
- package/dist/callbacks/handlers/run_collector.cjs +50 -0
- package/dist/callbacks/handlers/run_collector.d.ts +26 -0
- package/dist/callbacks/handlers/run_collector.js +46 -0
- package/dist/callbacks/handlers/tracer.cjs +33 -20
- package/dist/callbacks/handlers/tracer.d.ts +7 -3
- package/dist/callbacks/handlers/tracer.js +33 -20
- package/dist/callbacks/handlers/tracer_langchain.cjs +1 -0
- package/dist/callbacks/handlers/tracer_langchain.d.ts +2 -1
- package/dist/callbacks/handlers/tracer_langchain.js +1 -0
- package/dist/callbacks/index.cjs +3 -1
- package/dist/callbacks/index.d.ts +1 -0
- package/dist/callbacks/index.js +1 -0
- package/dist/callbacks/manager.cjs +29 -14
- package/dist/callbacks/manager.d.ts +9 -4
- package/dist/callbacks/manager.js +29 -14
- package/dist/chains/openai_functions/extraction.cjs +2 -2
- package/dist/chains/openai_functions/extraction.d.ts +5 -4
- package/dist/chains/openai_functions/extraction.js +2 -2
- package/dist/chains/openai_functions/openapi.d.ts +2 -1
- package/dist/chains/openai_functions/structured_output.d.ts +4 -3
- package/dist/chains/openai_functions/tagging.cjs +2 -2
- package/dist/chains/openai_functions/tagging.d.ts +5 -4
- package/dist/chains/openai_functions/tagging.js +2 -2
- package/dist/chat_models/anthropic.cjs +7 -5
- package/dist/chat_models/anthropic.d.ts +17 -12
- package/dist/chat_models/anthropic.js +4 -2
- package/dist/chat_models/minimax.cjs +547 -0
- package/dist/chat_models/minimax.d.ts +364 -0
- package/dist/chat_models/minimax.js +543 -0
- package/dist/chat_models/ollama.cjs +136 -0
- package/dist/chat_models/ollama.d.ts +34 -0
- package/dist/chat_models/ollama.js +136 -0
- package/dist/embeddings/minimax.cjs +152 -0
- package/dist/embeddings/minimax.d.ts +104 -0
- package/dist/embeddings/minimax.js +148 -0
- package/dist/experimental/chat_models/anthropic_functions.cjs +129 -0
- package/dist/experimental/chat_models/anthropic_functions.d.ts +20 -0
- package/dist/experimental/chat_models/anthropic_functions.js +125 -0
- package/dist/llms/ollama.cjs +136 -0
- package/dist/llms/ollama.d.ts +34 -0
- package/dist/llms/ollama.js +136 -0
- package/dist/load/import_constants.cjs +1 -0
- package/dist/load/import_constants.js +1 -0
- package/dist/load/import_map.cjs +4 -2
- package/dist/load/import_map.d.ts +2 -0
- package/dist/load/import_map.js +2 -0
- package/dist/schema/output_parser.cjs +1 -1
- package/dist/schema/output_parser.js +1 -1
- package/dist/schema/runnable.cjs +54 -15
- package/dist/schema/runnable.d.ts +9 -3
- package/dist/schema/runnable.js +55 -16
- package/dist/sql_db.cjs +3 -1
- package/dist/sql_db.js +3 -1
- package/dist/util/ollama.d.ts +34 -0
- package/dist/vectorstores/redis.cjs +17 -2
- package/dist/vectorstores/redis.d.ts +10 -1
- package/dist/vectorstores/redis.js +17 -2
- package/dist/vectorstores/zep.cjs +2 -1
- package/dist/vectorstores/zep.js +3 -2
- package/embeddings/minimax.cjs +1 -0
- package/embeddings/minimax.d.ts +1 -0
- package/embeddings/minimax.js +1 -0
- package/experimental/chat_models/anthropic_functions.cjs +1 -0
- package/experimental/chat_models/anthropic_functions.d.ts +1 -0
- package/experimental/chat_models/anthropic_functions.js +1 -0
- package/package.json +34 -5
|
@@ -33,6 +33,42 @@ class ChatOllama extends base_js_1.SimpleChatModel {
|
|
|
33
33
|
writable: true,
|
|
34
34
|
value: "http://localhost:11434"
|
|
35
35
|
});
|
|
36
|
+
Object.defineProperty(this, "embeddingOnly", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
configurable: true,
|
|
39
|
+
writable: true,
|
|
40
|
+
value: void 0
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(this, "f16KV", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
configurable: true,
|
|
45
|
+
writable: true,
|
|
46
|
+
value: void 0
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(this, "frequencyPenalty", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
configurable: true,
|
|
51
|
+
writable: true,
|
|
52
|
+
value: void 0
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(this, "logitsAll", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
configurable: true,
|
|
57
|
+
writable: true,
|
|
58
|
+
value: void 0
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(this, "lowVram", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
configurable: true,
|
|
63
|
+
writable: true,
|
|
64
|
+
value: void 0
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(this, "mainGpu", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
configurable: true,
|
|
69
|
+
writable: true,
|
|
70
|
+
value: void 0
|
|
71
|
+
});
|
|
36
72
|
Object.defineProperty(this, "mirostat", {
|
|
37
73
|
enumerable: true,
|
|
38
74
|
configurable: true,
|
|
@@ -51,6 +87,12 @@ class ChatOllama extends base_js_1.SimpleChatModel {
|
|
|
51
87
|
writable: true,
|
|
52
88
|
value: void 0
|
|
53
89
|
});
|
|
90
|
+
Object.defineProperty(this, "numBatch", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
configurable: true,
|
|
93
|
+
writable: true,
|
|
94
|
+
value: void 0
|
|
95
|
+
});
|
|
54
96
|
Object.defineProperty(this, "numCtx", {
|
|
55
97
|
enumerable: true,
|
|
56
98
|
configurable: true,
|
|
@@ -63,12 +105,36 @@ class ChatOllama extends base_js_1.SimpleChatModel {
|
|
|
63
105
|
writable: true,
|
|
64
106
|
value: void 0
|
|
65
107
|
});
|
|
108
|
+
Object.defineProperty(this, "numGqa", {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
configurable: true,
|
|
111
|
+
writable: true,
|
|
112
|
+
value: void 0
|
|
113
|
+
});
|
|
114
|
+
Object.defineProperty(this, "numKeep", {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
configurable: true,
|
|
117
|
+
writable: true,
|
|
118
|
+
value: void 0
|
|
119
|
+
});
|
|
66
120
|
Object.defineProperty(this, "numThread", {
|
|
67
121
|
enumerable: true,
|
|
68
122
|
configurable: true,
|
|
69
123
|
writable: true,
|
|
70
124
|
value: void 0
|
|
71
125
|
});
|
|
126
|
+
Object.defineProperty(this, "penalizeNewline", {
|
|
127
|
+
enumerable: true,
|
|
128
|
+
configurable: true,
|
|
129
|
+
writable: true,
|
|
130
|
+
value: void 0
|
|
131
|
+
});
|
|
132
|
+
Object.defineProperty(this, "presencePenalty", {
|
|
133
|
+
enumerable: true,
|
|
134
|
+
configurable: true,
|
|
135
|
+
writable: true,
|
|
136
|
+
value: void 0
|
|
137
|
+
});
|
|
72
138
|
Object.defineProperty(this, "repeatLastN", {
|
|
73
139
|
enumerable: true,
|
|
74
140
|
configurable: true,
|
|
@@ -81,6 +147,18 @@ class ChatOllama extends base_js_1.SimpleChatModel {
|
|
|
81
147
|
writable: true,
|
|
82
148
|
value: void 0
|
|
83
149
|
});
|
|
150
|
+
Object.defineProperty(this, "ropeFrequencyBase", {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
configurable: true,
|
|
153
|
+
writable: true,
|
|
154
|
+
value: void 0
|
|
155
|
+
});
|
|
156
|
+
Object.defineProperty(this, "ropeFrequencyScale", {
|
|
157
|
+
enumerable: true,
|
|
158
|
+
configurable: true,
|
|
159
|
+
writable: true,
|
|
160
|
+
value: void 0
|
|
161
|
+
});
|
|
84
162
|
Object.defineProperty(this, "temperature", {
|
|
85
163
|
enumerable: true,
|
|
86
164
|
configurable: true,
|
|
@@ -111,23 +189,64 @@ class ChatOllama extends base_js_1.SimpleChatModel {
|
|
|
111
189
|
writable: true,
|
|
112
190
|
value: void 0
|
|
113
191
|
});
|
|
192
|
+
Object.defineProperty(this, "typicalP", {
|
|
193
|
+
enumerable: true,
|
|
194
|
+
configurable: true,
|
|
195
|
+
writable: true,
|
|
196
|
+
value: void 0
|
|
197
|
+
});
|
|
198
|
+
Object.defineProperty(this, "useMLock", {
|
|
199
|
+
enumerable: true,
|
|
200
|
+
configurable: true,
|
|
201
|
+
writable: true,
|
|
202
|
+
value: void 0
|
|
203
|
+
});
|
|
204
|
+
Object.defineProperty(this, "useMMap", {
|
|
205
|
+
enumerable: true,
|
|
206
|
+
configurable: true,
|
|
207
|
+
writable: true,
|
|
208
|
+
value: void 0
|
|
209
|
+
});
|
|
210
|
+
Object.defineProperty(this, "vocabOnly", {
|
|
211
|
+
enumerable: true,
|
|
212
|
+
configurable: true,
|
|
213
|
+
writable: true,
|
|
214
|
+
value: void 0
|
|
215
|
+
});
|
|
114
216
|
this.model = fields.model ?? this.model;
|
|
115
217
|
this.baseUrl = fields.baseUrl?.endsWith("/")
|
|
116
218
|
? fields.baseUrl.slice(0, -1)
|
|
117
219
|
: fields.baseUrl ?? this.baseUrl;
|
|
220
|
+
this.embeddingOnly = fields.embeddingOnly;
|
|
221
|
+
this.f16KV = fields.f16KV;
|
|
222
|
+
this.frequencyPenalty = fields.frequencyPenalty;
|
|
223
|
+
this.logitsAll = fields.logitsAll;
|
|
224
|
+
this.lowVram = fields.lowVram;
|
|
225
|
+
this.mainGpu = fields.mainGpu;
|
|
118
226
|
this.mirostat = fields.mirostat;
|
|
119
227
|
this.mirostatEta = fields.mirostatEta;
|
|
120
228
|
this.mirostatTau = fields.mirostatTau;
|
|
229
|
+
this.numBatch = fields.numBatch;
|
|
121
230
|
this.numCtx = fields.numCtx;
|
|
122
231
|
this.numGpu = fields.numGpu;
|
|
232
|
+
this.numGqa = fields.numGqa;
|
|
233
|
+
this.numKeep = fields.numKeep;
|
|
123
234
|
this.numThread = fields.numThread;
|
|
235
|
+
this.penalizeNewline = fields.penalizeNewline;
|
|
236
|
+
this.presencePenalty = fields.presencePenalty;
|
|
124
237
|
this.repeatLastN = fields.repeatLastN;
|
|
125
238
|
this.repeatPenalty = fields.repeatPenalty;
|
|
239
|
+
this.ropeFrequencyBase = fields.ropeFrequencyBase;
|
|
240
|
+
this.ropeFrequencyScale = fields.ropeFrequencyScale;
|
|
126
241
|
this.temperature = fields.temperature;
|
|
127
242
|
this.stop = fields.stop;
|
|
128
243
|
this.tfsZ = fields.tfsZ;
|
|
129
244
|
this.topK = fields.topK;
|
|
130
245
|
this.topP = fields.topP;
|
|
246
|
+
this.typicalP = fields.typicalP;
|
|
247
|
+
this.useMLock = fields.useMLock;
|
|
248
|
+
this.useMMap = fields.useMMap;
|
|
249
|
+
this.vocabOnly = fields.vocabOnly;
|
|
131
250
|
}
|
|
132
251
|
_llmType() {
|
|
133
252
|
return "ollama";
|
|
@@ -142,19 +261,36 @@ class ChatOllama extends base_js_1.SimpleChatModel {
|
|
|
142
261
|
return {
|
|
143
262
|
model: this.model,
|
|
144
263
|
options: {
|
|
264
|
+
embedding_only: this.embeddingOnly,
|
|
265
|
+
f16_kv: this.f16KV,
|
|
266
|
+
frequency_penalty: this.frequencyPenalty,
|
|
267
|
+
logits_all: this.logitsAll,
|
|
268
|
+
low_vram: this.lowVram,
|
|
269
|
+
main_gpu: this.mainGpu,
|
|
145
270
|
mirostat: this.mirostat,
|
|
146
271
|
mirostat_eta: this.mirostatEta,
|
|
147
272
|
mirostat_tau: this.mirostatTau,
|
|
273
|
+
num_batch: this.numBatch,
|
|
148
274
|
num_ctx: this.numCtx,
|
|
149
275
|
num_gpu: this.numGpu,
|
|
276
|
+
num_gqa: this.numGqa,
|
|
277
|
+
num_keep: this.numKeep,
|
|
150
278
|
num_thread: this.numThread,
|
|
279
|
+
penalize_newline: this.penalizeNewline,
|
|
280
|
+
presence_penalty: this.presencePenalty,
|
|
151
281
|
repeat_last_n: this.repeatLastN,
|
|
152
282
|
repeat_penalty: this.repeatPenalty,
|
|
283
|
+
rope_frequency_base: this.ropeFrequencyBase,
|
|
284
|
+
rope_frequency_scale: this.ropeFrequencyScale,
|
|
153
285
|
temperature: this.temperature,
|
|
154
286
|
stop: options?.stop ?? this.stop,
|
|
155
287
|
tfs_z: this.tfsZ,
|
|
156
288
|
top_k: this.topK,
|
|
157
289
|
top_p: this.topP,
|
|
290
|
+
typical_p: this.typicalP,
|
|
291
|
+
use_mlock: this.useMLock,
|
|
292
|
+
use_mmap: this.useMMap,
|
|
293
|
+
vocab_only: this.vocabOnly,
|
|
158
294
|
},
|
|
159
295
|
};
|
|
160
296
|
}
|
|
@@ -20,19 +20,36 @@ export declare class ChatOllama extends SimpleChatModel implements OllamaInput {
|
|
|
20
20
|
lc_serializable: boolean;
|
|
21
21
|
model: string;
|
|
22
22
|
baseUrl: string;
|
|
23
|
+
embeddingOnly?: boolean;
|
|
24
|
+
f16KV?: boolean;
|
|
25
|
+
frequencyPenalty?: number;
|
|
26
|
+
logitsAll?: boolean;
|
|
27
|
+
lowVram?: boolean;
|
|
28
|
+
mainGpu?: number;
|
|
23
29
|
mirostat?: number;
|
|
24
30
|
mirostatEta?: number;
|
|
25
31
|
mirostatTau?: number;
|
|
32
|
+
numBatch?: number;
|
|
26
33
|
numCtx?: number;
|
|
27
34
|
numGpu?: number;
|
|
35
|
+
numGqa?: number;
|
|
36
|
+
numKeep?: number;
|
|
28
37
|
numThread?: number;
|
|
38
|
+
penalizeNewline?: boolean;
|
|
39
|
+
presencePenalty?: number;
|
|
29
40
|
repeatLastN?: number;
|
|
30
41
|
repeatPenalty?: number;
|
|
42
|
+
ropeFrequencyBase?: number;
|
|
43
|
+
ropeFrequencyScale?: number;
|
|
31
44
|
temperature?: number;
|
|
32
45
|
stop?: string[];
|
|
33
46
|
tfsZ?: number;
|
|
34
47
|
topK?: number;
|
|
35
48
|
topP?: number;
|
|
49
|
+
typicalP?: number;
|
|
50
|
+
useMLock?: boolean;
|
|
51
|
+
useMMap?: boolean;
|
|
52
|
+
vocabOnly?: boolean;
|
|
36
53
|
constructor(fields: OllamaInput & BaseChatModelParams);
|
|
37
54
|
_llmType(): string;
|
|
38
55
|
/**
|
|
@@ -44,19 +61,36 @@ export declare class ChatOllama extends SimpleChatModel implements OllamaInput {
|
|
|
44
61
|
invocationParams(options?: this["ParsedCallOptions"]): {
|
|
45
62
|
model: string;
|
|
46
63
|
options: {
|
|
64
|
+
embedding_only: boolean | undefined;
|
|
65
|
+
f16_kv: boolean | undefined;
|
|
66
|
+
frequency_penalty: number | undefined;
|
|
67
|
+
logits_all: boolean | undefined;
|
|
68
|
+
low_vram: boolean | undefined;
|
|
69
|
+
main_gpu: number | undefined;
|
|
47
70
|
mirostat: number | undefined;
|
|
48
71
|
mirostat_eta: number | undefined;
|
|
49
72
|
mirostat_tau: number | undefined;
|
|
73
|
+
num_batch: number | undefined;
|
|
50
74
|
num_ctx: number | undefined;
|
|
51
75
|
num_gpu: number | undefined;
|
|
76
|
+
num_gqa: number | undefined;
|
|
77
|
+
num_keep: number | undefined;
|
|
52
78
|
num_thread: number | undefined;
|
|
79
|
+
penalize_newline: boolean | undefined;
|
|
80
|
+
presence_penalty: number | undefined;
|
|
53
81
|
repeat_last_n: number | undefined;
|
|
54
82
|
repeat_penalty: number | undefined;
|
|
83
|
+
rope_frequency_base: number | undefined;
|
|
84
|
+
rope_frequency_scale: number | undefined;
|
|
55
85
|
temperature: number | undefined;
|
|
56
86
|
stop: string[] | undefined;
|
|
57
87
|
tfs_z: number | undefined;
|
|
58
88
|
top_k: number | undefined;
|
|
59
89
|
top_p: number | undefined;
|
|
90
|
+
typical_p: number | undefined;
|
|
91
|
+
use_mlock: boolean | undefined;
|
|
92
|
+
use_mmap: boolean | undefined;
|
|
93
|
+
vocab_only: boolean | undefined;
|
|
60
94
|
};
|
|
61
95
|
};
|
|
62
96
|
_combineLLMOutput(): {};
|
|
@@ -30,6 +30,42 @@ export class ChatOllama extends SimpleChatModel {
|
|
|
30
30
|
writable: true,
|
|
31
31
|
value: "http://localhost:11434"
|
|
32
32
|
});
|
|
33
|
+
Object.defineProperty(this, "embeddingOnly", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true,
|
|
37
|
+
value: void 0
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(this, "f16KV", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
configurable: true,
|
|
42
|
+
writable: true,
|
|
43
|
+
value: void 0
|
|
44
|
+
});
|
|
45
|
+
Object.defineProperty(this, "frequencyPenalty", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
configurable: true,
|
|
48
|
+
writable: true,
|
|
49
|
+
value: void 0
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(this, "logitsAll", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
configurable: true,
|
|
54
|
+
writable: true,
|
|
55
|
+
value: void 0
|
|
56
|
+
});
|
|
57
|
+
Object.defineProperty(this, "lowVram", {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
configurable: true,
|
|
60
|
+
writable: true,
|
|
61
|
+
value: void 0
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(this, "mainGpu", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
configurable: true,
|
|
66
|
+
writable: true,
|
|
67
|
+
value: void 0
|
|
68
|
+
});
|
|
33
69
|
Object.defineProperty(this, "mirostat", {
|
|
34
70
|
enumerable: true,
|
|
35
71
|
configurable: true,
|
|
@@ -48,6 +84,12 @@ export class ChatOllama extends SimpleChatModel {
|
|
|
48
84
|
writable: true,
|
|
49
85
|
value: void 0
|
|
50
86
|
});
|
|
87
|
+
Object.defineProperty(this, "numBatch", {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
configurable: true,
|
|
90
|
+
writable: true,
|
|
91
|
+
value: void 0
|
|
92
|
+
});
|
|
51
93
|
Object.defineProperty(this, "numCtx", {
|
|
52
94
|
enumerable: true,
|
|
53
95
|
configurable: true,
|
|
@@ -60,12 +102,36 @@ export class ChatOllama extends SimpleChatModel {
|
|
|
60
102
|
writable: true,
|
|
61
103
|
value: void 0
|
|
62
104
|
});
|
|
105
|
+
Object.defineProperty(this, "numGqa", {
|
|
106
|
+
enumerable: true,
|
|
107
|
+
configurable: true,
|
|
108
|
+
writable: true,
|
|
109
|
+
value: void 0
|
|
110
|
+
});
|
|
111
|
+
Object.defineProperty(this, "numKeep", {
|
|
112
|
+
enumerable: true,
|
|
113
|
+
configurable: true,
|
|
114
|
+
writable: true,
|
|
115
|
+
value: void 0
|
|
116
|
+
});
|
|
63
117
|
Object.defineProperty(this, "numThread", {
|
|
64
118
|
enumerable: true,
|
|
65
119
|
configurable: true,
|
|
66
120
|
writable: true,
|
|
67
121
|
value: void 0
|
|
68
122
|
});
|
|
123
|
+
Object.defineProperty(this, "penalizeNewline", {
|
|
124
|
+
enumerable: true,
|
|
125
|
+
configurable: true,
|
|
126
|
+
writable: true,
|
|
127
|
+
value: void 0
|
|
128
|
+
});
|
|
129
|
+
Object.defineProperty(this, "presencePenalty", {
|
|
130
|
+
enumerable: true,
|
|
131
|
+
configurable: true,
|
|
132
|
+
writable: true,
|
|
133
|
+
value: void 0
|
|
134
|
+
});
|
|
69
135
|
Object.defineProperty(this, "repeatLastN", {
|
|
70
136
|
enumerable: true,
|
|
71
137
|
configurable: true,
|
|
@@ -78,6 +144,18 @@ export class ChatOllama extends SimpleChatModel {
|
|
|
78
144
|
writable: true,
|
|
79
145
|
value: void 0
|
|
80
146
|
});
|
|
147
|
+
Object.defineProperty(this, "ropeFrequencyBase", {
|
|
148
|
+
enumerable: true,
|
|
149
|
+
configurable: true,
|
|
150
|
+
writable: true,
|
|
151
|
+
value: void 0
|
|
152
|
+
});
|
|
153
|
+
Object.defineProperty(this, "ropeFrequencyScale", {
|
|
154
|
+
enumerable: true,
|
|
155
|
+
configurable: true,
|
|
156
|
+
writable: true,
|
|
157
|
+
value: void 0
|
|
158
|
+
});
|
|
81
159
|
Object.defineProperty(this, "temperature", {
|
|
82
160
|
enumerable: true,
|
|
83
161
|
configurable: true,
|
|
@@ -108,23 +186,64 @@ export class ChatOllama extends SimpleChatModel {
|
|
|
108
186
|
writable: true,
|
|
109
187
|
value: void 0
|
|
110
188
|
});
|
|
189
|
+
Object.defineProperty(this, "typicalP", {
|
|
190
|
+
enumerable: true,
|
|
191
|
+
configurable: true,
|
|
192
|
+
writable: true,
|
|
193
|
+
value: void 0
|
|
194
|
+
});
|
|
195
|
+
Object.defineProperty(this, "useMLock", {
|
|
196
|
+
enumerable: true,
|
|
197
|
+
configurable: true,
|
|
198
|
+
writable: true,
|
|
199
|
+
value: void 0
|
|
200
|
+
});
|
|
201
|
+
Object.defineProperty(this, "useMMap", {
|
|
202
|
+
enumerable: true,
|
|
203
|
+
configurable: true,
|
|
204
|
+
writable: true,
|
|
205
|
+
value: void 0
|
|
206
|
+
});
|
|
207
|
+
Object.defineProperty(this, "vocabOnly", {
|
|
208
|
+
enumerable: true,
|
|
209
|
+
configurable: true,
|
|
210
|
+
writable: true,
|
|
211
|
+
value: void 0
|
|
212
|
+
});
|
|
111
213
|
this.model = fields.model ?? this.model;
|
|
112
214
|
this.baseUrl = fields.baseUrl?.endsWith("/")
|
|
113
215
|
? fields.baseUrl.slice(0, -1)
|
|
114
216
|
: fields.baseUrl ?? this.baseUrl;
|
|
217
|
+
this.embeddingOnly = fields.embeddingOnly;
|
|
218
|
+
this.f16KV = fields.f16KV;
|
|
219
|
+
this.frequencyPenalty = fields.frequencyPenalty;
|
|
220
|
+
this.logitsAll = fields.logitsAll;
|
|
221
|
+
this.lowVram = fields.lowVram;
|
|
222
|
+
this.mainGpu = fields.mainGpu;
|
|
115
223
|
this.mirostat = fields.mirostat;
|
|
116
224
|
this.mirostatEta = fields.mirostatEta;
|
|
117
225
|
this.mirostatTau = fields.mirostatTau;
|
|
226
|
+
this.numBatch = fields.numBatch;
|
|
118
227
|
this.numCtx = fields.numCtx;
|
|
119
228
|
this.numGpu = fields.numGpu;
|
|
229
|
+
this.numGqa = fields.numGqa;
|
|
230
|
+
this.numKeep = fields.numKeep;
|
|
120
231
|
this.numThread = fields.numThread;
|
|
232
|
+
this.penalizeNewline = fields.penalizeNewline;
|
|
233
|
+
this.presencePenalty = fields.presencePenalty;
|
|
121
234
|
this.repeatLastN = fields.repeatLastN;
|
|
122
235
|
this.repeatPenalty = fields.repeatPenalty;
|
|
236
|
+
this.ropeFrequencyBase = fields.ropeFrequencyBase;
|
|
237
|
+
this.ropeFrequencyScale = fields.ropeFrequencyScale;
|
|
123
238
|
this.temperature = fields.temperature;
|
|
124
239
|
this.stop = fields.stop;
|
|
125
240
|
this.tfsZ = fields.tfsZ;
|
|
126
241
|
this.topK = fields.topK;
|
|
127
242
|
this.topP = fields.topP;
|
|
243
|
+
this.typicalP = fields.typicalP;
|
|
244
|
+
this.useMLock = fields.useMLock;
|
|
245
|
+
this.useMMap = fields.useMMap;
|
|
246
|
+
this.vocabOnly = fields.vocabOnly;
|
|
128
247
|
}
|
|
129
248
|
_llmType() {
|
|
130
249
|
return "ollama";
|
|
@@ -139,19 +258,36 @@ export class ChatOllama extends SimpleChatModel {
|
|
|
139
258
|
return {
|
|
140
259
|
model: this.model,
|
|
141
260
|
options: {
|
|
261
|
+
embedding_only: this.embeddingOnly,
|
|
262
|
+
f16_kv: this.f16KV,
|
|
263
|
+
frequency_penalty: this.frequencyPenalty,
|
|
264
|
+
logits_all: this.logitsAll,
|
|
265
|
+
low_vram: this.lowVram,
|
|
266
|
+
main_gpu: this.mainGpu,
|
|
142
267
|
mirostat: this.mirostat,
|
|
143
268
|
mirostat_eta: this.mirostatEta,
|
|
144
269
|
mirostat_tau: this.mirostatTau,
|
|
270
|
+
num_batch: this.numBatch,
|
|
145
271
|
num_ctx: this.numCtx,
|
|
146
272
|
num_gpu: this.numGpu,
|
|
273
|
+
num_gqa: this.numGqa,
|
|
274
|
+
num_keep: this.numKeep,
|
|
147
275
|
num_thread: this.numThread,
|
|
276
|
+
penalize_newline: this.penalizeNewline,
|
|
277
|
+
presence_penalty: this.presencePenalty,
|
|
148
278
|
repeat_last_n: this.repeatLastN,
|
|
149
279
|
repeat_penalty: this.repeatPenalty,
|
|
280
|
+
rope_frequency_base: this.ropeFrequencyBase,
|
|
281
|
+
rope_frequency_scale: this.ropeFrequencyScale,
|
|
150
282
|
temperature: this.temperature,
|
|
151
283
|
stop: options?.stop ?? this.stop,
|
|
152
284
|
tfs_z: this.tfsZ,
|
|
153
285
|
top_k: this.topK,
|
|
154
286
|
top_p: this.topP,
|
|
287
|
+
typical_p: this.typicalP,
|
|
288
|
+
use_mlock: this.useMLock,
|
|
289
|
+
use_mmap: this.useMMap,
|
|
290
|
+
vocab_only: this.vocabOnly,
|
|
155
291
|
},
|
|
156
292
|
};
|
|
157
293
|
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MinimaxEmbeddings = void 0;
|
|
4
|
+
const env_js_1 = require("../util/env.cjs");
|
|
5
|
+
const chunk_js_1 = require("../util/chunk.cjs");
|
|
6
|
+
const base_js_1 = require("./base.cjs");
|
|
7
|
+
/**
|
|
8
|
+
* Class for generating embeddings using the Minimax API. Extends the
|
|
9
|
+
* Embeddings class and implements MinimaxEmbeddingsParams
|
|
10
|
+
*/
|
|
11
|
+
class MinimaxEmbeddings extends base_js_1.Embeddings {
|
|
12
|
+
constructor(fields) {
|
|
13
|
+
const fieldsWithDefaults = { maxConcurrency: 2, ...fields };
|
|
14
|
+
super(fieldsWithDefaults);
|
|
15
|
+
Object.defineProperty(this, "modelName", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true,
|
|
19
|
+
value: "embo-01"
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(this, "batchSize", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
value: 512
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(this, "stripNewLines", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
configurable: true,
|
|
30
|
+
writable: true,
|
|
31
|
+
value: true
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(this, "minimaxGroupId", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true,
|
|
37
|
+
value: void 0
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(this, "minimaxApiKey", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
configurable: true,
|
|
42
|
+
writable: true,
|
|
43
|
+
value: void 0
|
|
44
|
+
});
|
|
45
|
+
Object.defineProperty(this, "type", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
configurable: true,
|
|
48
|
+
writable: true,
|
|
49
|
+
value: "db"
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(this, "apiUrl", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
configurable: true,
|
|
54
|
+
writable: true,
|
|
55
|
+
value: void 0
|
|
56
|
+
});
|
|
57
|
+
Object.defineProperty(this, "basePath", {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
configurable: true,
|
|
60
|
+
writable: true,
|
|
61
|
+
value: "https://api.minimax.chat/v1"
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(this, "headers", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
configurable: true,
|
|
66
|
+
writable: true,
|
|
67
|
+
value: void 0
|
|
68
|
+
});
|
|
69
|
+
this.minimaxGroupId =
|
|
70
|
+
fields?.minimaxGroupId ?? (0, env_js_1.getEnvironmentVariable)("MINIMAX_GROUP_ID");
|
|
71
|
+
if (!this.minimaxGroupId) {
|
|
72
|
+
throw new Error("Minimax GroupID not found");
|
|
73
|
+
}
|
|
74
|
+
this.minimaxApiKey =
|
|
75
|
+
fields?.minimaxApiKey ?? (0, env_js_1.getEnvironmentVariable)("MINIMAX_API_KEY");
|
|
76
|
+
if (!this.minimaxApiKey) {
|
|
77
|
+
throw new Error("Minimax ApiKey not found");
|
|
78
|
+
}
|
|
79
|
+
this.modelName = fieldsWithDefaults?.modelName ?? this.modelName;
|
|
80
|
+
this.batchSize = fieldsWithDefaults?.batchSize ?? this.batchSize;
|
|
81
|
+
this.type = fieldsWithDefaults?.type ?? this.type;
|
|
82
|
+
this.stripNewLines =
|
|
83
|
+
fieldsWithDefaults?.stripNewLines ?? this.stripNewLines;
|
|
84
|
+
this.apiUrl = `${this.basePath}/embeddings`;
|
|
85
|
+
this.basePath = fields?.configuration?.basePath ?? this.basePath;
|
|
86
|
+
this.headers = fields?.configuration?.headers ?? this.headers;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Method to generate embeddings for an array of documents. Splits the
|
|
90
|
+
* documents into batches and makes requests to the Minimax API to generate
|
|
91
|
+
* embeddings.
|
|
92
|
+
* @param texts Array of documents to generate embeddings for.
|
|
93
|
+
* @returns Promise that resolves to a 2D array of embeddings for each document.
|
|
94
|
+
*/
|
|
95
|
+
async embedDocuments(texts) {
|
|
96
|
+
const batches = (0, chunk_js_1.chunkArray)(this.stripNewLines ? texts.map((t) => t.replace(/\n/g, " ")) : texts, this.batchSize);
|
|
97
|
+
const batchRequests = batches.map((batch) => this.embeddingWithRetry({
|
|
98
|
+
model: this.modelName,
|
|
99
|
+
texts: batch,
|
|
100
|
+
type: this.type,
|
|
101
|
+
}));
|
|
102
|
+
const batchResponses = await Promise.all(batchRequests);
|
|
103
|
+
const embeddings = [];
|
|
104
|
+
for (let i = 0; i < batchResponses.length; i += 1) {
|
|
105
|
+
const batch = batches[i];
|
|
106
|
+
const { vectors: batchResponse } = batchResponses[i];
|
|
107
|
+
for (let j = 0; j < batch.length; j += 1) {
|
|
108
|
+
embeddings.push(batchResponse[j]);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return embeddings;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Method to generate an embedding for a single document. Calls the
|
|
115
|
+
* embeddingWithRetry method with the document as the input.
|
|
116
|
+
* @param text Document to generate an embedding for.
|
|
117
|
+
* @returns Promise that resolves to an embedding for the document.
|
|
118
|
+
*/
|
|
119
|
+
async embedQuery(text) {
|
|
120
|
+
const { vectors } = await this.embeddingWithRetry({
|
|
121
|
+
model: this.modelName,
|
|
122
|
+
texts: [this.stripNewLines ? text.replace(/\n/g, " ") : text],
|
|
123
|
+
type: this.type,
|
|
124
|
+
});
|
|
125
|
+
return vectors[0];
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Private method to make a request to the Minimax API to generate
|
|
129
|
+
* embeddings. Handles the retry logic and returns the response from the
|
|
130
|
+
* API.
|
|
131
|
+
* @param request Request to send to the Minimax API.
|
|
132
|
+
* @returns Promise that resolves to the response from the API.
|
|
133
|
+
*/
|
|
134
|
+
async embeddingWithRetry(request) {
|
|
135
|
+
const makeCompletionRequest = async () => {
|
|
136
|
+
const url = `${this.apiUrl}?GroupId=${this.minimaxGroupId}`;
|
|
137
|
+
const response = await fetch(url, {
|
|
138
|
+
method: "POST",
|
|
139
|
+
headers: {
|
|
140
|
+
"Content-Type": "application/json",
|
|
141
|
+
Authorization: `Bearer ${this.minimaxApiKey}`,
|
|
142
|
+
...this.headers,
|
|
143
|
+
},
|
|
144
|
+
body: JSON.stringify(request),
|
|
145
|
+
});
|
|
146
|
+
const json = await response.json();
|
|
147
|
+
return json;
|
|
148
|
+
};
|
|
149
|
+
return this.caller.call(makeCompletionRequest);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports.MinimaxEmbeddings = MinimaxEmbeddings;
|