Fix load_demo_single called with list instead of Context in gradio_web_server#3860
Open
Chessing234 wants to merge 1 commit intolm-sys:mainfrom
Open
Fix load_demo_single called with list instead of Context in gradio_web_server#3860Chessing234 wants to merge 1 commit intolm-sys:mainfrom
Chessing234 wants to merge 1 commit intolm-sys:mainfrom
Conversation
…b_server load_demo calls load_demo_single(models, url_params), passing the global models list where a Context is expected. Since the signature change in 'Code sync (lm-sys#3546)', load_demo_single now dereferences context.text_models and context.models, so any invocation (e.g. the reload-mode code path) raises AttributeError on the list. Wrap the models list in a Context so both attributes resolve correctly.
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.
Fixes #3788.
Bug
load_demoinfastchat/serve/gradio_web_server.pyinvokesload_demo_single(models, url_params), passing the globalmodelslist asthe first positional argument.
load_demo_singlenow expects aContextobject and dereferences
context.text_models/context.models, so thecall raises
AttributeError: 'list' object has no attribute 'text_models'when Gradio fires the demo-load callback (including the
--model-list-mode reloadpath).Root cause
Commit
2c68a13(Code sync, PR #3546) changedload_demo_single'ssignature from
(models, url_params)to(context: Context, query_params)and moved the body to read
context.text_models/context.models, butload_demoin the same file was not updated and still passes the plainlist.
Why the fix is correct
In the standalone (non-multi) server there is no text/vision distinction,
so wrapping the existing
modelslist as bothtext_modelsandmodelson a fresh
Contextpreserves prior behavior exactly:load_demo_singleselects the default model from
context.text_modelsand populates thedropdown choices from
context.models, which both map to the same listthat was previously used directly.
Contextis already imported in thisfile (line 37), and the other caller in
gradio_web_server_multi.pycontinues to pass a fully-populated
Contextunchanged.