Skip to content

feat: support reading tags via API (#12891)#13732

Merged
yingfeng merged 1 commit intoinfiniflow:mainfrom
water-in-stone:feat/export-tag-kwd-field-2
Mar 29, 2026
Merged

feat: support reading tags via API (#12891)#13732
yingfeng merged 1 commit intoinfiniflow:mainfrom
water-in-stone:feat/export-tag-kwd-field-2

Conversation

@water-in-stone
Copy link
Copy Markdown
Contributor

@water-in-stone water-in-stone commented Mar 22, 2026

What problem does this PR solve?

Enable reading Tag Set tags via API (expose tag_kwd field). The result of the queried list chunks is as shown below:

image

Type of change

  • New Feature (non-breaking change which adds functionality)

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. 🌈 python Pull requests that update Python code 🐖api The modified files are located under directory 'api/apps/sdk' 💞 feature Feature request, pull request that fullfill a new feature. 🧪 test Pull requests that update test cases. labels Mar 22, 2026
@water-in-stone
Copy link
Copy Markdown
Contributor Author

@yingfeng PTAL

@water-in-stone water-in-stone force-pushed the feat/export-tag-kwd-field-2 branch from 74c149e to fa0c542 Compare March 22, 2026 03:52
@yingfeng yingfeng added the ci Continue Integration label Mar 23, 2026
@yingfeng yingfeng marked this pull request as draft March 23, 2026 02:45
@yingfeng yingfeng marked this pull request as ready for review March 23, 2026 02:45
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.72%. Comparing base (cb78ce0) to head (e298d6d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13732      +/-   ##
==========================================
- Coverage   98.14%   96.72%   -1.42%     
==========================================
  Files          10       10              
  Lines         702      703       +1     
  Branches      112      112              
==========================================
- Hits          689      680       -9     
- Misses          3        5       +2     
- Partials       10       18       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@water-in-stone water-in-stone force-pushed the feat/export-tag-kwd-field-2 branch 2 times, most recently from a7fbbfd to fdc1eb9 Compare March 23, 2026 10:25
@water-in-stone
Copy link
Copy Markdown
Contributor Author

water-in-stone commented Mar 23, 2026

@yingfeng wait a moment. I will fix all the unit test errors.

@water-in-stone water-in-stone force-pushed the feat/export-tag-kwd-field-2 branch from fdc1eb9 to 4f748c1 Compare March 24, 2026 04:08
@water-in-stone
Copy link
Copy Markdown
Contributor Author

@yingfeng I have fixed all the unit test errors. Please take a look again.

@water-in-stone
Copy link
Copy Markdown
Contributor Author

water-in-stone commented Mar 24, 2026

@yingfeng The unit tests were cancelled, could you please help me re-run all the unit tests?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for exposing chunk tag keywords (tag_kwd) through the API and propagates that field through the Python SDK, retrieval outputs, and test coverage.

Changes:

  • Expose tag_kwd in chunk list/retrieval outputs and SDK chunk objects.
  • Accept and validate tag_kwd on chunk create/update endpoints.
  • Add HTTP API + Python SDK test cases covering tag_kwd.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
api/apps/sdk/doc.py Adds tag_kwd to chunk model/output and validates tag_kwd in add/update chunk endpoints (plus OpenAPI response/request docs in some places).
api/apps/chunk_app.py Adds tag_kwd validation for web chunk create/set flows.
sdk/python/ragflow_sdk/modules/document.py Adds tag_kwd parameter to Python SDK Document.add_chunk() request body.
sdk/python/ragflow_sdk/modules/chunk.py Adds tag_kwd attribute so SDK chunk objects retain the field.
rag/nlp/search.py Includes tag_kwd in retrieval result payloads.
internal/service/chunk.go Includes tag_kwd when building retrieval test results.
test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_add_chunk.py Adds SDK tests/validation for tag_kwd on chunk creation.
test/testcases/test_sdk_api/test_chunk_management_within_dataset/test_update_chunk.py Adds SDK tests for tag_kwd on chunk update.
test/testcases/test_http_api/test_chunk_management_within_dataset/test_add_chunk.py Adds HTTP API tests for tag_kwd on chunk creation and updates validation helper.
test/testcases/test_http_api/test_chunk_management_within_dataset/test_update_chunk.py Adds HTTP API tests for tag_kwd on chunk update.
test/testcases/conftest.py Fixes f-string quoting in token fixture error message.
example/http/chunk_example.sh Adds a curl example showing tag_kwd in list-chunks output.
Comments suppressed due to low confidence (1)

test/testcases/test_http_api/test_chunk_management_within_dataset/test_add_chunk.py:184

  • Inside the expected_code == 0 branch, if res["code"] != 0: assert False is unreachable because the test already asserted res["code"] == expected_code. Removing this dead check will simplify the test and avoid confusion.
        if expected_code == 0:
            validate_chunk_details(dataset_id, document_id, payload, res)
            if res["code"] != 0:
                assert False, res

Comment thread sdk/python/ragflow_sdk/modules/document.py Outdated
Comment thread api/apps/sdk/doc.py
Comment thread sdk/python/ragflow_sdk/modules/document.py Outdated
Comment thread example/http/chunk_example.sh Outdated
@water-in-stone water-in-stone force-pushed the feat/export-tag-kwd-field-2 branch from 68cc845 to 70f6d40 Compare March 25, 2026 03:13
@water-in-stone
Copy link
Copy Markdown
Contributor Author

water-in-stone commented Mar 25, 2026

@yingfeng I have modified my code based on the comments from Copilot. Please take look again.

@water-in-stone water-in-stone force-pushed the feat/export-tag-kwd-field-2 branch 2 times, most recently from f980042 to a4c55dc Compare March 25, 2026 03:17
@yingfeng yingfeng requested a review from yongtenglei March 25, 2026 03:22
Copy link
Copy Markdown
Member

@yongtenglei yongtenglei left a comment

Choose a reason for hiding this comment

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

Hi @water-in-stone

Thank you for your contribution. Codes are all good to me. However, I would like to suggest removing example/http/chunk_example.sh. What do you think? Let me know.

Cheers.

@yingfeng
Copy link
Copy Markdown
Member

Since you've modified API, can you add corresponding adjustments to API documents in this PR?

@water-in-stone water-in-stone force-pushed the feat/export-tag-kwd-field-2 branch 2 times, most recently from 947d6ea to 73aef7a Compare March 29, 2026 07:21
@water-in-stone
Copy link
Copy Markdown
Contributor Author

Hi @water-in-stone

Thank you for your contribution. Codes are all good to me. However, I would like to suggest removing example/http/chunk_example.sh. What do you think? Let me know.

Cheers.

@yongtenglei Thanks for your suggestion. I have removed example/http/chunk_example.sh.

1. add unit tests
2. update HTTP API docs and Python SDK docs
@water-in-stone water-in-stone force-pushed the feat/export-tag-kwd-field-2 branch from 73aef7a to e298d6d Compare March 29, 2026 07:24
@water-in-stone
Copy link
Copy Markdown
Contributor Author

water-in-stone commented Mar 29, 2026

Since you've modified API, can you add corresponding adjustments to API documents in this PR?

@yingfeng Thanks for your suggestion. I have updated the docs corresponding to this PR. Please take a look again.

@yingfeng yingfeng merged commit 641b319 into infiniflow:main Mar 29, 2026
1 check passed
sirj0k3r pushed a commit to sirj0k3r/ragflow that referenced this pull request Apr 2, 2026
### What problem does this PR solve?

Enable reading Tag Set tags via API (expose tag_kwd field). The result
of the queried list chunks is as shown below:

<img width="1422" height="818" alt="image"
src="https://github.com/user-attachments/assets/abd1960a-fe34-489e-9d72-525f8e574938"
/>


### Type of change

- [x] New Feature (non-breaking change which adds functionality)

Co-authored-by: heyang.why <heyang.why@alibaba-inc.com>
writinwaters pushed a commit to writinwaters/ragflow that referenced this pull request Apr 10, 2026
### What problem does this PR solve?

Enable reading Tag Set tags via API (expose tag_kwd field). The result
of the queried list chunks is as shown below:

<img width="1422" height="818" alt="image"
src="https://github.com/user-attachments/assets/abd1960a-fe34-489e-9d72-525f8e574938"
/>


### Type of change

- [x] New Feature (non-breaking change which adds functionality)

Co-authored-by: heyang.why <heyang.why@alibaba-inc.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐖api The modified files are located under directory 'api/apps/sdk' ci Continue Integration 💞 feature Feature request, pull request that fullfill a new feature. 🌈 python Pull requests that update Python code size:L This PR changes 100-499 lines, ignoring generated files. 🧪 test Pull requests that update test cases.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants