Skip to content

feat: enhance conversation metadata handling with improved JSON parsing#119

Merged
chenyme merged 1 commit into
devfrom
enhance_metadata
Jun 3, 2026
Merged

feat: enhance conversation metadata handling with improved JSON parsing#119
chenyme merged 1 commit into
devfrom
enhance_metadata

Conversation

@chenyme

@chenyme chenyme commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

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 follow task model behavior. When follow is 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

  • Bug fix
  • Feature
  • Documentation
  • Refactor
  • Configuration / deployment
  • Security hardening
  • Other

Affected areas

  • Frontend / UI
  • Backend / API
  • Authentication / authorization
  • Conversations / streaming
  • Files / RAG / extraction
  • Model routing / providers
  • MCP / tools
  • Billing / payments
  • Admin console
  • Deployment / Docker / configuration
  • Documentation

Verification

  • cd backend && go test ./internal/application/conversation/...

Screenshots, API examples, or logs

No screenshots or API examples.

Behavior verified by tests:

  • follow metadata tasks use the current conversation model first.
  • follow metadata tasks fall back to the default chat route when the current route fails.
  • Explicit task model configuration does not add fallback candidates.
  • Title and label task errors do not block each other when either task succeeds.
  • Title and label parsers accept the expected structured JSON shapes and limited loose output.

Configuration, migration, and compatibility notes

No database migration, deployment configuration, environment variable, public API, or Swagger contract changes.

Compatibility notes:

  • Existing conversation_task_model = follow behavior is preserved but made more reliable with one fallback attempt.
  • Explicit task model configuration remains strict.
  • Title fallback uses the first user message only when the generated title is empty or unusable.

Documentation

  • Documentation is not needed for this change.
  • Documentation was updated.
  • Documentation still needs to be updated.

Security and privacy

  • No secrets, tokens, credentials, local config, or personal data are included.
  • User data access remains scoped by authenticated user context unless an admin-only path explicitly requires broader access.
  • Security-sensitive behavior was reviewed, including metadata task routing and model fallback behavior.

Checklist

  • I searched existing issues and pull requests.
  • Changes are focused and do not include unrelated refactors.
  • Tests or static verification were run where practical.
  • User-facing behavior, deployment steps, API contracts, or configuration changes are documented.
  • Generated artifacts are included only when this project explicitly requires them.
  • Caches, build output, .pyc files, .env files, and local storage data are not committed.

@chenyme chenyme linked an issue Jun 3, 2026 that may be closed by this pull request
3 tasks
@chenyme
chenyme merged commit 7dcdd8f into dev Jun 3, 2026
4 checks passed
@chenyme
chenyme deleted the enhance_metadata branch June 3, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 生成标题的模型选择跟随会无法生成标题

1 participant