@shenghuabi/workflow 1.1.2 → 1.1.4

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
@@ -364,126 +364,83 @@ var NODE_COMMON = {
364
364
 
365
365
  // packages/workflow/inline/node/chat/chat.node.define.ts
366
366
  import * as v7 from "valibot";
367
- import {
368
- actions as actions5,
369
- setComponent as setComponent2,
370
- valueChange
371
- } from "@piying/view-angular-core";
367
+ import { actions as actions5, setComponent as setComponent2, valueChange } from "@piying/view-angular-core";
372
368
  var ResponseList = ["json", "markdown", "yaml"];
373
369
  var ResponseFormat = ["text", "json_object", "json_schema"];
374
- var CHAT_NODE_DEFINE = v7.looseObject({
375
- data: v7.looseObject({
376
- config: v7.pipe(
377
- v7.object({
378
- llm: v7.optional(llmModelConfig()),
379
- /** 处理时解析 */
380
- responseFormat: v7.pipe(
381
- v7.optional(v7.picklist(ResponseFormat)),
382
- actions5.inputs.patch({
383
- options: [
384
- // 有输入json时
385
- {
386
- label: "自动",
387
- value: void 0,
388
- description: `传入JsonSchema时为[json_schema],否则为[text]`
389
- },
390
- { label: "文本", value: "text" },
391
- {
392
- label: "JSON对象",
393
- value: "json_object",
394
- description: "只限制返回类型为JSON对象,不对字段进行限制"
395
- },
396
- {
397
- label: "JSON格式定义",
398
- value: "json_schema",
399
- description: "限制返回类型为JSON对象,同时限制字段,不建议手动指定,传入JsonSchema后自动启用"
400
- }
401
- ]
402
- }),
403
- v7.title("响应格式")
404
- ),
405
- /** 处理后解析 */
406
- parseBy: v7.pipe(
407
- v7.optional(v7.picklist(ResponseList)),
408
- actions5.inputs.patch({
409
- options: [
410
- { label: "直接返回", value: void 0 },
411
- {
412
- label: "json",
413
- value: "json",
414
- description: `将返回的json代码块内容或原始内容解析为对象`
415
- },
416
- {
417
- label: "markdown",
418
- value: "markdown",
419
- description: `[需要提示词约束]将返回其中的markdown代码块内容或原始内容`
420
- },
421
- {
422
- label: "yaml",
423
- value: "yaml",
424
- description: `[需要提示词约束]将返回的yaml代码块内容或原始内容解析为对象`
425
- }
426
- ]
427
- }),
428
- v7.title("返回解析"),
429
- valueChange((fn) => {
430
- fn({ list: [["..", "responseFormat"]] }).subscribe(
431
- ({ list: [value], field }) => {
432
- if ((value ?? "").startsWith("json")) {
433
- if (!field.form.control.value) {
434
- field.form.control.updateValue("json");
435
- }
436
- }
437
- }
438
- );
439
- })
440
- ),
441
- examples: EXAMPLES_DEFINE
370
+ var CHAT_NODE_DEFINE = v7.pipe(
371
+ v7.object({
372
+ llm: v7.optional(llmModelConfig()),
373
+ /** 处理时解析 */
374
+ responseFormat: v7.pipe(
375
+ v7.optional(v7.picklist(ResponseFormat)),
376
+ actions5.inputs.patch({
377
+ options: [
378
+ // 有输入json时
379
+ {
380
+ label: "自动",
381
+ value: void 0,
382
+ description: `传入JsonSchema时为[json_schema],否则为[text]`
383
+ },
384
+ { label: "文本", value: "text" },
385
+ {
386
+ label: "JSON对象",
387
+ value: "json_object",
388
+ description: "只限制返回类型为JSON对象,不对字段进行限制"
389
+ },
390
+ {
391
+ label: "JSON格式定义",
392
+ value: "json_schema",
393
+ description: "限制返回类型为JSON对象,同时限制字段,不建议手动指定,传入JsonSchema后自动启用"
394
+ }
395
+ ]
396
+ }),
397
+ v7.title("响应格式")
398
+ ),
399
+ /** 处理后解析 */
400
+ parseBy: v7.pipe(
401
+ v7.optional(v7.picklist(ResponseList)),
402
+ actions5.inputs.patch({
403
+ options: [
404
+ { label: "直接返回", value: void 0 },
405
+ {
406
+ label: "json",
407
+ value: "json",
408
+ description: `将返回的json代码块内容或原始内容解析为对象`
409
+ },
410
+ {
411
+ label: "markdown",
412
+ value: "markdown",
413
+ description: `[需要提示词约束]将返回其中的markdown代码块内容或原始内容`
414
+ },
415
+ {
416
+ label: "yaml",
417
+ value: "yaml",
418
+ description: `[需要提示词约束]将返回的yaml代码块内容或原始内容解析为对象`
419
+ }
420
+ ]
442
421
  }),
443
- actions5.wrappers.patch(["div"]),
444
- actions5.class.top("grid auto-rows-auto gap-2")
422
+ v7.title("返回解析"),
423
+ valueChange((fn) => {
424
+ fn({ list: [["..", "responseFormat"]] }).subscribe(
425
+ ({ list: [value], field }) => {
426
+ if ((value ?? "").startsWith("json")) {
427
+ if (!field.form.control.value) {
428
+ field.form.control.updateValue("json");
429
+ }
430
+ }
431
+ }
432
+ );
433
+ })
445
434
  ),
435
+ examples: EXAMPLES_DEFINE,
446
436
  value: v7.pipe(
447
437
  v7.custom(Boolean),
448
438
  setComponent2("prompt-list")
449
- // valueChange((fn) => {
450
- // fn({ list: [undefined] }).subscribe(({ list: [value], field }) => {
451
- // if (!Array.isArray(value)) {
452
- // return;
453
- // }
454
- // const inputValue: ChatMessageListInputType = value ?? [];
455
- // // field.context
456
- // // .parseTemplate(
457
- // // inputValue.flatMap((item) =>
458
- // // item.content.map((item) =>
459
- // // item.type === 'text' ? item.text : '',
460
- // // ),
461
- // // ),
462
- // // )
463
- // // .then((value: any) => {
464
- // // if (!value) {
465
- // // return;
466
- // // }
467
- // // field.context.changeHandleData(field, 'input', 1, value);
468
- // // });
469
- // // const list = inputValue
470
- // // .flatMap((item) =>
471
- // // item.content.map((item) =>
472
- // // item.type === 'image_url' ? item.image_url.url : undefined,
473
- // // ),
474
- // // )
475
- // // .filter(Boolean)
476
- // // .map((item) => ({
477
- // // value: `${item}`,
478
- // // label: `${item}`,
479
- // // inputType: `image` as const,
480
- // // }));
481
- // // field.context.changeHandleData(field, 'input', 3, list ?? []);
482
- // });
483
- // }),
484
439
  )
485
- })
486
- });
440
+ }),
441
+ actions5.wrappers.patch(["div"]),
442
+ actions5.class.top("grid auto-rows-auto gap-2")
443
+ );
487
444
 
488
445
  // packages/workflow/inline/node/chat/main/llm.runner.ts
489
446
  import { inject as inject2 } from "static-injector";
@@ -645,11 +602,11 @@ var NodeRunnerBase = class {
645
602
  ) : this.#modelConfig;
646
603
  }
647
604
  getParsedNode(schema) {
648
- const result = v8.safeParse(schema, this.node);
605
+ const result = v8.safeParse(schema, this.node.data.config);
649
606
  if (result.success) {
650
607
  return result.output;
651
608
  }
652
- if (!PROD_ENV) {
609
+ if (typeof PROD_ENV === "undefined" || !PROD_ENV) {
653
610
  console.log(result.issues);
654
611
  }
655
612
  throw new Error(JSON.stringify(result.issues));
@@ -776,9 +733,9 @@ var LlmRunner = class extends NodeRunnerBase {
776
733
  const { metadataList, obj } = await this.getInputChat();
777
734
  const inputJsonSchema = this.inputParams.get(DEFAULT_CHAT_SCHEMA_KEY);
778
735
  const nodeResult = this.getParsedNode(CHAT_NODE_DEFINE);
779
- const config = nodeResult.data.config;
736
+ const config = nodeResult;
780
737
  const examples = config.examples;
781
- const list = nodeResult.data.value;
738
+ const list = nodeResult.value;
782
739
  const historyList = list.map((item) => {
783
740
  const content = this.#format.interpolate(
784
741
  item.content.map((item2) => item2.type === "text" ? item2.text : "").join("\n"),