fix: handle string input in _get_further_suggestion#1218
Open
JasonOA888 wants to merge 1 commit intoMemTensor:mainfrom
Open
fix: handle string input in _get_further_suggestion#1218JasonOA888 wants to merge 1 commit intoMemTensor:mainfrom
JasonOA888 wants to merge 1 commit intoMemTensor:mainfrom
Conversation
…atibility Fixes MemTensor#1215 ## Root Cause Analysis - API endpoint /suggestions may receive string-type message - _get_further_suggestion expected MessageList (list[dict]) - When string passed, string[-2:] returns last 2 chars - Then msg['role'] causes TypeError: string indices must be integers ## Solution **Short-term (this PR):** Add type check and auto-convert string to MessageList format **Long-term (follow-up):** Add API input validation layer ## Changes - Updated type hint: MessageList | str - Added isinstance check for backward compatibility - Log warning when conversion happens ## Test Plan - [x] String input is converted to [{"role": "user", "content": ...}] - [x] MessageList input still works - [x] Warning logged for string input - [x] No more TypeError ## Impact - Fixes runtime crash - Backward compatible - Graceful degradation
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 #1215
Root Cause
_get_further_suggestionexpected MessageList but received string, causing TypeError.Solution
Changes
Test plan