fix: prevent AttributeError in parse_vision_messages when llm is None#5023
Open
toller892 wants to merge 1 commit intomem0ai:mainfrom
Open
fix: prevent AttributeError in parse_vision_messages when llm is None#5023toller892 wants to merge 1 commit intomem0ai:mainfrom
toller892 wants to merge 1 commit intomem0ai:mainfrom
Conversation
parse_vision_messages() defaults llm=None (vision disabled), but unconditionally calls get_image_description() → llm.generate_response() for list-typed and image_url-dict content. This crashes with AttributeError: 'NoneType' object has no attribute 'generate_response' when any message uses the standard multimodal content format. Fix: - Fast-path return when llm is None (no vision processing needed) - For list-typed content, check if items actually contain image_url before calling vision processing; pass through text-only lists Fixes mem0ai#4799
dd8f9b5 to
345c2e8
Compare
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.
Problem
parse_vision_messages()defaultsllm=None(vision disabled), but unconditionally callsget_image_description()→llm.generate_response()for list-typed andimage_url-dict content. This crashes with:Triggered by any standard multimodal message format (as produced by OpenAI SDK, LangChain, etc.) when
enable_vision=False(the default).Repro
Fix
llm is None— no vision processing neededimage_urlbefore calling vision processing; pass through text-only lists unchangedRelated
Fixes #4799