feat: enhance conversation metadata handling with improved JSON parsing#119
Merged
Conversation
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.
Summary
Fix conversation metadata generation when the task model is set to
follow.This change makes title and label generation independent from each other and improves the
followtask model behavior. Whenfollowis used, metadata generation now tries the current conversation model first and falls back to the default chat route if the request fails. Explicitly configured task models remain strict and do not fall back to another model.The metadata result parser was also tightened around the expected structured outputs:
{ "title": "..." }{ "labels": ["...", "..."] }It supports code fences, surrounding text, and limited loose JSON for those two shapes only. If title generation still produces no usable title, the first user message is used as a deterministic fallback so conversations do not remain titled “新对话”.
Change type
Affected areas
Verification
cd backend && go test ./internal/application/conversation/...Screenshots, API examples, or logs
No screenshots or API examples.
Behavior verified by tests:
followmetadata tasks use the current conversation model first.followmetadata tasks fall back to the default chat route when the current route fails.Configuration, migration, and compatibility notes
No database migration, deployment configuration, environment variable, public API, or Swagger contract changes.
Compatibility notes:
conversation_task_model = followbehavior is preserved but made more reliable with one fallback attempt.Documentation
Security and privacy
Checklist
.pycfiles,.envfiles, and local storage data are not committed.