@shenghuabi/workflow 1.1.2 → 1.1.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/index.js CHANGED
@@ -424,119 +424,80 @@ var v7 = __toESM(require("valibot"), 1);
424
424
  var import_view_angular_core5 = require("@piying/view-angular-core");
425
425
  var ResponseList = ["json", "markdown", "yaml"];
426
426
  var ResponseFormat = ["text", "json_object", "json_schema"];
427
- var CHAT_NODE_DEFINE = v7.looseObject({
428
- data: v7.looseObject({
429
- config: v7.pipe(
430
- v7.object({
431
- llm: v7.optional(llmModelConfig()),
432
- /** 处理时解析 */
433
- responseFormat: v7.pipe(
434
- v7.optional(v7.picklist(ResponseFormat)),
435
- import_view_angular_core5.actions.inputs.patch({
436
- options: [
437
- // 有输入json时
438
- {
439
- label: "自动",
440
- value: void 0,
441
- description: `传入JsonSchema时为[json_schema],否则为[text]`
442
- },
443
- { label: "文本", value: "text" },
444
- {
445
- label: "JSON对象",
446
- value: "json_object",
447
- description: "只限制返回类型为JSON对象,不对字段进行限制"
448
- },
449
- {
450
- label: "JSON格式定义",
451
- value: "json_schema",
452
- description: "限制返回类型为JSON对象,同时限制字段,不建议手动指定,传入JsonSchema后自动启用"
453
- }
454
- ]
455
- }),
456
- v7.title("响应格式")
457
- ),
458
- /** 处理后解析 */
459
- parseBy: v7.pipe(
460
- v7.optional(v7.picklist(ResponseList)),
461
- import_view_angular_core5.actions.inputs.patch({
462
- options: [
463
- { label: "直接返回", value: void 0 },
464
- {
465
- label: "json",
466
- value: "json",
467
- description: `将返回的json代码块内容或原始内容解析为对象`
468
- },
469
- {
470
- label: "markdown",
471
- value: "markdown",
472
- description: `[需要提示词约束]将返回其中的markdown代码块内容或原始内容`
473
- },
474
- {
475
- label: "yaml",
476
- value: "yaml",
477
- description: `[需要提示词约束]将返回的yaml代码块内容或原始内容解析为对象`
478
- }
479
- ]
480
- }),
481
- v7.title("返回解析"),
482
- (0, import_view_angular_core5.valueChange)((fn) => {
483
- fn({ list: [["..", "responseFormat"]] }).subscribe(
484
- ({ list: [value], field }) => {
485
- if ((value ?? "").startsWith("json")) {
486
- if (!field.form.control.value) {
487
- field.form.control.updateValue("json");
488
- }
489
- }
490
- }
491
- );
492
- })
493
- ),
494
- examples: EXAMPLES_DEFINE
427
+ var CHAT_NODE_DEFINE = v7.pipe(
428
+ v7.object({
429
+ llm: v7.optional(llmModelConfig()),
430
+ /** 处理时解析 */
431
+ responseFormat: v7.pipe(
432
+ v7.optional(v7.picklist(ResponseFormat)),
433
+ import_view_angular_core5.actions.inputs.patch({
434
+ options: [
435
+ // 有输入json时
436
+ {
437
+ label: "自动",
438
+ value: void 0,
439
+ description: `传入JsonSchema时为[json_schema],否则为[text]`
440
+ },
441
+ { label: "文本", value: "text" },
442
+ {
443
+ label: "JSON对象",
444
+ value: "json_object",
445
+ description: "只限制返回类型为JSON对象,不对字段进行限制"
446
+ },
447
+ {
448
+ label: "JSON格式定义",
449
+ value: "json_schema",
450
+ description: "限制返回类型为JSON对象,同时限制字段,不建议手动指定,传入JsonSchema后自动启用"
451
+ }
452
+ ]
495
453
  }),
496
- import_view_angular_core5.actions.wrappers.patch(["div"]),
497
- import_view_angular_core5.actions.class.top("grid auto-rows-auto gap-2")
454
+ v7.title("响应格式")
498
455
  ),
456
+ /** 处理后解析 */
457
+ parseBy: v7.pipe(
458
+ v7.optional(v7.picklist(ResponseList)),
459
+ import_view_angular_core5.actions.inputs.patch({
460
+ options: [
461
+ { label: "直接返回", value: void 0 },
462
+ {
463
+ label: "json",
464
+ value: "json",
465
+ description: `将返回的json代码块内容或原始内容解析为对象`
466
+ },
467
+ {
468
+ label: "markdown",
469
+ value: "markdown",
470
+ description: `[需要提示词约束]将返回其中的markdown代码块内容或原始内容`
471
+ },
472
+ {
473
+ label: "yaml",
474
+ value: "yaml",
475
+ description: `[需要提示词约束]将返回的yaml代码块内容或原始内容解析为对象`
476
+ }
477
+ ]
478
+ }),
479
+ v7.title("返回解析"),
480
+ (0, import_view_angular_core5.valueChange)((fn) => {
481
+ fn({ list: [["..", "responseFormat"]] }).subscribe(
482
+ ({ list: [value], field }) => {
483
+ if ((value ?? "").startsWith("json")) {
484
+ if (!field.form.control.value) {
485
+ field.form.control.updateValue("json");
486
+ }
487
+ }
488
+ }
489
+ );
490
+ })
491
+ ),
492
+ examples: EXAMPLES_DEFINE,
499
493
  value: v7.pipe(
500
494
  v7.custom(Boolean),
501
495
  (0, import_view_angular_core5.setComponent)("prompt-list")
502
- // valueChange((fn) => {
503
- // fn({ list: [undefined] }).subscribe(({ list: [value], field }) => {
504
- // if (!Array.isArray(value)) {
505
- // return;
506
- // }
507
- // const inputValue: ChatMessageListInputType = value ?? [];
508
- // // field.context
509
- // // .parseTemplate(
510
- // // inputValue.flatMap((item) =>
511
- // // item.content.map((item) =>
512
- // // item.type === 'text' ? item.text : '',
513
- // // ),
514
- // // ),
515
- // // )
516
- // // .then((value: any) => {
517
- // // if (!value) {
518
- // // return;
519
- // // }
520
- // // field.context.changeHandleData(field, 'input', 1, value);
521
- // // });
522
- // // const list = inputValue
523
- // // .flatMap((item) =>
524
- // // item.content.map((item) =>
525
- // // item.type === 'image_url' ? item.image_url.url : undefined,
526
- // // ),
527
- // // )
528
- // // .filter(Boolean)
529
- // // .map((item) => ({
530
- // // value: `${item}`,
531
- // // label: `${item}`,
532
- // // inputType: `image` as const,
533
- // // }));
534
- // // field.context.changeHandleData(field, 'input', 3, list ?? []);
535
- // });
536
- // }),
537
496
  )
538
- })
539
- });
497
+ }),
498
+ import_view_angular_core5.actions.wrappers.patch(["div"]),
499
+ import_view_angular_core5.actions.class.top("grid auto-rows-auto gap-2")
500
+ );
540
501
 
541
502
  // packages/workflow/inline/node/chat/main/llm.runner.ts
542
503
  var import_static_injector5 = require("static-injector");
@@ -698,11 +659,11 @@ var NodeRunnerBase = class {
698
659
  ) : this.#modelConfig;
699
660
  }
700
661
  getParsedNode(schema) {
701
- const result = v8.safeParse(schema, this.node);
662
+ const result = v8.safeParse(schema, this.node.data.config);
702
663
  if (result.success) {
703
664
  return result.output;
704
665
  }
705
- if (!PROD_ENV) {
666
+ if (typeof PROD_ENV === "undefined" || !PROD_ENV) {
706
667
  console.log(result.issues);
707
668
  }
708
669
  throw new Error(JSON.stringify(result.issues));
@@ -829,9 +790,9 @@ var LlmRunner = class extends NodeRunnerBase {
829
790
  const { metadataList, obj } = await this.getInputChat();
830
791
  const inputJsonSchema = this.inputParams.get(DEFAULT_CHAT_SCHEMA_KEY);
831
792
  const nodeResult = this.getParsedNode(CHAT_NODE_DEFINE);
832
- const config = nodeResult.data.config;
793
+ const config = nodeResult;
833
794
  const examples = config.examples;
834
- const list = nodeResult.data.value;
795
+ const list = nodeResult.value;
835
796
  const historyList = list.map((item) => {
836
797
  const content = this.#format.interpolate(
837
798
  item.content.map((item2) => item2.type === "text" ? item2.text : "").join("\n"),