Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More β†’
Socket
Sign inDemoInstall
Socket

@langchain/core

Package Overview
Dependencies
Maintainers
4
Versions
170
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@langchain/core - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

1

dist/prompt_values.d.ts

@@ -25,2 +25,3 @@ import { Serializable } from "./load/serializable.js";

export declare class StringPromptValue extends BasePromptValue implements StringPromptValueInterface {
static lc_name(): string;
lc_namespace: string[];

@@ -27,0 +28,0 @@ lc_serializable: boolean;

@@ -13,2 +13,5 @@ import { Serializable } from "./load/serializable.js";

export class StringPromptValue extends BasePromptValue {
static lc_name() {
return "StringPromptValue";
}
constructor(value) {

@@ -15,0 +18,0 @@ super({ value });

8

dist/runnables/base.d.ts

@@ -140,3 +140,3 @@ import { CallbackManager, CallbackManagerForChainRun } from "../callbacks/manager.js";

*/
protected _transformStreamWithConfig<I extends RunInput, O extends RunOutput>(inputGenerator: AsyncGenerator<I>, transformer: (generator: AsyncGenerator<I>, runManager?: CallbackManagerForChainRun, options?: Partial<CallOptions>) => AsyncGenerator<O>, options?: CallOptions & {
protected _transformStreamWithConfig<I extends RunInput, O extends RunOutput>(inputGenerator: AsyncGenerator<I>, transformer: (generator: AsyncGenerator<I>, runManager?: Promise<CallbackManagerForChainRun | undefined>, options?: Partial<CallOptions>) => AsyncGenerator<O>, options?: CallOptions & {
runType?: string;

@@ -406,3 +406,3 @@ }): AsyncGenerator<O>;

invoke(input: RunInput, options?: Partial<RunnableConfig>): Promise<RunOutput>;
_transform(generator: AsyncGenerator<RunInput>, runManager?: CallbackManagerForChainRun, options?: Partial<RunnableConfig>): AsyncGenerator<RunOutput>;
_transform(generator: AsyncGenerator<RunInput>, runManagerPromise?: Promise<CallbackManagerForChainRun | undefined>, options?: Partial<RunnableConfig>): AsyncGenerator<RunOutput>;
transform(generator: AsyncGenerator<RunInput>, options?: Partial<RunnableConfig>): AsyncGenerator<RunOutput>;

@@ -424,3 +424,3 @@ stream(input: RunInput, options?: Partial<RunnableConfig>): Promise<IterableReadableStream<RunOutput>>;

invoke(input: RunInput, options?: Partial<RunnableConfig>): Promise<RunOutput>;
_transform(generator: AsyncGenerator<RunInput>, runManager?: CallbackManagerForChainRun, config?: Partial<RunnableConfig>): AsyncGenerator<RunOutput>;
_transform(generator: AsyncGenerator<RunInput>, runManagerPromise?: Promise<CallbackManagerForChainRun | undefined>, config?: Partial<RunnableConfig>): AsyncGenerator<RunOutput>;
transform(generator: AsyncGenerator<RunInput>, options?: Partial<RunnableConfig>): AsyncGenerator<RunOutput>;

@@ -468,3 +468,3 @@ stream(input: RunInput, options?: Partial<RunnableConfig>): Promise<IterableReadableStream<RunOutput>>;

invoke(input: RunInput, options?: Partial<CallOptions>): Promise<RunOutput>;
_transform(generator: AsyncGenerator<RunInput>, runManager?: CallbackManagerForChainRun, options?: Partial<RunnableConfig>): AsyncGenerator<RunOutput>;
_transform(generator: AsyncGenerator<RunInput>, runManagerPromise?: Promise<CallbackManagerForChainRun | undefined>, options?: Partial<RunnableConfig>): AsyncGenerator<RunOutput>;
transform(generator: AsyncGenerator<RunInput>, options?: Partial<RunnableConfig>): AsyncGenerator<RunOutput>;

@@ -471,0 +471,0 @@ stream(input: RunInput, options?: Partial<RunnableConfig>): Promise<IterableReadableStream<RunOutput>>;

@@ -5,4 +5,4 @@ import pRetry from "p-retry";

import { Serializable } from "../load/serializable.js";
import { IterableReadableStream, concat, atee, } from "../utils/stream.js";
import { DEFAULT_RECURSION_LIMIT, getCallbackMangerForConfig, mergeConfigs, } from "./config.js";
import { IterableReadableStream, concat, atee, AsyncGeneratorWithSetup, } from "../utils/stream.js";
import { DEFAULT_RECURSION_LIMIT, getCallbackManagerForConfig, mergeConfigs, } from "./config.js";
import { AsyncCaller } from "../utils/async_caller.js";

@@ -166,3 +166,3 @@ import { RootListenersTracer } from "../tracers/root_listener.js";

async _callWithConfig(func, input, options) {
const callbackManager_ = await getCallbackMangerForConfig(options);
const callbackManager_ = await getCallbackManagerForConfig(options);
const runManager = await callbackManager_?.handleChainStart(this.toJSON(), _coerceToDict(input, "input"), undefined, options?.runType, undefined, undefined, options?.runName ?? this.getName());

@@ -191,3 +191,3 @@ let output;

const optionsList = this._getOptionsList(options ?? {}, inputs.length);
const callbackManagers = await Promise.all(optionsList.map(getCallbackMangerForConfig));
const callbackManagers = await Promise.all(optionsList.map(getCallbackManagerForConfig));
const runManagers = await Promise.all(callbackManagers.map((callbackManager, i) => callbackManager?.handleChainStart(this.toJSON(), _coerceToDict(inputs[i], "input"), undefined, optionsList[i].runType, undefined, undefined, optionsList[i].runName ?? this.getName())));

@@ -215,6 +215,6 @@ let outputs;

let finalOutputSupported = true;
const callbackManager_ = await getCallbackMangerForConfig(options);
const runManager = await callbackManager_?.handleChainStart(this.toJSON(), { input: "" }, undefined, options?.runType, undefined, undefined, options?.runName ?? this.getName());
const callbackManager_ = await getCallbackManagerForConfig(options);
const inputGeneratorWithSetup = new AsyncGeneratorWithSetup(inputGenerator, async () => callbackManager_?.handleChainStart(this.toJSON(), { input: "" }, undefined, options?.runType, undefined, undefined, options?.runName ?? this.getName()));
async function* wrapInputForTracing() {
for await (const chunk of inputGenerator) {
for await (const chunk of inputGeneratorWithSetup) {
if (finalInputSupported) {

@@ -238,5 +238,4 @@ if (finalInput === undefined) {

}
const wrappedInputGenerator = wrapInputForTracing();
try {
const outputIterator = transformer(wrappedInputGenerator, runManager, options);
const outputIterator = transformer(wrapInputForTracing(), inputGeneratorWithSetup.setup, options);
for await (const chunk of outputIterator) {

@@ -262,2 +261,3 @@ yield chunk;

catch (e) {
const runManager = await inputGeneratorWithSetup.setup;
await runManager?.handleChainError(e, undefined, undefined, undefined, {

@@ -268,2 +268,3 @@ inputs: _coerceToDict(finalInput, "input"),

}
const runManager = await inputGeneratorWithSetup.setup;
await runManager?.handleChainEnd(finalOutput ?? {}, undefined, undefined, undefined, { inputs: _coerceToDict(finalInput, "input") });

@@ -816,3 +817,3 @@ }

async invoke(input, options) {
const callbackManager_ = await getCallbackMangerForConfig(options);
const callbackManager_ = await getCallbackManagerForConfig(options);
const runManager = await callbackManager_?.handleChainStart(this.toJSON(), _coerceToDict(input, "input"), undefined, undefined, undefined, undefined, options?.runName);

@@ -839,3 +840,3 @@ let nextStepInput = input;

const configList = this._getOptionsList(options ?? {}, inputs.length);
const callbackManagers = await Promise.all(configList.map(getCallbackMangerForConfig));
const callbackManagers = await Promise.all(configList.map(getCallbackManagerForConfig));
const runManagers = await Promise.all(callbackManagers.map((callbackManager, i) => callbackManager?.handleChainStart(this.toJSON(), _coerceToDict(inputs[i], "input"), undefined, undefined, undefined, undefined, configList[i].runName)));

@@ -861,3 +862,3 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any

async *_streamIterator(input, options) {
const callbackManager_ = await getCallbackMangerForConfig(options);
const callbackManager_ = await getCallbackManagerForConfig(options);
const runManager = await callbackManager_?.handleChainStart(this.toJSON(), _coerceToDict(input, "input"), undefined, undefined, undefined, undefined, options?.runName);

@@ -989,3 +990,3 @@ const steps = [this.first, ...this.middle, this.last];

async invoke(input, options) {
const callbackManager_ = await getCallbackMangerForConfig(options);
const callbackManager_ = await getCallbackManagerForConfig(options);
const runManager = await callbackManager_?.handleChainStart(this.toJSON(), {

@@ -1008,3 +1009,3 @@ input,

}
async *_transform(generator, runManager, options) {
async *_transform(generator, runManagerPromise, options) {
// shallow copy steps to ignore changes while iterating

@@ -1014,2 +1015,3 @@ const steps = { ...this.steps };

const inputCopies = atee(generator, Object.keys(steps).length);
const runManager = await runManagerPromise;
// start the first iteration of each output iterator

@@ -1083,3 +1085,3 @@ const tasks = new Map(Object.entries(steps).map(([key, runnable], i) => {

}
async *_transform(generator, runManager, config) {
async *_transform(generator, runManagerPromise, config) {
let finalChunk;

@@ -1106,2 +1108,3 @@ for await (const chunk of generator) {

}
const runManager = await runManagerPromise;
const stream = await output.stream(finalChunk, this._patchConfig(config, runManager?.getChild(), (config?.recursionLimit ?? DEFAULT_RECURSION_LIMIT) - 1));

@@ -1282,7 +1285,8 @@ for await (const chunk of stream) {

}
async *_transform(generator, runManager, options) {
async *_transform(generator, runManagerPromise, options) {
// collect mapper keys
const mapperKeys = this.mapper.getStepsKeys();
// create two input gens, one for the mapper, one for the input
const [forPassthrough, forMapper] = atee(generator, 2);
const [forPassthrough, forMapper] = atee(generator);
const runManager = await runManagerPromise;
// create mapper output gen

@@ -1289,0 +1293,0 @@ const mapperOutput = this.mapper.transform(forMapper, this._patchConfig(options, runManager?.getChild()));

@@ -14,3 +14,3 @@ import { type BaseCallbackConfig, CallbackManager } from "../callbacks/manager.js";

}
export declare function getCallbackMangerForConfig(config?: RunnableConfig): Promise<CallbackManager | undefined>;
export declare function getCallbackManagerForConfig(config?: RunnableConfig): Promise<CallbackManager | undefined>;
export declare function mergeConfigs<CallOptions extends RunnableConfig>(config: RunnableConfig, options?: Record<string, any>): Partial<CallOptions>;
import { CallbackManager, } from "../callbacks/manager.js";
export const DEFAULT_RECURSION_LIMIT = 25;
export async function getCallbackMangerForConfig(config) {
export async function getCallbackManagerForConfig(config) {
return CallbackManager.configure(config?.callbacks, undefined, config?.tags, undefined, config?.metadata);

@@ -5,0 +5,0 @@ }

export { type RunnableFunc, type RunnableLike, type RunnableBatchOptions, type RunnableRetryFailedAttemptHandler, Runnable, type RunnableInterface, type RunnableBindingArgs, RunnableBinding, RunnableEach, RunnableRetry, RunnableSequence, RunnableMap, RunnableParallel, RunnableLambda, RunnableWithFallbacks, RunnableAssign, RunnablePick, _coerceToRunnable, } from "./base.js";
export type { RunnableConfig, getCallbackMangerForConfig } from "./config.js";
export { type RunnableConfig, getCallbackManagerForConfig } from "./config.js";
export { RunnablePassthrough } from "./passthrough.js";

@@ -4,0 +4,0 @@ export { type RouterInput, RouterRunnable } from "./router.js";

export { Runnable, RunnableBinding, RunnableEach, RunnableRetry, RunnableSequence, RunnableMap, RunnableParallel, RunnableLambda, RunnableWithFallbacks, RunnableAssign, RunnablePick, _coerceToRunnable, } from "./base.js";
export { getCallbackManagerForConfig } from "./config.js";
export { RunnablePassthrough } from "./passthrough.js";

@@ -3,0 +4,0 @@ export { RouterRunnable } from "./router.js";

@@ -21,1 +21,12 @@ export interface IterableReadableStreamInterface<T> extends ReadableStream<T>, AsyncGenerator<T> {

export declare function concat<T extends Array<any> | string | number | Record<string, any> | any>(first: T, second: T): T;
export declare class AsyncGeneratorWithSetup<S = unknown, T = unknown, TReturn = unknown, TNext = unknown> implements AsyncGenerator<T, TReturn, TNext> {
private generator;
setup: Promise<S>;
private firstResult;
private firstResultUsed;
constructor(generator: AsyncGenerator<T>, startSetup: () => Promise<S>);
next(...args: [] | [TNext]): Promise<IteratorResult<T>>;
return(value: TReturn | PromiseLike<TReturn>): Promise<IteratorResult<T>>;
throw(e: Error): Promise<IteratorResult<T>>;
[Symbol.asyncIterator](): this;
}

@@ -153,1 +153,54 @@ /*

}
export class AsyncGeneratorWithSetup {
constructor(generator, startSetup) {
Object.defineProperty(this, "generator", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "setup", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "firstResult", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "firstResultUsed", {
enumerable: true,
configurable: true,
writable: true,
value: false
});
this.generator = generator;
// setup is a promise that resolves only after the first iterator value
// is available. this is useful when setup of several piped generators
// needs to happen in logical order, ie. in the order in which input to
// to each generator is available.
this.setup = new Promise((resolve, reject) => {
this.firstResult = generator.next();
this.firstResult.then(startSetup).then(resolve, reject);
});
}
async next(...args) {
if (!this.firstResultUsed) {
this.firstResultUsed = true;
return this.firstResult;
}
return this.generator.next(...args);
}
async return(value) {
return this.generator.return(value);
}
async throw(e) {
return this.generator.throw(e);
}
[Symbol.asyncIterator]() {
return this;
}
}
{
"name": "@langchain/core",
"version": "0.1.5",
"version": "0.1.6",
"description": "Core LangChain.js abstractions and schemas",

@@ -5,0 +5,0 @@ "type": "module",

@@ -124,3 +124,3 @@ # 🦜🍎️ @langchain/core

"@anthropic-ai/sdk": "^0.10.0",
"@langchain/core": "~0.1.2"
"@langchain/core": "~0.1.5"
}

@@ -127,0 +127,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc