Skip to content

Conversation

belloibrahv
Copy link
Contributor

  • Add description field to Rust FieldSchema struct (Arc<str>)
  • Update Python FieldSchema to include description field
  • Extract Pydantic field descriptions during schema creation
  • Update JSON schema builder to include field descriptions
  • Add comprehensive tests for field description functionality

Resolves #1074

- Add description field to Rust FieldSchema struct (Arc<str>)
- Update Python FieldSchema to include description field
- Extract Pydantic field descriptions during schema creation
- Update JSON schema builder to include field descriptions
- Add comprehensive tests for field description functionality

Resolves cocoindex-io#1074
@belloibrahv
Copy link
Contributor Author

@georgeh0 I've implemented the field-level descriptions feature for FieldSchema as requested in #1074. Kindly review when you have time.

Copy link
Member

@georgeh0 georgeh0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Mostly looks good - just one minor thing to fix.

}
// Set field description if available
if let Some(description) = &f.description {
self.set_description(&mut schema, description, field_path.prepend(&f.name));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a problem of description overwrite here.

The schema returned by for_enriched_value_type() above may already have a description. e.g. self.description() is already called in many places based on the type (example).

I think we may concatenate both descriptions (field level + type level, separated by a newline).

Here's one way to do this:

  • Change set_description() to "append" instead of "overwrite" if we already have a description.

  • Instead of calling set_description() here (which is after the type is already processed, so field description are placed after type description), we can pass the description as a argument down to for_enriched_value_type() / for_value_type() / for_basic_value_type() / etc. Then we can call set_description() with the passed-in description right after we create SchemaObject (which is before set_description() called based on type) - this will make sure the type description is added after field descriptions.

Please let me know if there's questions on this. Thanks!

Copy link
Contributor Author

@belloibrahv belloibrahv Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@georgeh0 ,I have added the changes concatenate field and type descriptions instead of overwriting, kindly review it

belloibrahv added a commit to belloibrahv/cocoindex that referenced this pull request Oct 2, 2025
- Modified set_description method to append descriptions with newline separator
- Fixed description overwrite issue where field-level descriptions would replace type-level descriptions
- Added description: None to all FieldSchema initializations to satisfy new field requirement
- Added test to verify description concatenation works correctly
- All existing tests pass (129 passed, 0 failed)

Resolves reviewer feedback about description overwrite in PR cocoindex-io#1087
- Modified set_description method to append descriptions with newline separator
- Fixed description overwrite issue where field-level descriptions would replace type-level descriptions
- Added description: None to all FieldSchema initializations to satisfy new field requirement
- Added comprehensive test to verify description concatenation works correctly
- All existing tests pass (129 passed, 0 failed) with no regressions detected
- Implementation handles both extract_descriptions: true and false scenarios
- Field-level descriptions now properly concatenate with type-level descriptions using newline separator
- Resolves reviewer feedback about description overwrite in PR cocoindex-io#1087
- Changes maintain backward compatibility while fixing the core issue
- Ready for review and testing by the maintainer team
@belloibrahv belloibrahv force-pushed the feature/field-descriptions branch from 25c9b5e to d7db89c Compare October 2, 2025 01:49
@georgeh0
Copy link
Member

georgeh0 commented Oct 2, 2025

Thanks! There're two checks failed. You may install pre-commit hooks and use it to fix automatically:

pre-commit install
pre-commit run --all-files

@badmonster0 badmonster0 closed this Oct 2, 2025
@badmonster0 badmonster0 reopened this Oct 2, 2025
@badmonster0
Copy link
Member

ops sorry closed by accident, this is a great PR, just a final touch on the format. Thanks @belloibrahv !

@belloibrahv
Copy link
Contributor Author

ops sorry closed by accident, this is a great PR, just a final touch on the format. Thanks @belloibrahv !

No problem, thanks for opening the PR back

@belloibrahv
Copy link
Contributor Author

Thanks! There're two checks failed. You may install pre-commit hooks and use it to fix automatically:

pre-commit install
pre-commit run --all-files

I have updated the PR with the required changes as requested, and I ensured that all failing checks were resolved locally. Please help me review when you have time.

@georgeh0
Copy link
Member

georgeh0 commented Oct 2, 2025

Thanks for the PR! Merging.

@georgeh0 georgeh0 merged commit c25d179 into cocoindex-io:main Oct 2, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Enable users providing field-level description and carry it over to JSON schema

3 participants