langchain 0.0.195 → 0.0.197-rc.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/LICENSE +21 -0
- package/dist/agents/openai/index.cjs +6 -2
- package/dist/agents/openai/index.js +6 -2
- package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.d.ts +1 -1
- package/dist/base_language/count_tokens.cjs +5 -70
- package/dist/base_language/count_tokens.d.ts +1 -10
- package/dist/base_language/count_tokens.js +1 -65
- package/dist/base_language/index.cjs +6 -196
- package/dist/base_language/index.d.ts +1 -111
- package/dist/base_language/index.js +1 -191
- package/dist/cache/base.cjs +15 -37
- package/dist/cache/base.d.ts +1 -20
- package/dist/cache/base.js +1 -33
- package/dist/cache/index.cjs +2 -46
- package/dist/cache/index.d.ts +1 -29
- package/dist/cache/index.js +1 -45
- package/dist/callbacks/base.cjs +3 -139
- package/dist/callbacks/base.d.ts +1 -266
- package/dist/callbacks/base.js +1 -126
- package/dist/callbacks/handlers/console.cjs +14 -221
- package/dist/callbacks/handlers/console.d.ts +1 -117
- package/dist/callbacks/handlers/console.js +1 -217
- package/dist/callbacks/handlers/initialize.cjs +15 -30
- package/dist/callbacks/handlers/initialize.d.ts +1 -16
- package/dist/callbacks/handlers/initialize.js +1 -27
- package/dist/callbacks/handlers/log_stream.cjs +15 -293
- package/dist/callbacks/handlers/log_stream.d.ts +1 -100
- package/dist/callbacks/handlers/log_stream.js +1 -289
- package/dist/callbacks/handlers/run_collector.cjs +15 -48
- package/dist/callbacks/handlers/run_collector.d.ts +1 -26
- package/dist/callbacks/handlers/run_collector.js +1 -46
- package/dist/callbacks/handlers/tracer.cjs +15 -375
- package/dist/callbacks/handlers/tracer.d.ts +1 -70
- package/dist/callbacks/handlers/tracer.js +1 -373
- package/dist/callbacks/handlers/tracer_langchain.cjs +15 -104
- package/dist/callbacks/handlers/tracer_langchain.d.ts +1 -41
- package/dist/callbacks/handlers/tracer_langchain.js +1 -102
- package/dist/callbacks/handlers/tracer_langchain_v1.cjs +15 -197
- package/dist/callbacks/handlers/tracer_langchain_v1.d.ts +1 -57
- package/dist/callbacks/handlers/tracer_langchain_v1.js +1 -195
- package/dist/callbacks/manager.cjs +15 -676
- package/dist/callbacks/manager.d.ts +1 -180
- package/dist/callbacks/manager.js +1 -666
- package/dist/callbacks/promises.cjs +14 -42
- package/dist/callbacks/promises.d.ts +1 -11
- package/dist/callbacks/promises.js +1 -37
- package/dist/chains/graph_qa/prompts.d.ts +1 -1
- package/dist/chains/openai_functions/structured_output.cjs +2 -2
- package/dist/chains/openai_functions/structured_output.d.ts +1 -1
- package/dist/chains/openai_functions/structured_output.js +1 -1
- package/dist/chat_models/anthropic.cjs +15 -348
- package/dist/chat_models/anthropic.d.ts +1 -156
- package/dist/chat_models/anthropic.js +1 -346
- package/dist/chat_models/baiduwenxin.d.ts +1 -1
- package/dist/chat_models/base.cjs +15 -296
- package/dist/chat_models/base.d.ts +1 -122
- package/dist/chat_models/base.js +1 -292
- package/dist/chat_models/bedrock/web.cjs +21 -1
- package/dist/chat_models/bedrock/web.d.ts +2 -2
- package/dist/chat_models/bedrock/web.js +21 -1
- package/dist/chat_models/fireworks.d.ts +1 -1
- package/dist/document.cjs +2 -24
- package/dist/document.d.ts +1 -12
- package/dist/document.js +1 -23
- package/dist/document_loaders/web/azure_blob_storage_file.d.ts +1 -1
- package/dist/document_loaders/web/github.cjs +105 -0
- package/dist/document_loaders/web/github.d.ts +26 -0
- package/dist/document_loaders/web/github.js +105 -0
- package/dist/document_loaders/web/s3.d.ts +1 -1
- package/dist/embeddings/base.cjs +15 -22
- package/dist/embeddings/base.d.ts +1 -33
- package/dist/embeddings/base.js +1 -20
- package/dist/embeddings/cache_backed.cjs +2 -2
- package/dist/embeddings/cache_backed.js +1 -1
- package/dist/evaluation/agents/trajectory.d.ts +1 -1
- package/dist/evaluation/criteria/prompt.d.ts +2 -2
- package/dist/evaluation/qa/prompt.d.ts +2 -2
- package/dist/experimental/hubs/makersuite/googlemakersuitehub.d.ts +1 -1
- package/dist/experimental/plan_and_execute/prompt.d.ts +1 -1
- package/dist/llms/base.cjs +15 -278
- package/dist/llms/base.d.ts +1 -115
- package/dist/llms/base.js +1 -275
- package/dist/llms/bedrock/web.cjs +21 -1
- package/dist/llms/bedrock/web.d.ts +2 -2
- package/dist/llms/bedrock/web.js +21 -1
- package/dist/llms/fireworks.d.ts +1 -1
- package/dist/load/import_map.cjs +2 -1
- package/dist/load/import_map.d.ts +1 -0
- package/dist/load/import_map.js +1 -0
- package/dist/load/index.cjs +7 -148
- package/dist/load/index.js +7 -148
- package/dist/load/map_keys.cjs +0 -24
- package/dist/load/map_keys.d.ts +0 -6
- package/dist/load/map_keys.js +1 -17
- package/dist/load/serializable.cjs +15 -178
- package/dist/load/serializable.d.ts +1 -66
- package/dist/load/serializable.js +1 -175
- package/dist/memory/base.cjs +17 -92
- package/dist/memory/base.d.ts +2 -68
- package/dist/memory/base.js +2 -87
- package/dist/output_parsers/list.cjs +4 -122
- package/dist/output_parsers/list.d.ts +1 -57
- package/dist/output_parsers/list.js +1 -119
- package/dist/output_parsers/openai_functions.cjs +2 -2
- package/dist/output_parsers/openai_functions.d.ts +1 -1
- package/dist/output_parsers/openai_functions.js +1 -1
- package/dist/output_parsers/regex.d.ts +1 -1
- package/dist/output_parsers/structured.d.ts +1 -1
- package/dist/prompts/base.cjs +8 -183
- package/dist/prompts/base.d.ts +3 -132
- package/dist/prompts/base.js +3 -178
- package/dist/prompts/chat.cjs +13 -477
- package/dist/prompts/chat.d.ts +2 -219
- package/dist/prompts/chat.js +2 -466
- package/dist/prompts/few_shot.cjs +3 -352
- package/dist/prompts/few_shot.d.ts +1 -192
- package/dist/prompts/few_shot.js +1 -350
- package/dist/prompts/index.cjs +3 -2
- package/dist/prompts/index.d.ts +2 -1
- package/dist/prompts/index.js +2 -1
- package/dist/prompts/pipeline.cjs +2 -141
- package/dist/prompts/pipeline.d.ts +1 -98
- package/dist/prompts/pipeline.js +1 -140
- package/dist/prompts/prompt.cjs +2 -145
- package/dist/prompts/prompt.d.ts +1 -92
- package/dist/prompts/prompt.js +1 -144
- package/dist/prompts/selectors/LengthBasedExampleSelector.cjs +2 -147
- package/dist/prompts/selectors/LengthBasedExampleSelector.d.ts +1 -89
- package/dist/prompts/selectors/LengthBasedExampleSelector.js +1 -146
- package/dist/prompts/selectors/SemanticSimilarityExampleSelector.cjs +15 -137
- package/dist/prompts/selectors/SemanticSimilarityExampleSelector.d.ts +1 -91
- package/dist/prompts/selectors/SemanticSimilarityExampleSelector.js +1 -135
- package/dist/prompts/selectors/conditional.cjs +5 -73
- package/dist/prompts/selectors/conditional.d.ts +1 -63
- package/dist/prompts/selectors/conditional.js +1 -69
- package/dist/prompts/serde.d.ts +1 -43
- package/dist/prompts/template.cjs +8 -88
- package/dist/prompts/template.d.ts +1 -36
- package/dist/prompts/template.js +1 -83
- package/dist/{util/@cfworker/json-schema → runnables}/index.cjs +1 -1
- package/dist/runnables/index.d.ts +1 -0
- package/dist/runnables/index.js +1 -0
- package/dist/schema/document.cjs +3 -34
- package/dist/schema/document.d.ts +2 -29
- package/dist/schema/document.js +2 -32
- package/dist/schema/index.cjs +37 -612
- package/dist/schema/index.d.ts +11 -311
- package/dist/schema/index.js +8 -583
- package/dist/schema/output_parser.cjs +15 -309
- package/dist/schema/output_parser.d.ts +1 -173
- package/dist/schema/output_parser.js +1 -301
- package/dist/schema/retriever.cjs +15 -77
- package/dist/schema/retriever.d.ts +1 -43
- package/dist/schema/retriever.js +1 -75
- package/dist/schema/runnable/base.cjs +10 -1072
- package/dist/schema/runnable/base.d.ts +1 -356
- package/dist/schema/runnable/base.js +1 -1060
- package/dist/schema/runnable/branch.cjs +2 -131
- package/dist/schema/runnable/branch.d.ts +1 -94
- package/dist/schema/runnable/branch.js +1 -130
- package/dist/schema/runnable/config.cjs +0 -6
- package/dist/schema/runnable/config.d.ts +1 -3
- package/dist/schema/runnable/config.js +1 -4
- package/dist/schema/runnable/index.cjs +15 -16
- package/dist/schema/runnable/index.d.ts +1 -5
- package/dist/schema/runnable/index.js +1 -4
- package/dist/schema/runnable/passthrough.cjs +3 -113
- package/dist/schema/runnable/passthrough.d.ts +1 -72
- package/dist/schema/runnable/passthrough.js +1 -111
- package/dist/schema/runnable/router.cjs +2 -71
- package/dist/schema/runnable/router.d.ts +1 -29
- package/dist/schema/runnable/router.js +1 -70
- package/dist/schema/storage.cjs +15 -8
- package/dist/schema/storage.d.ts +1 -57
- package/dist/schema/storage.js +1 -6
- package/dist/tools/bingserpapi.d.ts +1 -1
- package/dist/tools/searchapi.d.ts +1 -1
- package/dist/tools/serpapi.d.ts +1 -1
- package/dist/tools/serper.d.ts +1 -1
- package/dist/util/async_caller.cjs +14 -128
- package/dist/util/async_caller.d.ts +1 -45
- package/dist/util/async_caller.js +1 -124
- package/dist/vectorstores/momento_vector_index.cjs +39 -0
- package/dist/vectorstores/momento_vector_index.d.ts +17 -1
- package/dist/vectorstores/momento_vector_index.js +40 -1
- package/dist/vectorstores/mongodb_atlas.cjs +22 -2
- package/dist/vectorstores/mongodb_atlas.d.ts +13 -0
- package/dist/vectorstores/mongodb_atlas.js +22 -2
- package/package.json +18 -11
- package/runnables.cjs +1 -0
- package/runnables.d.ts +1 -0
- package/runnables.js +1 -0
- package/dist/util/@cfworker/json-schema/index.d.ts +0 -1
- package/dist/util/@cfworker/json-schema/index.js +0 -1
- package/dist/util/@cfworker/json-schema/src/deep-compare-strict.cjs +0 -43
- package/dist/util/@cfworker/json-schema/src/deep-compare-strict.d.ts +0 -1
- package/dist/util/@cfworker/json-schema/src/deep-compare-strict.js +0 -39
- package/dist/util/@cfworker/json-schema/src/dereference.cjs +0 -169
- package/dist/util/@cfworker/json-schema/src/dereference.d.ts +0 -12
- package/dist/util/@cfworker/json-schema/src/dereference.js +0 -165
- package/dist/util/@cfworker/json-schema/src/format.cjs +0 -139
- package/dist/util/@cfworker/json-schema/src/format.d.ts +0 -2
- package/dist/util/@cfworker/json-schema/src/format.js +0 -136
- package/dist/util/@cfworker/json-schema/src/index.cjs +0 -24
- package/dist/util/@cfworker/json-schema/src/index.d.ts +0 -8
- package/dist/util/@cfworker/json-schema/src/index.js +0 -8
- package/dist/util/@cfworker/json-schema/src/pointer.cjs +0 -11
- package/dist/util/@cfworker/json-schema/src/pointer.d.ts +0 -2
- package/dist/util/@cfworker/json-schema/src/pointer.js +0 -6
- package/dist/util/@cfworker/json-schema/src/types.cjs +0 -2
- package/dist/util/@cfworker/json-schema/src/types.d.ts +0 -72
- package/dist/util/@cfworker/json-schema/src/types.js +0 -1
- package/dist/util/@cfworker/json-schema/src/ucs2-length.cjs +0 -28
- package/dist/util/@cfworker/json-schema/src/ucs2-length.d.ts +0 -6
- package/dist/util/@cfworker/json-schema/src/ucs2-length.js +0 -24
- package/dist/util/@cfworker/json-schema/src/validate.cjs +0 -808
- package/dist/util/@cfworker/json-schema/src/validate.d.ts +0 -3
- package/dist/util/@cfworker/json-schema/src/validate.js +0 -804
- package/dist/util/@cfworker/json-schema/src/validator.cjs +0 -44
- package/dist/util/@cfworker/json-schema/src/validator.d.ts +0 -10
- package/dist/util/@cfworker/json-schema/src/validator.js +0 -40
- package/dist/util/fast-json-patch/index.cjs +0 -49
- package/dist/util/fast-json-patch/index.d.ts +0 -22
- package/dist/util/fast-json-patch/index.js +0 -16
- package/dist/util/fast-json-patch/src/core.cjs +0 -469
- package/dist/util/fast-json-patch/src/core.d.ts +0 -111
- package/dist/util/fast-json-patch/src/core.js +0 -459
- package/dist/util/fast-json-patch/src/duplex.cjs +0 -237
- package/dist/util/fast-json-patch/src/duplex.d.ts +0 -23
- package/dist/util/fast-json-patch/src/duplex.js +0 -230
- package/dist/util/fast-json-patch/src/helpers.cjs +0 -194
- package/dist/util/fast-json-patch/src/helpers.d.ts +0 -36
- package/dist/util/fast-json-patch/src/helpers.js +0 -181
- package/dist/util/js-sha1/hash.cjs +0 -358
- package/dist/util/js-sha1/hash.d.ts +0 -1
- package/dist/util/js-sha1/hash.js +0 -355
|
@@ -278,11 +278,31 @@ class Bedrock extends base_js_1.LLM {
|
|
|
278
278
|
}
|
|
279
279
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
280
280
|
_readChunks(reader) {
|
|
281
|
+
function _concatChunks(a, b) {
|
|
282
|
+
const newBuffer = new Uint8Array(a.length + b.length);
|
|
283
|
+
newBuffer.set(a);
|
|
284
|
+
newBuffer.set(b, a.length);
|
|
285
|
+
return newBuffer;
|
|
286
|
+
}
|
|
287
|
+
function getMessageLength(buffer) {
|
|
288
|
+
if (buffer.byteLength === 0)
|
|
289
|
+
return 0;
|
|
290
|
+
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
291
|
+
return view.getUint32(0, false);
|
|
292
|
+
}
|
|
281
293
|
return {
|
|
282
294
|
async *[Symbol.asyncIterator]() {
|
|
283
295
|
let readResult = await reader.read();
|
|
296
|
+
let buffer = new Uint8Array(0);
|
|
284
297
|
while (!readResult.done) {
|
|
285
|
-
|
|
298
|
+
const chunk = readResult.value;
|
|
299
|
+
buffer = _concatChunks(buffer, chunk);
|
|
300
|
+
let messageLength = getMessageLength(buffer);
|
|
301
|
+
while (buffer.byteLength > 0 && buffer.byteLength >= messageLength) {
|
|
302
|
+
yield buffer.slice(0, messageLength);
|
|
303
|
+
buffer = buffer.slice(messageLength);
|
|
304
|
+
messageLength = getMessageLength(buffer);
|
|
305
|
+
}
|
|
286
306
|
readResult = await reader.read();
|
|
287
307
|
}
|
|
288
308
|
},
|
|
@@ -3,7 +3,7 @@ import { BaseBedrockInput, type CredentialType } from "../../util/bedrock.js";
|
|
|
3
3
|
import { LLM, BaseLLMParams } from "../base.js";
|
|
4
4
|
import { CallbackManagerForLLMRun } from "../../callbacks/manager.js";
|
|
5
5
|
import { GenerationChunk } from "../../schema/index.js";
|
|
6
|
-
import { SerializedFields } from "../../load/map_keys.js";
|
|
6
|
+
import type { SerializedFields } from "../../load/map_keys.js";
|
|
7
7
|
/**
|
|
8
8
|
* A type of Large Language Model (LLM) that interacts with the Bedrock
|
|
9
9
|
* service. It extends the base `LLM` class and implements the
|
|
@@ -61,6 +61,6 @@ export declare class Bedrock extends LLM implements BaseBedrockInput {
|
|
|
61
61
|
};
|
|
62
62
|
_streamResponseChunks(prompt: string, options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<GenerationChunk>;
|
|
63
63
|
_readChunks(reader: any): {
|
|
64
|
-
[Symbol.asyncIterator](): AsyncGenerator<
|
|
64
|
+
[Symbol.asyncIterator](): AsyncGenerator<Uint8Array, void, unknown>;
|
|
65
65
|
};
|
|
66
66
|
}
|
package/dist/llms/bedrock/web.js
CHANGED
|
@@ -275,11 +275,31 @@ export class Bedrock extends LLM {
|
|
|
275
275
|
}
|
|
276
276
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
277
277
|
_readChunks(reader) {
|
|
278
|
+
function _concatChunks(a, b) {
|
|
279
|
+
const newBuffer = new Uint8Array(a.length + b.length);
|
|
280
|
+
newBuffer.set(a);
|
|
281
|
+
newBuffer.set(b, a.length);
|
|
282
|
+
return newBuffer;
|
|
283
|
+
}
|
|
284
|
+
function getMessageLength(buffer) {
|
|
285
|
+
if (buffer.byteLength === 0)
|
|
286
|
+
return 0;
|
|
287
|
+
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
288
|
+
return view.getUint32(0, false);
|
|
289
|
+
}
|
|
278
290
|
return {
|
|
279
291
|
async *[Symbol.asyncIterator]() {
|
|
280
292
|
let readResult = await reader.read();
|
|
293
|
+
let buffer = new Uint8Array(0);
|
|
281
294
|
while (!readResult.done) {
|
|
282
|
-
|
|
295
|
+
const chunk = readResult.value;
|
|
296
|
+
buffer = _concatChunks(buffer, chunk);
|
|
297
|
+
let messageLength = getMessageLength(buffer);
|
|
298
|
+
while (buffer.byteLength > 0 && buffer.byteLength >= messageLength) {
|
|
299
|
+
yield buffer.slice(0, messageLength);
|
|
300
|
+
buffer = buffer.slice(messageLength);
|
|
301
|
+
messageLength = getMessageLength(buffer);
|
|
302
|
+
}
|
|
283
303
|
readResult = await reader.read();
|
|
284
304
|
}
|
|
285
305
|
},
|
package/dist/llms/fireworks.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare class Fireworks extends OpenAI<FireworksCallOptions> {
|
|
|
26
26
|
constructor(fields?: Partial<Omit<OpenAIInput, "openAIApiKey" | FireworksUnsupportedArgs>> & BaseLLMParams & {
|
|
27
27
|
fireworksApiKey?: string;
|
|
28
28
|
});
|
|
29
|
-
toJSON(): import("
|
|
29
|
+
toJSON(): import("langchain-core/load/serializable").Serialized;
|
|
30
30
|
completionWithRetry(request: OpenAIClient.CompletionCreateParamsStreaming, options?: OpenAICoreRequestOptions): Promise<AsyncIterable<OpenAIClient.Completion>>;
|
|
31
31
|
completionWithRetry(request: OpenAIClient.CompletionCreateParamsNonStreaming, options?: OpenAICoreRequestOptions): Promise<OpenAIClient.Completions.Completion>;
|
|
32
32
|
}
|
package/dist/load/import_map.cjs
CHANGED
|
@@ -26,7 +26,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.chat_models__anthropic = exports.chat_models__openai = exports.chat_models__base = exports.document_transformers__openai_functions = exports.document_loaders__web__sort_xyz_blockchain = exports.document_loaders__web__serpapi = exports.document_loaders__web__searchapi = exports.document_loaders__base = exports.document = exports.memory = exports.text_splitter = exports.vectorstores__xata = exports.vectorstores__vectara = exports.vectorstores__prisma = exports.vectorstores__memory = exports.vectorstores__base = exports.prompts = exports.llms__fake = exports.llms__yandex = exports.llms__fireworks = exports.llms__ollama = exports.llms__cloudflare_workersai = exports.llms__aleph_alpha = exports.llms__ai21 = exports.llms__openai = exports.llms__base = exports.embeddings__voyage = exports.embeddings__minimax = exports.embeddings__openai = exports.embeddings__ollama = exports.embeddings__fake = exports.embeddings__cache_backed = exports.embeddings__base = exports.chains__openai_functions = exports.chains__combine_documents__reduce = exports.chains = exports.tools__render = exports.tools = exports.base_language = exports.agents__openai__output_parser = exports.agents__xml__output_parser = exports.agents__react__output_parser = exports.agents__format_scratchpad__log_to_message = exports.agents__format_scratchpad__xml = exports.agents__format_scratchpad__log = exports.agents__format_scratchpad__openai_tools = exports.agents__format_scratchpad = exports.agents__toolkits = exports.agents = exports.load__serializable = void 0;
|
|
28
28
|
exports.experimental__chains__violation_of_expectations = exports.experimental__chat_models__ollama_functions = exports.experimental__chat_models__bittensor = exports.experimental__plan_and_execute = exports.experimental__generative_agents = exports.experimental__babyagi = exports.experimental__openai_files = exports.experimental__openai_assistant = exports.experimental__autogpt = exports.util__time = exports.util__math = exports.util__document = exports.storage__in_memory = exports.storage__encoder_backed = exports.stores__message__in_memory = exports.stores__file__in_memory = exports.stores__doc__in_memory = exports.cache = exports.retrievers__vespa = exports.retrievers__score_threshold = exports.retrievers__hyde = exports.retrievers__document_compressors__embeddings_filter = exports.retrievers__document_compressors__chain_extract = exports.retrievers__time_weighted = exports.retrievers__tavily_search_api = exports.retrievers__parent_document = exports.retrievers__multi_vector = exports.retrievers__multi_query = exports.retrievers__document_compressors = exports.retrievers__contextual_compression = exports.retrievers__databerry = exports.retrievers__chaindesk = exports.retrievers__remote = exports.output_parsers = exports.callbacks = exports.schema__storage = exports.schema__runnable = exports.schema__retriever = exports.schema__query_constructor = exports.schema__prompt_template = exports.schema__output_parser = exports.schema__document = exports.schema = exports.chat_models__fake = exports.chat_models__yandex = exports.chat_models__minimax = exports.chat_models__ollama = exports.chat_models__baiduwenxin = exports.chat_models__fireworks = exports.chat_models__cloudflare_workersai = void 0;
|
|
29
|
-
exports.runnables__remote = exports.evaluation = void 0;
|
|
29
|
+
exports.runnables__remote = exports.runnables = exports.evaluation = void 0;
|
|
30
30
|
exports.load__serializable = __importStar(require("../load/serializable.cjs"));
|
|
31
31
|
exports.agents = __importStar(require("../agents/index.cjs"));
|
|
32
32
|
exports.agents__toolkits = __importStar(require("../agents/toolkits/index.cjs"));
|
|
@@ -128,4 +128,5 @@ exports.experimental__chat_models__bittensor = __importStar(require("../experime
|
|
|
128
128
|
exports.experimental__chat_models__ollama_functions = __importStar(require("../experimental/chat_models/ollama_functions.cjs"));
|
|
129
129
|
exports.experimental__chains__violation_of_expectations = __importStar(require("../experimental/chains/violation_of_expectations/index.cjs"));
|
|
130
130
|
exports.evaluation = __importStar(require("../evaluation/index.cjs"));
|
|
131
|
+
exports.runnables = __importStar(require("../runnables/index.cjs"));
|
|
131
132
|
exports.runnables__remote = __importStar(require("../runnables/remote.cjs"));
|
|
@@ -99,4 +99,5 @@ export * as experimental__chat_models__bittensor from "../experimental/chat_mode
|
|
|
99
99
|
export * as experimental__chat_models__ollama_functions from "../experimental/chat_models/ollama_functions.js";
|
|
100
100
|
export * as experimental__chains__violation_of_expectations from "../experimental/chains/violation_of_expectations/index.js";
|
|
101
101
|
export * as evaluation from "../evaluation/index.js";
|
|
102
|
+
export * as runnables from "../runnables/index.js";
|
|
102
103
|
export * as runnables__remote from "../runnables/remote.js";
|
package/dist/load/import_map.js
CHANGED
|
@@ -100,4 +100,5 @@ export * as experimental__chat_models__bittensor from "../experimental/chat_mode
|
|
|
100
100
|
export * as experimental__chat_models__ollama_functions from "../experimental/chat_models/ollama_functions.js";
|
|
101
101
|
export * as experimental__chains__violation_of_expectations from "../experimental/chains/violation_of_expectations/index.js";
|
|
102
102
|
export * as evaluation from "../evaluation/index.js";
|
|
103
|
+
export * as runnables from "../runnables/index.js";
|
|
103
104
|
export * as runnables__remote from "../runnables/remote.js";
|
package/dist/load/index.cjs
CHANGED
|
@@ -24,156 +24,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.load = void 0;
|
|
27
|
-
const
|
|
27
|
+
const load_1 = require("langchain-core/load");
|
|
28
28
|
const import_constants_js_1 = require("./import_constants.cjs");
|
|
29
29
|
const importMap = __importStar(require("./import_map.cjs"));
|
|
30
|
-
const map_keys_js_1 = require("./map_keys.cjs");
|
|
31
|
-
const env_js_1 = require("../util/env.cjs");
|
|
32
|
-
function combineAliasesAndInvert(constructor) {
|
|
33
|
-
const aliases = {};
|
|
34
|
-
for (
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
36
|
-
let current = constructor; current && current.prototype; current = Object.getPrototypeOf(current)) {
|
|
37
|
-
Object.assign(aliases, Reflect.get(current.prototype, "lc_aliases"));
|
|
38
|
-
}
|
|
39
|
-
return Object.entries(aliases).reduce((acc, [key, value]) => {
|
|
40
|
-
acc[value] = key;
|
|
41
|
-
return acc;
|
|
42
|
-
}, {});
|
|
43
|
-
}
|
|
44
|
-
async function reviver(value) {
|
|
45
|
-
const { optionalImportsMap, secretsMap, path = ["$"] } = this;
|
|
46
|
-
const pathStr = path.join(".");
|
|
47
|
-
if (typeof value === "object" &&
|
|
48
|
-
value !== null &&
|
|
49
|
-
!Array.isArray(value) &&
|
|
50
|
-
"lc" in value &&
|
|
51
|
-
"type" in value &&
|
|
52
|
-
"id" in value &&
|
|
53
|
-
value.lc === 1 &&
|
|
54
|
-
value.type === "secret") {
|
|
55
|
-
const serialized = value;
|
|
56
|
-
const [key] = serialized.id;
|
|
57
|
-
if (key in secretsMap) {
|
|
58
|
-
return secretsMap[key];
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
const secretValueInEnv = (0, env_js_1.getEnvironmentVariable)(key);
|
|
62
|
-
if (secretValueInEnv) {
|
|
63
|
-
return secretValueInEnv;
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
throw new Error(`Missing key "${key}" for ${pathStr} in load(secretsMap={})`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
else if (typeof value === "object" &&
|
|
71
|
-
value !== null &&
|
|
72
|
-
!Array.isArray(value) &&
|
|
73
|
-
"lc" in value &&
|
|
74
|
-
"type" in value &&
|
|
75
|
-
"id" in value &&
|
|
76
|
-
value.lc === 1 &&
|
|
77
|
-
value.type === "not_implemented") {
|
|
78
|
-
const serialized = value;
|
|
79
|
-
const str = JSON.stringify(serialized);
|
|
80
|
-
throw new Error(`Trying to load an object that doesn't implement serialization: ${pathStr} -> ${str}`);
|
|
81
|
-
}
|
|
82
|
-
else if (typeof value === "object" &&
|
|
83
|
-
value !== null &&
|
|
84
|
-
!Array.isArray(value) &&
|
|
85
|
-
"lc" in value &&
|
|
86
|
-
"type" in value &&
|
|
87
|
-
"id" in value &&
|
|
88
|
-
"kwargs" in value &&
|
|
89
|
-
value.lc === 1) {
|
|
90
|
-
const serialized = value;
|
|
91
|
-
const str = JSON.stringify(serialized);
|
|
92
|
-
const [name, ...namespaceReverse] = serialized.id.slice().reverse();
|
|
93
|
-
const namespace = namespaceReverse.reverse();
|
|
94
|
-
let module;
|
|
95
|
-
if (import_constants_js_1.optionalImportEntrypoints.includes(namespace.join("/")) ||
|
|
96
|
-
namespace.join("/") in optionalImportsMap) {
|
|
97
|
-
if (namespace.join("/") in optionalImportsMap) {
|
|
98
|
-
module = await optionalImportsMap[namespace.join("/")];
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
throw new Error(`Missing key "${namespace.join("/")}" for ${pathStr} in load(optionalImportsMap={})`);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
// Currently, we only support langchain imports.
|
|
106
|
-
if (namespace[0] === "langchain") {
|
|
107
|
-
namespace.shift();
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
throw new Error(`Invalid namespace: ${pathStr} -> ${str}`);
|
|
111
|
-
}
|
|
112
|
-
// The root namespace "langchain" is not a valid import.
|
|
113
|
-
if (namespace.length === 0) {
|
|
114
|
-
throw new Error(`Invalid namespace: ${pathStr} -> ${str}`);
|
|
115
|
-
}
|
|
116
|
-
// Find the longest matching namespace.
|
|
117
|
-
let importMapKey;
|
|
118
|
-
do {
|
|
119
|
-
importMapKey = namespace.join("__");
|
|
120
|
-
if (importMapKey in importMap) {
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
namespace.pop();
|
|
125
|
-
}
|
|
126
|
-
} while (namespace.length > 0);
|
|
127
|
-
// If no matching namespace is found, throw an error.
|
|
128
|
-
if (importMapKey in importMap) {
|
|
129
|
-
module = importMap[importMapKey];
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
if (typeof module !== "object" || module === null) {
|
|
133
|
-
throw new Error(`Invalid namespace: ${pathStr} -> ${str}`);
|
|
134
|
-
}
|
|
135
|
-
// Extract the builder from the import map.
|
|
136
|
-
const builder =
|
|
137
|
-
// look for a named export with the same name as the class
|
|
138
|
-
module[name] ??
|
|
139
|
-
// look for an export with a lc_name property matching the class name
|
|
140
|
-
// this is necessary for classes that are minified
|
|
141
|
-
Object.values(module).find((v) => typeof v === "function" &&
|
|
142
|
-
(0, serializable_js_1.get_lc_unique_name)(v) === name);
|
|
143
|
-
if (typeof builder !== "function") {
|
|
144
|
-
throw new Error(`Invalid identifer: ${pathStr} -> ${str}`);
|
|
145
|
-
}
|
|
146
|
-
// Recurse on the arguments, which may be serialized objects themselves
|
|
147
|
-
const kwargs = await reviver.call({ ...this, path: [...path, "kwargs"] }, serialized.kwargs);
|
|
148
|
-
// Construct the object
|
|
149
|
-
if (serialized.type === "constructor") {
|
|
150
|
-
// eslint-disable-next-line new-cap, @typescript-eslint/no-explicit-any
|
|
151
|
-
const instance = new builder((0, map_keys_js_1.mapKeys)(kwargs, map_keys_js_1.keyFromJson, combineAliasesAndInvert(builder)));
|
|
152
|
-
// Minification in severless/edge runtimes will mange the
|
|
153
|
-
// name of classes presented in traces. As the names in import map
|
|
154
|
-
// are present as-is even with minification, use these names instead
|
|
155
|
-
Object.defineProperty(instance.constructor, "name", { value: name });
|
|
156
|
-
return instance;
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
throw new Error(`Invalid type: ${pathStr} -> ${str}`);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
else if (typeof value === "object" && value !== null) {
|
|
163
|
-
if (Array.isArray(value)) {
|
|
164
|
-
return Promise.all(value.map((v, i) => reviver.call({ ...this, path: [...path, `${i}`] }, v)));
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
return Object.fromEntries(await Promise.all(Object.entries(value).map(async ([key, value]) => [
|
|
168
|
-
key,
|
|
169
|
-
await reviver.call({ ...this, path: [...path, key] }, value),
|
|
170
|
-
])));
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return value;
|
|
174
|
-
}
|
|
175
30
|
async function load(text, secretsMap = {}, optionalImportsMap = {}) {
|
|
176
|
-
|
|
177
|
-
|
|
31
|
+
return (0, load_1.load)(text, {
|
|
32
|
+
secretsMap,
|
|
33
|
+
optionalImportsMap,
|
|
34
|
+
optionalImportEntrypoints: import_constants_js_1.optionalImportEntrypoints,
|
|
35
|
+
importMap,
|
|
36
|
+
});
|
|
178
37
|
}
|
|
179
38
|
exports.load = load;
|
package/dist/load/index.js
CHANGED
|
@@ -1,152 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { load as coreLoad } from "langchain-core/load";
|
|
2
2
|
import { optionalImportEntrypoints } from "./import_constants.js";
|
|
3
3
|
import * as importMap from "./import_map.js";
|
|
4
|
-
import { keyFromJson, mapKeys } from "./map_keys.js";
|
|
5
|
-
import { getEnvironmentVariable } from "../util/env.js";
|
|
6
|
-
function combineAliasesAndInvert(constructor) {
|
|
7
|
-
const aliases = {};
|
|
8
|
-
for (
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
10
|
-
let current = constructor; current && current.prototype; current = Object.getPrototypeOf(current)) {
|
|
11
|
-
Object.assign(aliases, Reflect.get(current.prototype, "lc_aliases"));
|
|
12
|
-
}
|
|
13
|
-
return Object.entries(aliases).reduce((acc, [key, value]) => {
|
|
14
|
-
acc[value] = key;
|
|
15
|
-
return acc;
|
|
16
|
-
}, {});
|
|
17
|
-
}
|
|
18
|
-
async function reviver(value) {
|
|
19
|
-
const { optionalImportsMap, secretsMap, path = ["$"] } = this;
|
|
20
|
-
const pathStr = path.join(".");
|
|
21
|
-
if (typeof value === "object" &&
|
|
22
|
-
value !== null &&
|
|
23
|
-
!Array.isArray(value) &&
|
|
24
|
-
"lc" in value &&
|
|
25
|
-
"type" in value &&
|
|
26
|
-
"id" in value &&
|
|
27
|
-
value.lc === 1 &&
|
|
28
|
-
value.type === "secret") {
|
|
29
|
-
const serialized = value;
|
|
30
|
-
const [key] = serialized.id;
|
|
31
|
-
if (key in secretsMap) {
|
|
32
|
-
return secretsMap[key];
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
const secretValueInEnv = getEnvironmentVariable(key);
|
|
36
|
-
if (secretValueInEnv) {
|
|
37
|
-
return secretValueInEnv;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
throw new Error(`Missing key "${key}" for ${pathStr} in load(secretsMap={})`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
else if (typeof value === "object" &&
|
|
45
|
-
value !== null &&
|
|
46
|
-
!Array.isArray(value) &&
|
|
47
|
-
"lc" in value &&
|
|
48
|
-
"type" in value &&
|
|
49
|
-
"id" in value &&
|
|
50
|
-
value.lc === 1 &&
|
|
51
|
-
value.type === "not_implemented") {
|
|
52
|
-
const serialized = value;
|
|
53
|
-
const str = JSON.stringify(serialized);
|
|
54
|
-
throw new Error(`Trying to load an object that doesn't implement serialization: ${pathStr} -> ${str}`);
|
|
55
|
-
}
|
|
56
|
-
else if (typeof value === "object" &&
|
|
57
|
-
value !== null &&
|
|
58
|
-
!Array.isArray(value) &&
|
|
59
|
-
"lc" in value &&
|
|
60
|
-
"type" in value &&
|
|
61
|
-
"id" in value &&
|
|
62
|
-
"kwargs" in value &&
|
|
63
|
-
value.lc === 1) {
|
|
64
|
-
const serialized = value;
|
|
65
|
-
const str = JSON.stringify(serialized);
|
|
66
|
-
const [name, ...namespaceReverse] = serialized.id.slice().reverse();
|
|
67
|
-
const namespace = namespaceReverse.reverse();
|
|
68
|
-
let module;
|
|
69
|
-
if (optionalImportEntrypoints.includes(namespace.join("/")) ||
|
|
70
|
-
namespace.join("/") in optionalImportsMap) {
|
|
71
|
-
if (namespace.join("/") in optionalImportsMap) {
|
|
72
|
-
module = await optionalImportsMap[namespace.join("/")];
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
throw new Error(`Missing key "${namespace.join("/")}" for ${pathStr} in load(optionalImportsMap={})`);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
// Currently, we only support langchain imports.
|
|
80
|
-
if (namespace[0] === "langchain") {
|
|
81
|
-
namespace.shift();
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
throw new Error(`Invalid namespace: ${pathStr} -> ${str}`);
|
|
85
|
-
}
|
|
86
|
-
// The root namespace "langchain" is not a valid import.
|
|
87
|
-
if (namespace.length === 0) {
|
|
88
|
-
throw new Error(`Invalid namespace: ${pathStr} -> ${str}`);
|
|
89
|
-
}
|
|
90
|
-
// Find the longest matching namespace.
|
|
91
|
-
let importMapKey;
|
|
92
|
-
do {
|
|
93
|
-
importMapKey = namespace.join("__");
|
|
94
|
-
if (importMapKey in importMap) {
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
namespace.pop();
|
|
99
|
-
}
|
|
100
|
-
} while (namespace.length > 0);
|
|
101
|
-
// If no matching namespace is found, throw an error.
|
|
102
|
-
if (importMapKey in importMap) {
|
|
103
|
-
module = importMap[importMapKey];
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
if (typeof module !== "object" || module === null) {
|
|
107
|
-
throw new Error(`Invalid namespace: ${pathStr} -> ${str}`);
|
|
108
|
-
}
|
|
109
|
-
// Extract the builder from the import map.
|
|
110
|
-
const builder =
|
|
111
|
-
// look for a named export with the same name as the class
|
|
112
|
-
module[name] ??
|
|
113
|
-
// look for an export with a lc_name property matching the class name
|
|
114
|
-
// this is necessary for classes that are minified
|
|
115
|
-
Object.values(module).find((v) => typeof v === "function" &&
|
|
116
|
-
get_lc_unique_name(v) === name);
|
|
117
|
-
if (typeof builder !== "function") {
|
|
118
|
-
throw new Error(`Invalid identifer: ${pathStr} -> ${str}`);
|
|
119
|
-
}
|
|
120
|
-
// Recurse on the arguments, which may be serialized objects themselves
|
|
121
|
-
const kwargs = await reviver.call({ ...this, path: [...path, "kwargs"] }, serialized.kwargs);
|
|
122
|
-
// Construct the object
|
|
123
|
-
if (serialized.type === "constructor") {
|
|
124
|
-
// eslint-disable-next-line new-cap, @typescript-eslint/no-explicit-any
|
|
125
|
-
const instance = new builder(mapKeys(kwargs, keyFromJson, combineAliasesAndInvert(builder)));
|
|
126
|
-
// Minification in severless/edge runtimes will mange the
|
|
127
|
-
// name of classes presented in traces. As the names in import map
|
|
128
|
-
// are present as-is even with minification, use these names instead
|
|
129
|
-
Object.defineProperty(instance.constructor, "name", { value: name });
|
|
130
|
-
return instance;
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
throw new Error(`Invalid type: ${pathStr} -> ${str}`);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
else if (typeof value === "object" && value !== null) {
|
|
137
|
-
if (Array.isArray(value)) {
|
|
138
|
-
return Promise.all(value.map((v, i) => reviver.call({ ...this, path: [...path, `${i}`] }, v)));
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
return Object.fromEntries(await Promise.all(Object.entries(value).map(async ([key, value]) => [
|
|
142
|
-
key,
|
|
143
|
-
await reviver.call({ ...this, path: [...path, key] }, value),
|
|
144
|
-
])));
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return value;
|
|
148
|
-
}
|
|
149
4
|
export async function load(text, secretsMap = {}, optionalImportsMap = {}) {
|
|
150
|
-
|
|
151
|
-
|
|
5
|
+
return coreLoad(text, {
|
|
6
|
+
secretsMap,
|
|
7
|
+
optionalImportsMap,
|
|
8
|
+
optionalImportEntrypoints,
|
|
9
|
+
importMap,
|
|
10
|
+
});
|
|
152
11
|
}
|
package/dist/load/map_keys.cjs
CHANGED
|
@@ -1,26 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.mapKeys = exports.keyFromJson = exports.keyToJson = void 0;
|
|
7
|
-
const decamelize_1 = __importDefault(require("decamelize"));
|
|
8
|
-
const camelcase_1 = __importDefault(require("camelcase"));
|
|
9
|
-
function keyToJson(key, map) {
|
|
10
|
-
return map?.[key] || (0, decamelize_1.default)(key);
|
|
11
|
-
}
|
|
12
|
-
exports.keyToJson = keyToJson;
|
|
13
|
-
function keyFromJson(key, map) {
|
|
14
|
-
return map?.[key] || (0, camelcase_1.default)(key);
|
|
15
|
-
}
|
|
16
|
-
exports.keyFromJson = keyFromJson;
|
|
17
|
-
function mapKeys(fields, mapper, map) {
|
|
18
|
-
const mapped = {};
|
|
19
|
-
for (const key in fields) {
|
|
20
|
-
if (Object.hasOwn(fields, key)) {
|
|
21
|
-
mapped[mapper(key, map)] = fields[key];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return mapped;
|
|
25
|
-
}
|
|
26
|
-
exports.mapKeys = mapKeys;
|
package/dist/load/map_keys.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
1
|
export interface SerializedFields {
|
|
2
2
|
[key: string]: any;
|
|
3
3
|
}
|
|
4
|
-
export interface SerializedKeyAlias {
|
|
5
|
-
[key: string]: string;
|
|
6
|
-
}
|
|
7
|
-
export declare function keyToJson(key: string, map?: SerializedKeyAlias): string;
|
|
8
|
-
export declare function keyFromJson(key: string, map?: SerializedKeyAlias): string;
|
|
9
|
-
export declare function mapKeys(fields: SerializedFields, mapper: typeof keyToJson, map?: SerializedKeyAlias): SerializedFields;
|
package/dist/load/map_keys.js
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import camelCase from "camelcase";
|
|
3
|
-
export function keyToJson(key, map) {
|
|
4
|
-
return map?.[key] || snakeCase(key);
|
|
5
|
-
}
|
|
6
|
-
export function keyFromJson(key, map) {
|
|
7
|
-
return map?.[key] || camelCase(key);
|
|
8
|
-
}
|
|
9
|
-
export function mapKeys(fields, mapper, map) {
|
|
10
|
-
const mapped = {};
|
|
11
|
-
for (const key in fields) {
|
|
12
|
-
if (Object.hasOwn(fields, key)) {
|
|
13
|
-
mapped[mapper(key, map)] = fields[key];
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return mapped;
|
|
17
|
-
}
|
|
1
|
+
export {};
|