Skip to content

feat(DocumentMetadata): Add payload support for Document metadata#433

Merged
AlbumenJ merged 4 commits intoagentscope-ai:mainfrom
wuji1428:feat-document-metadata-payload
Jan 4, 2026
Merged

feat(DocumentMetadata): Add payload support for Document metadata#433
AlbumenJ merged 4 commits intoagentscope-ai:mainfrom
wuji1428:feat-document-metadata-payload

Conversation

@wuji1428
Copy link
Contributor

@wuji1428 wuji1428 commented Jan 4, 2026

Description

This PR enhances payload support for DocumentMetadata, allowing the storage of custom business-specific metadata fields.

1. DocumentMetadata Class Enhancements

  • Added payload field: A Map<String, Object> to store custom metadata
  • New constructor: DocumentMetadata(ContentBlock, String, String, Map<String, Object>) with payload parameter
  • Payload access methods:
    • getPayload(): Returns unmodifiable map of all payload fields
    • getPayloadValue(String key): Retrieves individual payload value by key
    • hasPayloadKey(String key): Checks if a payload key exists
  • Builder pattern enhancement:
    • payload(Map<String, Object>): Sets entire payload map
    • addPayload(String key, Object value): Adds individual payload fields

2. Document Class Enhancements

  • Added convenience methods that delegate to metadata:
    • getPayload(): Access payload through Document
    • getPayloadValue(String key): Get individual payload values
    • getPayloadValueAs(String key, Class<T> targetClass): Type-safe payload retrieval with automatic conversion
    • hasPayloadKey(String key): Check payload key existence

3. Store Enhancements

Support for payload storage: All stores now support storing and retrieving documents with payload

  • MilvusStore: Handles payload in search and upsert operations
  • QdrantStore: Supports payload in vector database interactions
  • InMemoryStore: Manages payload in memory-based document storage

4. DocumentConverter Enhancements

Payload building: All converters now build payload maps from source data

  • BailianDocumentConverter
  • HayStackDocumentConverter
  • RAGFlowDocumentConverter
  • DifyDocumentConverter

Testing

  • Complete test coverage for document metadata
  • Test coverage for payload of store class
  • Test coverage for payload of document converter class

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

Related Issues

#305

@wuji1428 wuji1428 requested a review from a team January 4, 2026 08:01
@AlbumenJ AlbumenJ merged commit b19a1de into agentscope-ai:main Jan 4, 2026
4 checks passed
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.

2 participants