@shenghuabi/workflow 1.1.7 → 1.1.9

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/index.mjs CHANGED
@@ -649,7 +649,7 @@ var TemplateFormatService = class extends RootStaticInjectOptions {
649
649
  // packages/workflow/inline/node/chat/main/runner.ts
650
650
  import { jsonParse, yamlParse, markdownParse } from "@cyia/util";
651
651
 
652
- // packages/workflow/inline/node/chat/util/useChat.ts
652
+ // packages/workflow/util/useChat.ts
653
653
  import { inject as inject2 } from "static-injector";
654
654
 
655
655
  // packages/workflow/util/serialize-text-template.ts
@@ -672,7 +672,7 @@ function serializeLexicalTextarea(input, options) {
672
672
  }).trim();
673
673
  }
674
674
 
675
- // packages/workflow/inline/node/chat/util/useChat.ts
675
+ // packages/workflow/util/useChat.ts
676
676
  function useChat() {
677
677
  const contextProvider = inject2(NodeContextToken);
678
678
  const environmentContext = inject2(EnviromentParametersToken);
@@ -794,10 +794,11 @@ var LlmRunner = class extends NodeRunnerBase {
794
794
  streamData.extra.historyList = historyList;
795
795
  this.emitter.send(streamData);
796
796
  return async (id) => {
797
- if (id === RUNNER_ORIGIN_OUTPUT[0].id) {
797
+ if (id === void 0 || id === RUNNER_ORIGIN_OUTPUT[0].id) {
798
798
  return streamData.value;
799
- }
800
- if (id === "format") {
799
+ } else if (id === "historyList") {
800
+ return historyList;
801
+ } else if (id === "format") {
801
802
  let value;
802
803
  switch (config.parseBy) {
803
804
  case "markdown":
@@ -1262,15 +1263,13 @@ var IterationMainConfig = {
1262
1263
 
1263
1264
  // packages/workflow/inline/node/input-params/common.ts
1264
1265
  var NODE_COMMON4 = {
1265
- priority: -100,
1266
+ priority: -999,
1266
1267
  type: "input-params",
1267
- label: `入口`,
1268
- icon: { fontIcon: "chat" },
1269
- disableHead: false,
1270
- disableConnect: false,
1271
- color: "accent",
1272
- help: [`- 入口`].join("\n"),
1273
- outputs: [RUNNER_ORIGIN_OUTPUT]
1268
+ label: `外界输入`,
1269
+ icon: { fontIcon: "input" },
1270
+ disableHead: true,
1271
+ disableConnect: true,
1272
+ color: "primary"
1274
1273
  };
1275
1274
 
1276
1275
  // packages/workflow/inline/node/input-params/node.define.ts
@@ -1296,6 +1295,18 @@ var InputParams_NODE_DEFINE = v10.pipe(
1296
1295
  });
1297
1296
  }),
1298
1297
  v10.title("输入类型")
1298
+ ),
1299
+ editorInput: v10.pipe(
1300
+ v10.optional(v10.boolean()),
1301
+ v10.title("编辑器输入"),
1302
+ valueChange2((fn) => {
1303
+ fn().subscribe(({ list: [value], field }) => {
1304
+ if (value === void 0) {
1305
+ return;
1306
+ }
1307
+ field.context["editorInputChange"](value);
1308
+ });
1309
+ })
1299
1310
  )
1300
1311
  }),
1301
1312
  actions8.wrappers.patch(["div"]),
@@ -1607,11 +1618,6 @@ var ContextBuildService = class {
1607
1618
  template = inject9(TemplateFormatService);
1608
1619
  parser = inject9(WorkflowParserService);
1609
1620
  createWorkflow(input) {
1610
- const result = this.template.parse(
1611
- input.template.flatMap(
1612
- (item) => item.content.map((item2) => item2.type === "text" ? item2.text : "")
1613
- ).join("\n")
1614
- ).list.map((item) => item.value);
1615
1621
  const chatNode = {
1616
1622
  id: "2",
1617
1623
  data: {
@@ -1627,13 +1633,13 @@ var ContextBuildService = class {
1627
1633
  ]
1628
1634
  ]
1629
1635
  },
1630
- value: input.template,
1631
- config: {}
1636
+ config: { value: { value: input.template } }
1632
1637
  },
1633
1638
  type: "chat"
1634
1639
  };
1635
1640
  return {
1636
- nodes: [chatNode]
1641
+ nodes: [chatNode],
1642
+ edges: []
1637
1643
  };
1638
1644
  }
1639
1645
  };
@@ -1645,18 +1651,10 @@ var WorkflowExecService = class {
1645
1651
  parse(data) {
1646
1652
  return this.#parser.parse(data);
1647
1653
  }
1648
- async runParse(define, input, ob, abortSignal) {
1649
- return this.#runner.run(
1650
- define,
1651
- {
1652
- inputs: input.input ?? {},
1653
- environmentParameters: input.environmentParameters
1654
- },
1655
- ob,
1656
- abortSignal
1657
- );
1654
+ async runParse(...args) {
1655
+ return this.#runner.run(...args);
1658
1656
  }
1659
- async exec(data, input, options, ob, abortSignal) {
1657
+ async exec(data, input, options, ob, abortSignal, providers) {
1660
1658
  let define;
1661
1659
  if (data.define) {
1662
1660
  define = data.define;
@@ -1668,7 +1666,7 @@ var WorkflowExecService = class {
1668
1666
  define = res.data;
1669
1667
  }
1670
1668
  try {
1671
- return await this.runParse(define, input, ob, abortSignal);
1669
+ return await this.runParse(define, input, ob, abortSignal, providers);
1672
1670
  } catch (error) {
1673
1671
  if (options.showError) {
1674
1672
  }
@@ -1676,7 +1674,7 @@ var WorkflowExecService = class {
1676
1674
  }
1677
1675
  }
1678
1676
  #contextBuild = inject10(ContextBuildService);
1679
- async agentChat(input, fn, abort) {
1677
+ async agentChat(input, fn, abort, providers) {
1680
1678
  const workflow = this.#contextBuild.createWorkflow(input);
1681
1679
  const subject = new Subject();
1682
1680
  subject.subscribe({
@@ -1687,12 +1685,13 @@ var WorkflowExecService = class {
1687
1685
  const result2 = await this.exec(
1688
1686
  { flow: workflow },
1689
1687
  {
1690
- input: input.input,
1688
+ // inputs: input.inputs,
1691
1689
  environmentParameters: input.environmentParameters
1692
1690
  },
1693
1691
  { showError: true },
1694
1692
  subject,
1695
- abort
1693
+ abort,
1694
+ providers
1696
1695
  );
1697
1696
  return result2;
1698
1697
  }
@@ -1831,6 +1830,7 @@ export {
1831
1830
  createResultData,
1832
1831
  flatFilterHandleList,
1833
1832
  llmModelConfig,
1834
- serializeLexicalTextarea
1833
+ serializeLexicalTextarea,
1834
+ useChat
1835
1835
  };
1836
1836
  //# sourceMappingURL=index.mjs.map