Help for code node and llm node #25238
Replies: 1 comment 4 replies
-
Hi @kavyakalivarapu-lab! I'm Dosu and I’m helping the dify team. To access the output of an LLM node in a code node, you need to configure the code node's input variables to reference the LLM node's output. In Dify, each node's outputs are stored in a shared variable pool, and you map them to your code node's function arguments using the variable selector format: Here's how you can do it:
def main(summary_text: str) -> dict:
# Now you can use summary_text, which contains the LLM node's output
print("LLM summary:", summary_text)
return {"result": summary_text} If you want to access other fields (like usage info), use Common pitfalls: Make sure the variable name and selector match exactly, and that the LLM node output is available (the LLM node must run before the code node). If you see "Output result is missing," double-check your variable mapping and output schema in the code node config. For more details and troubleshooting, see this discussion and this PR. Let me know if you need a more specific example based on your node IDs! To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Self Checks
1. Is this request related to a challenge you're experiencing? Tell me about your story.
i am trying to build a simple workflow. on uploading a file sin start node, doc extractor node extracts the text and that text is summarized by llm node. upto this its working fine. My doubt is how to access the llm nodes output in code node to write it in python code. how to access the llm nodes output variable in code node python code? i am running dify on localhost

2. Additional context or comments
No response
Beta Was this translation helpful? Give feedback.
All reactions