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
51.13k stars 7.36k forks source link

LLM nodes do not support complex variables in inputs when using Jinja templates #8273

Closed dempfi closed 1 week ago

dempfi commented 1 month ago

Self Checks

Dify version

0.8.0

Cloud or Self Hosted

Cloud

Steps to reproduce

Screenshot 2024-09-11 at 4 13 12 PM

✔️ Expected Behavior

To be able to set any input variable

❌ Actual Behavior

Can only set input variables to primitives like String or Number

dosubot[bot] commented 1 month ago

Hi @dempfi! I'm here to help you with any bugs, questions, or contributions you have for the Dify project. Let's work together to solve this issue!

LLM nodes in Dify version 0.8.0 do not support complex variables in inputs when using Jinja templates because the _fetch_jinja_inputs method in the LLMNode class is designed to handle only simple data types. This method converts complex structures like dictionaries and lists into strings, which limits the ability to use complex variables directly in Jinja templates [1][2].

For handling complex variables, you can use Jinja-2 templates for lightweight data transformation and logic processing. However, the current implementation ensures that all variables are converted to strings, simplifying the handling of inputs but restricting the use of complex variable structures [1][2].

To continue talking to Dosu, mention @dosu.