agsamantha/node_modules/langchain/dist/chains/transform.cjs

57 lines
1.7 KiB
JavaScript
Raw Normal View History

2024-10-02 15:15:21 -05:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TransformChain = void 0;
const base_js_1 = require("./base.cjs");
/**
* Class that represents a transform chain. It extends the `BaseChain`
* class and implements the `TransformChainFields` interface. It provides
* a way to transform input values to output values using a specified
* transform function.
*
* @deprecated
* Switch to {@link https://js.langchain.com/docs/expression_language/ | expression language}.
* Will be removed in 0.2.0
*/
class TransformChain extends base_js_1.BaseChain {
static lc_name() {
return "TransformChain";
}
_chainType() {
return "transform";
}
get inputKeys() {
return this.inputVariables;
}
get outputKeys() {
return this.outputVariables;
}
constructor(fields) {
super(fields);
Object.defineProperty(this, "transformFunc", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "inputVariables", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "outputVariables", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
this.transformFunc = fields.transform;
this.inputVariables = fields.inputVariables;
this.outputVariables = fields.outputVariables;
}
async _call(values, runManager) {
return this.transformFunc(values, runManager?.getChild("transform"));
}
}
exports.TransformChain = TransformChain;