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

### 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>
This commit is contained in:
Heyang Wang
2026-03-29 20:17:01 +08:00
committed by GitHub
parent cb78ce0a7b
commit 641b319647
13 changed files with 162 additions and 6 deletions

View File

@@ -28,6 +28,7 @@ class Chunk(Base):
self.id = ""
self.content = ""
self.important_keywords = []
self.tag_kwd = []
self.questions = []
self.create_time = ""
self.create_timestamp = 0.0

View File

@@ -87,8 +87,8 @@ class Document(Base):
return chunks
raise Exception(res.get("message"))
def add_chunk(self, content: str, important_keywords: list[str] = [], questions: list[str] = [], image_base64: str | None = None):
body = {"content": content, "important_keywords": important_keywords, "questions": questions}
def add_chunk(self, content: str, important_keywords: list[str] = [], questions: list[str] = [], image_base64: str | None = None, *, tag_kwd: list[str] = []):
body = {"content": content, "important_keywords": important_keywords, "tag_kwd": tag_kwd, "questions": questions}
if image_base64 is not None:
body["image_base64"] = image_base64
res = self.post(f"/datasets/{self.dataset_id}/documents/{self.id}/chunks", body)