@langchain/core 0.1.20 → 0.1.22
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/agents.d.cts +1 -0
- package/caches.d.cts +1 -0
- package/callbacks/base.d.cts +1 -0
- package/callbacks/manager.d.cts +1 -0
- package/callbacks/promises.d.cts +1 -0
- package/chat_history.d.cts +1 -0
- package/dist/load/import_type.cjs +3 -0
- package/dist/load/import_type.d.ts +4 -0
- package/dist/load/import_type.js +2 -0
- package/dist/messages/index.cjs +3 -0
- package/dist/messages/index.d.ts +5 -2
- package/dist/messages/index.js +3 -0
- package/dist/prompt_values.cjs +62 -1
- package/dist/prompt_values.d.ts +25 -0
- package/dist/prompt_values.js +60 -0
- package/dist/prompts/chat.cjs +235 -27
- package/dist/prompts/chat.d.ts +35 -10
- package/dist/prompts/chat.js +235 -27
- package/dist/prompts/image.cjs +115 -0
- package/dist/prompts/image.d.ts +56 -0
- package/dist/prompts/image.js +111 -0
- package/dist/prompts/prompt.d.ts +3 -2
- package/dist/prompts/serde.d.ts +2 -1
- package/dist/prompts/template.cjs +22 -1
- package/dist/prompts/template.d.ts +2 -1
- package/dist/prompts/template.js +22 -1
- package/dist/runnables/base.cjs +6 -5
- package/dist/runnables/base.d.ts +3 -3
- package/dist/runnables/base.js +6 -5
- package/dist/utils/stream.cjs +3 -0
- package/dist/utils/stream.js +3 -0
- package/documents.d.cts +1 -0
- package/embeddings.d.cts +1 -0
- package/example_selectors.d.cts +1 -0
- package/language_models/base.d.cts +1 -0
- package/language_models/chat_models.d.cts +1 -0
- package/language_models/llms.d.cts +1 -0
- package/load/serializable.d.cts +1 -0
- package/load.d.cts +1 -0
- package/memory.d.cts +1 -0
- package/messages.d.cts +1 -0
- package/output_parsers.d.cts +1 -0
- package/outputs.d.cts +1 -0
- package/package.json +268 -47
- package/prompt_values.d.cts +1 -0
- package/prompts.d.cts +1 -0
- package/retrievers.d.cts +1 -0
- package/runnables.d.cts +1 -0
- package/stores.d.cts +1 -0
- package/tools.d.cts +1 -0
- package/tracers/base.d.cts +1 -0
- package/tracers/console.d.cts +1 -0
- package/tracers/initialize.d.cts +1 -0
- package/tracers/log_stream.d.cts +1 -0
- package/tracers/run_collector.d.cts +1 -0
- package/tracers/tracer_langchain.d.cts +1 -0
- package/tracers/tracer_langchain_v1.d.cts +1 -0
- package/utils/async_caller.d.cts +1 -0
- package/utils/chunk_array.d.cts +1 -0
- package/utils/env.d.cts +1 -0
- package/utils/function_calling.d.cts +1 -0
- package/utils/hash.d.cts +1 -0
- package/utils/json_patch.d.cts +1 -0
- package/utils/json_schema.d.cts +1 -0
- package/utils/math.d.cts +1 -0
- package/utils/stream.d.cts +1 -0
- package/utils/testing.d.cts +1 -0
- package/utils/tiktoken.d.cts +1 -0
- package/utils/types.d.cts +1 -0
- package/vectorstores.d.cts +1 -0
package/dist/prompts/template.js
CHANGED
|
@@ -74,7 +74,28 @@ export const checkValidTemplate = (template, templateFormat, inputVariables) =>
|
|
|
74
74
|
acc[v] = "foo";
|
|
75
75
|
return acc;
|
|
76
76
|
}, {});
|
|
77
|
-
|
|
77
|
+
if (Array.isArray(template)) {
|
|
78
|
+
template.forEach((message) => {
|
|
79
|
+
if (message.type === "text") {
|
|
80
|
+
renderTemplate(message.text, templateFormat, dummyInputs);
|
|
81
|
+
}
|
|
82
|
+
else if (message.type === "image_url") {
|
|
83
|
+
if (typeof message.image_url === "string") {
|
|
84
|
+
renderTemplate(message.image_url, templateFormat, dummyInputs);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
const imageUrl = message.image_url.url;
|
|
88
|
+
renderTemplate(imageUrl, templateFormat, dummyInputs);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
throw new Error(`Invalid message template received. ${JSON.stringify(message, null, 2)}`);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
renderTemplate(template, templateFormat, dummyInputs);
|
|
98
|
+
}
|
|
78
99
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
100
|
}
|
|
80
101
|
catch (e) {
|
package/dist/runnables/base.cjs
CHANGED
|
@@ -370,9 +370,10 @@ class Runnable extends serializable_js_1.Serializable {
|
|
|
370
370
|
copiedCallbacks.inheritableHandlers.push(stream);
|
|
371
371
|
config.callbacks = copiedCallbacks;
|
|
372
372
|
}
|
|
373
|
-
const
|
|
373
|
+
const runnableStreamPromise = this.stream(input, config);
|
|
374
374
|
async function consumeRunnableStream() {
|
|
375
375
|
try {
|
|
376
|
+
const runnableStream = await runnableStreamPromise;
|
|
376
377
|
for await (const chunk of runnableStream) {
|
|
377
378
|
const patch = new log_stream_js_1.RunLogPatch({
|
|
378
379
|
ops: [
|
|
@@ -390,14 +391,14 @@ class Runnable extends serializable_js_1.Serializable {
|
|
|
390
391
|
await stream.writer.close();
|
|
391
392
|
}
|
|
392
393
|
}
|
|
393
|
-
const
|
|
394
|
+
const runnableStreamConsumePromise = consumeRunnableStream();
|
|
394
395
|
try {
|
|
395
396
|
for await (const log of stream) {
|
|
396
397
|
yield log;
|
|
397
398
|
}
|
|
398
399
|
}
|
|
399
400
|
finally {
|
|
400
|
-
await
|
|
401
|
+
await runnableStreamConsumePromise;
|
|
401
402
|
}
|
|
402
403
|
}
|
|
403
404
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1083,7 +1084,7 @@ class RunnableLambda extends Runnable {
|
|
|
1083
1084
|
});
|
|
1084
1085
|
}
|
|
1085
1086
|
async _invoke(input, config, runManager) {
|
|
1086
|
-
let output = await this.func(input, { config });
|
|
1087
|
+
let output = await this.func(input, { ...config, config });
|
|
1087
1088
|
if (output && Runnable.isRunnable(output)) {
|
|
1088
1089
|
if (config?.recursionLimit === 0) {
|
|
1089
1090
|
throw new Error("Recursion limit reached.");
|
|
@@ -1115,7 +1116,7 @@ class RunnableLambda extends Runnable {
|
|
|
1115
1116
|
}
|
|
1116
1117
|
}
|
|
1117
1118
|
}
|
|
1118
|
-
const output = await this.func(finalChunk, { config });
|
|
1119
|
+
const output = await this.func(finalChunk, { ...config, config });
|
|
1119
1120
|
if (output && Runnable.isRunnable(output)) {
|
|
1120
1121
|
if (config?.recursionLimit === 0) {
|
|
1121
1122
|
throw new Error("Recursion limit reached.");
|
package/dist/runnables/base.d.ts
CHANGED
|
@@ -23,11 +23,11 @@ export interface RunnableInterface<RunInput = any, RunOutput = any, CallOptions
|
|
|
23
23
|
stream(input: RunInput, options?: Partial<CallOptions>): Promise<IterableReadableStreamInterface<RunOutput>>;
|
|
24
24
|
transform(generator: AsyncGenerator<RunInput>, options: Partial<CallOptions>): AsyncGenerator<RunOutput>;
|
|
25
25
|
}
|
|
26
|
-
export type RunnableFunc<RunInput, RunOutput> = (input: RunInput, options?: {
|
|
26
|
+
export type RunnableFunc<RunInput, RunOutput> = (input: RunInput, options?: ({
|
|
27
27
|
config?: RunnableConfig;
|
|
28
|
-
} | Record<string, any> | (Record<string, any> & {
|
|
28
|
+
} & RunnableConfig) | Record<string, any> | (Record<string, any> & {
|
|
29
29
|
config: RunnableConfig;
|
|
30
|
-
})) => RunOutput | Promise<RunOutput>;
|
|
30
|
+
} & RunnableConfig)) => RunOutput | Promise<RunOutput>;
|
|
31
31
|
export type RunnableMapLike<RunInput, RunOutput> = {
|
|
32
32
|
[K in keyof RunOutput]: RunnableLike<RunInput, RunOutput[K]>;
|
|
33
33
|
};
|
package/dist/runnables/base.js
CHANGED
|
@@ -363,9 +363,10 @@ export class Runnable extends Serializable {
|
|
|
363
363
|
copiedCallbacks.inheritableHandlers.push(stream);
|
|
364
364
|
config.callbacks = copiedCallbacks;
|
|
365
365
|
}
|
|
366
|
-
const
|
|
366
|
+
const runnableStreamPromise = this.stream(input, config);
|
|
367
367
|
async function consumeRunnableStream() {
|
|
368
368
|
try {
|
|
369
|
+
const runnableStream = await runnableStreamPromise;
|
|
369
370
|
for await (const chunk of runnableStream) {
|
|
370
371
|
const patch = new RunLogPatch({
|
|
371
372
|
ops: [
|
|
@@ -383,14 +384,14 @@ export class Runnable extends Serializable {
|
|
|
383
384
|
await stream.writer.close();
|
|
384
385
|
}
|
|
385
386
|
}
|
|
386
|
-
const
|
|
387
|
+
const runnableStreamConsumePromise = consumeRunnableStream();
|
|
387
388
|
try {
|
|
388
389
|
for await (const log of stream) {
|
|
389
390
|
yield log;
|
|
390
391
|
}
|
|
391
392
|
}
|
|
392
393
|
finally {
|
|
393
|
-
await
|
|
394
|
+
await runnableStreamConsumePromise;
|
|
394
395
|
}
|
|
395
396
|
}
|
|
396
397
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1070,7 +1071,7 @@ export class RunnableLambda extends Runnable {
|
|
|
1070
1071
|
});
|
|
1071
1072
|
}
|
|
1072
1073
|
async _invoke(input, config, runManager) {
|
|
1073
|
-
let output = await this.func(input, { config });
|
|
1074
|
+
let output = await this.func(input, { ...config, config });
|
|
1074
1075
|
if (output && Runnable.isRunnable(output)) {
|
|
1075
1076
|
if (config?.recursionLimit === 0) {
|
|
1076
1077
|
throw new Error("Recursion limit reached.");
|
|
@@ -1102,7 +1103,7 @@ export class RunnableLambda extends Runnable {
|
|
|
1102
1103
|
}
|
|
1103
1104
|
}
|
|
1104
1105
|
}
|
|
1105
|
-
const output = await this.func(finalChunk, { config });
|
|
1106
|
+
const output = await this.func(finalChunk, { ...config, config });
|
|
1106
1107
|
if (output && Runnable.isRunnable(output)) {
|
|
1107
1108
|
if (config?.recursionLimit === 0) {
|
|
1108
1109
|
throw new Error("Recursion limit reached.");
|
package/dist/utils/stream.cjs
CHANGED
|
@@ -101,6 +101,9 @@ class IterableReadableStream extends ReadableStream {
|
|
|
101
101
|
// Fix: `else if (value)` will hang the streaming when nullish value (e.g. empty string) is pulled
|
|
102
102
|
controller.enqueue(value);
|
|
103
103
|
},
|
|
104
|
+
async cancel(reason) {
|
|
105
|
+
await generator.return(reason);
|
|
106
|
+
},
|
|
104
107
|
});
|
|
105
108
|
}
|
|
106
109
|
}
|
package/dist/utils/stream.js
CHANGED
|
@@ -98,6 +98,9 @@ export class IterableReadableStream extends ReadableStream {
|
|
|
98
98
|
// Fix: `else if (value)` will hang the streaming when nullish value (e.g. empty string) is pulled
|
|
99
99
|
controller.enqueue(value);
|
|
100
100
|
},
|
|
101
|
+
async cancel(reason) {
|
|
102
|
+
await generator.return(reason);
|
|
103
|
+
},
|
|
101
104
|
});
|
|
102
105
|
}
|
|
103
106
|
}
|
package/documents.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/documents/index.js'
|
package/embeddings.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/embeddings.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/example_selectors/index.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/language_models/base.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/language_models/chat_models.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/language_models/llms.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/load/serializable.js'
|
package/load.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/load/index.js'
|
package/memory.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/memory.js'
|
package/messages.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/messages/index.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/output_parsers/index.js'
|
package/outputs.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/outputs.js'
|