feat(llm): expose model_provider and model_name as node outputs - #226
Open
dparkmit24 wants to merge 1 commit into
Open
feat(llm): expose model_provider and model_name as node outputs#226dparkmit24 wants to merge 1 commit into
dparkmit24 wants to merge 1 commit into
Conversation
|
All contributors on this pull request have signed the CLA. |
Author
|
I have read the CLA Document and I hereby sign the CLA |
Add model_provider and model_name to the LLM node's run outputs so downstream nodes can reference the generation's model identity (e.g. to label each response in a multi-model comparison workflow) instead of hardcoding model names as literal text. The pair is sourced from the model instance already in scope at output assembly - the same values build_model_identity_inputs already exposes to node inputs - reusing that naming convention. Falsy values coerce to empty strings so the outputs always carry both keys without raising.
dparkmit24
force-pushed
the
llm-node-model-identity-outputs
branch
from
July 20, 2026 15:50
9f64d1b to
c46ac3b
Compare
Author
|
recheck |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
!Related Issue
Advances #225
Summary
Adds two top-level string outputs to the LLM node —
model_providerandmodel_name— so downstream nodes can reference the generation's model identity.Use case. I'm building a five-model comparison workflow: five parallel LLM nodes feed a judge node and an Answer node, and each response needs to be labelled with the model that produced it. There's no output variable carrying the model identity today, so the labels have to be hardcoded as literal text in the Answer node — which silently desyncs the moment a node's model is swapped. These outputs let the workflow label each response from the node's actual configuration.
Implementation. The pair is sourced from the model instance already in scope at output assembly — the same values
build_model_identity_inputsalready exposes to node inputs, reusing that naming convention rather than inventingmodel/provider. Falsy values coerce to empty strings so the outputs always carry both keys without raising.self._model_instanceis typed non-optional and is already dereferenced one line earlier, so this introduces no new failure mode.Design choices — proposals, open to change
usage.usageis metering data (tokens, prices, latency); model identity is a different kind of thing, and nesting would mean{{#LLM.usage.model_name#}}for the common case, withusagetyped as an object making sub-field selection clumsier in the picker. That said,usageis a legitimate alternative — happy to move it there if you'd prefer.ModelConfigalready storesproviderandnameseparately and there's no precomputed combined form. Splitting also avoids the ambiguity of a bare model name, since two providers can serve same-named models. Happy to collapse to a single output if you'd rather keep the surface smaller.model, but consistent with what the codebase already calls these values.Companion frontend change
This alone won't surface the outputs in the variable picker — that list is hardcoded in
langgenius/dify's frontend (LLM_OUTPUT_STRUCT, the node's Output panel, and i18n). I'll open a companion PR there once this lands and a graphon release ships. Happy to do that whenever you're ready.Tests
Added to
tests/nodes/llm/test_node.py, mirroring the existingtest_run_emits_model_identity_in_node_result_inputs:uv run pytest tests/nodes/llm/test_node.py→ 51 passed.Note: a full
uv syncfails on ARM macOS buildingllvmlite(transitive viaunstructured→numba), which is unrelated to the LLM node path. I ran the targeted suite with those packages skipped; CI uses Linux wheels, so this doesn't affect the build.Checklist
!Implemented with AI assistance (Claude) using a two-agent workflow, and reviewed by me before submitting.