langgenius / dify

Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
https://dify.ai
Other
45.3k stars 6.36k forks source link

The LLM Node change my input {variable} unexpectly #5493

Closed forrestsocool closed 4 days ago

forrestsocool commented 2 months ago

Self Checks

Dify version

0.6.11

Cloud or Self Hosted

Cloud

Steps to reproduce

when there are some special text in the {variable} ,the LLM node will change id unexpectly during the data processing.
the sepcial text is like "\<id:123123>" it is useful when we need to append some additional information.

✔️ Expected Behavior

don't change the {variable}

❌ Actual Behavior

the sepcial text is like "\<id:123123>" is deleted unexpectly

dosubot[bot] commented 2 months ago

Hello @forrestsocool! I'm here to assist you with bug-solving, answering questions, and contributing while you wait for a human maintainer.

The LLM Node in Dify version 0.6.11 might change or delete special text like "" due to how it handles special variables and context variables in the prompt. To prevent this, you can use the Jinja-2 template language supported by the LLM's prompt editor to escape or handle special characters properly. For example:

{% raw %}
<id:123123>
{% endraw %}

Using {% raw %} and {% endraw %} tags in Jinja-2 will ensure that the special text is treated as literal text and not processed or altered by the system [1].

To continue talking to Dosu, mention @dosu.

iamjoel commented 2 months ago

I can't find the way to create a variable which includes special text like . Can you tell me way to create it? @forrestsocool

forrestsocool commented 2 months ago

I can't find the way to create a variable which includes special text like id:123123. Can you tell me way to create it? @forrestsocool

there are several ways In my case, the variable is generated by a upstream LLM node, which is used to distinguish from normal character and used by the downstream LLM/code node. For convenient, you can use the test ui of any node, and just input what u want directly.

forrestsocool commented 2 months ago

@iamjoel

iamjoel commented 2 months ago

I can't find the way to create a variable which includes special text like id:123123. Can you tell me way to create it? @forrestsocool

there are several ways In my case, the variable is generated by a upstream LLM node, which is used to distinguish from normal character and used by the downstream LLM/code node. For convenient, you can use the test ui of any node, and just input what u want directly.

@forrestsocool Can you provide a App DSL?

forrestsocool commented 2 months ago

DSL yml: test (1).zip

To Use: 1.click run 2.input variable as described in the pic 3.check result

intput: image

output: image

@iamjoel

forrestsocool commented 2 months ago

@iamjoel Anything progress?

bslml commented 2 months ago

same issue

iamjoel commented 2 months ago

@takatost some variable value includes special letters would be ignored in prompt.

Prompt:

image

Result:

image image