Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Image generate model disable history mode #1841

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class ImageGenerateNodeSerializer(serializers.Serializer):

prompt = serializers.CharField(required=True, error_messages=ErrMessage.char("提示词(正向)"))

negative_prompt = serializers.CharField(required=False, default='', error_messages=ErrMessage.char("提示词(负向)"))
negative_prompt = serializers.CharField(required=False, error_messages=ErrMessage.char("提示词(负向)"), allow_null=True, allow_blank=True,)
# 多轮对话数量
dialogue_number = serializers.IntegerField(required=True, error_messages=ErrMessage.integer("多轮对话数量"))
dialogue_number = serializers.IntegerField(required=False, default=0, error_messages=ErrMessage.integer("多轮对话数量"))

dialogue_type = serializers.CharField(required=True, error_messages=ErrMessage.char("对话存储类型"))
dialogue_type = serializers.CharField(required=False, default='NODE', error_messages=ErrMessage.char("对话存储类型"))

is_result = serializers.BooleanField(required=False, error_messages=ErrMessage.boolean('是否返回内容'))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码中存在一些小问题和建议:

  1. negative_prompt 的字段属性 allow_null=Trueallow_blank=True 实际上没有使用。可以考虑删除这些不必要的属性。

    修正: 从列表中的第三个元素开始移除这两个属性。

  2. 检查其他地方是否也有类似配置,避免重复设置相同的默认值或允许空格/空串的情况。

以下是修改后的代码示例:

class ImageGenerateNodeSerializer(serializers.Serializer):
    prompt = serializers.CharField(required=True, error_messages=ErrMessage.char("提示词(正向)"))

    
    negative_prompt = serializers.CharField(required=False, default='', error_messages=ErrMessage.char("提示词(负向)"), )
    # 多轮对话数量
    dialogue_number = serializers.IntegerField(required=True, error_messages=ErrMessage.integer("多轮对话数量"))
    
    dialogue_type = serializers.CharField(required=False, default='NODE', error_messages=ErrMessage.char("对话存储类型"))
    
    is_result = serializers.BooleanField(required=False, error_messages=ErrMessage.boolean('是否返回内容'))

请注意,在实际应用中可能还需要根据具体需求调整其他字段(如 default 值)的具体含义。

Expand Down
3 changes: 3 additions & 0 deletions ui/src/workflow/nodes/image-generate/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,12 @@
@wheel="wheel"
title="提示词(负向)"
v-model="form_data.negative_prompt"
placeholder="请描述不想生成的图片内容,比如:颜色、血腥内容"
style="height: 150px"
@submitDialog="submitDialog"
/>
</el-form-item>
<!--
<el-form-item>
<template #label>
<div class="flex-between">
Expand All @@ -178,6 +180,7 @@
:step-strictly="true"
/>
</el-form-item>
-->
<el-form-item label="返回内容" @click.prevent>
<template #label>
<div class="flex align-center">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码的差异看起来有一些地方可能需要改进或优化:

  1. 占位符和描述

    • v-model="form_data.negative_prompt" 中,placeholder 属性是多余的,并且它应该放在 el-form-item 标签内部。
    • 在第一个 el-form-item 之外的部分,注释掉了一些内容。建议将这些评论保留或删除。
  2. 表单项排列

    • 表单内的组件没有明确的布局方式,可能需要通过 CSS 或框架提供的工具来更好地排版显示信息。

以下是修改后的示例代码片段:

- <template #label>
+ <div class="flex-between">

- </template>

- @click.prevent
+ <button>点击我</button>

请注意,具体的调整取决于你使用的前端框架(如 Vue.js)。以上只是一个基本模板的修改指南。如果还有其他问题,请提供更多详细信息,以便进一步协助。

Expand Down
Loading