@flutchai/flutch-sdk 0.2.2 → 0.2.3
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/dist/index.cjs +29 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +29 -63
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1324,62 +1324,38 @@ exports.AbstractGraphBuilder = class AbstractGraphBuilder {
|
|
|
1324
1324
|
}
|
|
1325
1325
|
/**
|
|
1326
1326
|
* Prepare config for graph execution
|
|
1327
|
-
*
|
|
1327
|
+
* Deserialization happens in engine, so just pass through with customization hook
|
|
1328
1328
|
*/
|
|
1329
1329
|
async preparePayload(payload) {
|
|
1330
|
-
const
|
|
1331
|
-
return
|
|
1330
|
+
const finalPayload = await this.customizeConfig(payload);
|
|
1331
|
+
return finalPayload;
|
|
1332
1332
|
}
|
|
1333
1333
|
/**
|
|
1334
|
-
*
|
|
1335
|
-
*/
|
|
1336
|
-
async prepareConfig(payload) {
|
|
1337
|
-
let input = payload.input;
|
|
1338
|
-
if (payload.input && typeof payload.input === "object" && "lc" in payload.input) {
|
|
1339
|
-
try {
|
|
1340
|
-
const { load } = await import('@langchain/core/load');
|
|
1341
|
-
input = await load(JSON.stringify(payload.input));
|
|
1342
|
-
this.logger.debug({
|
|
1343
|
-
message: "Deserialized BaseMessage using load()",
|
|
1344
|
-
type: input.constructor?.name
|
|
1345
|
-
});
|
|
1346
|
-
} catch (error) {
|
|
1347
|
-
this.logger.warn({
|
|
1348
|
-
message: "Failed to deserialize message",
|
|
1349
|
-
error: error.message
|
|
1350
|
-
});
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
const baseConfig = {
|
|
1354
|
-
...payload.config,
|
|
1355
|
-
input
|
|
1356
|
-
};
|
|
1357
|
-
const finalConfig = await this.customizeConfig(baseConfig, payload);
|
|
1358
|
-
return finalConfig;
|
|
1359
|
-
}
|
|
1360
|
-
/**
|
|
1361
|
-
* Hook for customizing config after base preparation
|
|
1334
|
+
* Hook for customizing config before graph execution
|
|
1362
1335
|
* Override this method in child classes to add/modify config fields
|
|
1363
1336
|
*
|
|
1364
|
-
* @param
|
|
1365
|
-
* @
|
|
1366
|
-
* @returns Modified config
|
|
1337
|
+
* @param payload - Original request payload with input and config
|
|
1338
|
+
* @returns Modified payload
|
|
1367
1339
|
*
|
|
1368
1340
|
* @example
|
|
1369
1341
|
* ```typescript
|
|
1370
|
-
* protected async customizeConfig(
|
|
1371
|
-
* // Add custom fields
|
|
1372
|
-
*
|
|
1373
|
-
*
|
|
1374
|
-
*
|
|
1375
|
-
*
|
|
1376
|
-
*
|
|
1377
|
-
*
|
|
1342
|
+
* protected async customizeConfig(payload: IGraphRequestPayload): Promise<any> {
|
|
1343
|
+
* // Add custom fields to config
|
|
1344
|
+
* return {
|
|
1345
|
+
* ...payload,
|
|
1346
|
+
* config: {
|
|
1347
|
+
* ...payload.config,
|
|
1348
|
+
* configurable: {
|
|
1349
|
+
* ...payload.config.configurable,
|
|
1350
|
+
* myCustomField: "value",
|
|
1351
|
+
* },
|
|
1352
|
+
* },
|
|
1353
|
+
* };
|
|
1378
1354
|
* }
|
|
1379
1355
|
* ```
|
|
1380
1356
|
*/
|
|
1381
|
-
async customizeConfig(
|
|
1382
|
-
return
|
|
1357
|
+
async customizeConfig(payload) {
|
|
1358
|
+
return payload;
|
|
1383
1359
|
}
|
|
1384
1360
|
/**
|
|
1385
1361
|
* Load graph manifest (if using manifest-based approach)
|
|
@@ -4985,7 +4961,6 @@ exports.EventProcessor = class EventProcessor {
|
|
|
4985
4961
|
exports.EventProcessor = __decorateClass([
|
|
4986
4962
|
common.Injectable()
|
|
4987
4963
|
], exports.EventProcessor);
|
|
4988
|
-
var DEFAULT_RECURSION_LIMIT = 40;
|
|
4989
4964
|
process.setMaxListeners(0);
|
|
4990
4965
|
exports.LangGraphEngine = class LangGraphEngine {
|
|
4991
4966
|
constructor(eventProcessor, configService) {
|
|
@@ -5036,15 +5011,16 @@ exports.LangGraphEngine = class LangGraphEngine {
|
|
|
5036
5011
|
/**
|
|
5037
5012
|
* Method to invoke LangGraph
|
|
5038
5013
|
*/
|
|
5039
|
-
async invokeGraph(graph,
|
|
5014
|
+
async invokeGraph(graph, preparedPayload, signal) {
|
|
5015
|
+
this.logger.debug("invokeGraph preparedPayload", preparedPayload);
|
|
5040
5016
|
if (signal) {
|
|
5041
|
-
|
|
5017
|
+
preparedPayload.signal = signal;
|
|
5018
|
+
this.logger.debug("[ENGINE] Signal assigned to preparedPayload.signal");
|
|
5042
5019
|
}
|
|
5043
|
-
const input = await this.deserializeInput(
|
|
5044
|
-
const recursionLimit = config.recursionLimit ?? DEFAULT_RECURSION_LIMIT;
|
|
5020
|
+
const input = await this.deserializeInput(preparedPayload.input || {});
|
|
5045
5021
|
const result = await graph.invoke(input, {
|
|
5046
|
-
...config,
|
|
5047
|
-
|
|
5022
|
+
...preparedPayload.config,
|
|
5023
|
+
signal: preparedPayload.signal
|
|
5048
5024
|
});
|
|
5049
5025
|
return this.processGraphResult(result);
|
|
5050
5026
|
}
|
|
@@ -5063,22 +5039,12 @@ exports.LangGraphEngine = class LangGraphEngine {
|
|
|
5063
5039
|
this.logger.debug("[ENGINE] Signal assigned to preparedPayload.signal");
|
|
5064
5040
|
}
|
|
5065
5041
|
const input = await this.deserializeInput(preparedPayload.input || {});
|
|
5066
|
-
const recursionLimit = preparedPayload.recursionLimit ?? DEFAULT_RECURSION_LIMIT;
|
|
5067
|
-
this.logger.debug({
|
|
5068
|
-
message: "[ENGINE] Calling streamEvents",
|
|
5069
|
-
hasSignalInPayload: !!preparedPayload.signal,
|
|
5070
|
-
signalAborted: preparedPayload.signal?.aborted,
|
|
5071
|
-
configKeys: Object.keys(preparedPayload.config || {}),
|
|
5072
|
-
hasSignalInConfig: !!preparedPayload.config?.signal
|
|
5073
|
-
});
|
|
5074
5042
|
const eventStream = await graph.streamEvents(input, {
|
|
5075
5043
|
...preparedPayload.config,
|
|
5076
5044
|
signal: preparedPayload.signal,
|
|
5077
5045
|
// Include abort signal
|
|
5078
|
-
version: "v2"
|
|
5046
|
+
version: "v2"
|
|
5079
5047
|
// Important for correct operation
|
|
5080
|
-
recursionLimit
|
|
5081
|
-
// Prevent GraphRecursionError (default is 25)
|
|
5082
5048
|
});
|
|
5083
5049
|
for await (const event of eventStream) {
|
|
5084
5050
|
try {
|
|
@@ -5366,7 +5332,7 @@ function createMetaBuilder(config, versionedGraphService, moduleRef) {
|
|
|
5366
5332
|
}
|
|
5367
5333
|
}
|
|
5368
5334
|
};
|
|
5369
|
-
return versionedBuilder.
|
|
5335
|
+
return versionedBuilder.preparePayload(updatedPayload);
|
|
5370
5336
|
}
|
|
5371
5337
|
}
|
|
5372
5338
|
Object.defineProperty(VersionRouter, "name", { value: className });
|