Documentation Index
Fetch the complete documentation index at: https://docs.clarifeye.ai/llms.txt
Use this file to discover all available pages before exploring further.
Document tags apply labels to entire documents rather than individual chunks, enabling document-level classification and filtering.
Define the tags you want to apply at the document level:
# Define document tags
document_tags = [
{
"name": "document_type",
"values": ["invoice", "contract", "report"]
},
{
"name": "priority",
"values": ["high", "medium", "low"]
},
{
"name": "department",
"values": ["finance", "legal", "hr"]
}
]
# Create document tags table
doc_tags_table = warehouse.create_document_tags_table(
table_name="doc_classifications",
document_tags=document_tags
)
print(f"Created document tags table: {doc_tags_table.name}")
Apply tags to documents with justification and supporting evidence:
# Write document tags
tags = [
{
"id": "tag-1",
"document_id": "doc-id-123",
"tag_name": "document_type",
"tag_value": "invoice",
"justification": "Contains invoice number and line items",
"verbatim": "Invoice #INV-2024-001"
},
{
"id": "tag-2",
"document_id": "doc-id-123",
"tag_name": "priority",
"tag_value": "high",
"justification": "Amount exceeds $10,000",
"verbatim": "Total: $15,250.00"
},
{
"id": "tag-3",
"document_id": "doc-id-123",
"tag_name": "department",
"tag_value": "finance",
"justification": "Financial document",
"verbatim": None
}
]
doc_tags_table.write_data(tags)
Retrieve document tags:
# Get all document tags
all_tags = doc_tags_table.get_data()
for tag in all_tags:
print(f"Document: {tag['document_id']}")
print(f"Tag: {tag['tag_name']} = {tag['tag_value']}")
print(f"Justification: {tag['justification']}")
print("---")
# Filter by document
doc_tags = doc_tags_table.get_data(document_id="doc-id-123")
# Filter by tag name
type_tags = doc_tags_table.get_data(tag_name="document_type")
Modify existing tags:
# Update a tag value
doc_tags_table.perform_data_operation(
operation="update",
data=[{"tag_value": "urgent"}],
filters={"tag_name": "priority", "document_id": "doc-id-123"}
)
# Delete tags for a document
doc_tags_table.perform_data_operation(
operation="delete",
data=None,
filters={"document_id": "doc-id-old"}
)