Skip to content

fix: Fix the generate_prompt method generated an empty string#6464

Open
wangliang181230 wants to merge 1 commit into
1Panel-dev:v2from
wangliang181230:PR/67-fix--generate_prompt--NoneStr
Open

fix: Fix the generate_prompt method generated an empty string#6464
wangliang181230 wants to merge 1 commit into
1Panel-dev:v2from
wangliang181230:PR/67-fix--generate_prompt--NoneStr

Conversation

@wangliang181230

@wangliang181230 wangliang181230 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it?

fix: Fix the generate_prompt method generated an empty string

方法 generate_prompt:修复当原变量值为 None时,该方法生成了空字符串 '' 的问题。
注:调用端并不是生成提示词时,这是错误的,应该返回None,而不是空字符串 ''

修复方案
另外写一个方法;generate_field_value,生成属性值时,逻辑稍微和 generate_prompt 有些不同:

  • 获取变量值的方法:context.get('xxx').get(key, '') 改为 context.get('xxx').get(key),即值为 None 时,不再返回空字符串 ''
  • 当生成的值为 'None' 字符串时,返回 空,即:None

Summary of your change

判断器 做测试:

  1. 修复前:(a=Noneb=None,但 a != b,因为 None != ''
    图片

  2. 修复后:(a=Noneb=Nonea == bNone == None
    图片

Please indicate you've done the following:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

@wangliang181230 wangliang181230 changed the title fix: Fix the generate_prompt method generated a 'None' string fix: Fix the generate_prompt method generated an empty string Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant