Skip to content

feat: knowledge base document import base - #197

Merged
HardeepAsrani merged 2 commits into
developmentfrom
feat/document-import
Jul 7, 2026
Merged

feat: knowledge base document import base#197
HardeepAsrani merged 2 commits into
developmentfrom
feat/document-import

Conversation

@HardeepAsrani

@HardeepAsrani HardeepAsrani commented Jul 7, 2026

Copy link
Copy Markdown
Member

What this adds

The Hyve Lite base for importing documents into the knowledge base, plus a few improvements surfaced while building it. The actual document parsing and UI live in the Pro companion (Codeinwp/hyve#258); this PR is the shared groundwork.

Part of Codeinwp/hyve#153 (closed by the Pro companion PR).

Changes

  • OpenAI::detect_sensitive_data() scans a block of text for personal data (names with contact details, emails, phone numbers, addresses, IDs, payment details, credentials, health data) and returns a short, value-free summary. The Pro importer uses it to warn before storing a file.
  • Batched moderation. moderate_chunks() now sends chunks to the moderation endpoint in small groups (default 5, filterable via hyve_moderation_batch_size) instead of one request per chunk. Same result, far fewer round-trips on multi-chunk content. Benefits every ingestion source, not just documents.
  • Shared pagination helper BaseAPI::query_page(). List endpoints (get_data, get_threads, and the Pro get_knowledge/get_links/get_documents) now detect a next page by fetching one extra row instead of running a found-rows count. This also fixes a long-standing bug where "Load more" never disappeared once the total exceeded a page.
  • Generic PostsTable status rendering. The shared table accepts an optional renderStatus( post ) render-prop so a caller (the Pro import queue) can render per-row status, while the table itself stays free of feature-specific vocabulary.
  • Documents source tile in the Knowledge Base, shown as a Premium upsell in the free plugin.

Manual QA

  1. Free plugin. Knowledge Base shows a Documents tile behind a Premium upsell.
  2. Pagination. With more than a page of knowledge-base items or messages, "Load more" fetches the next page and disappears on the last page (previously it stayed forever).
  3. Moderation unchanged. Existing ingestion (WordPress posts) still moderates and imports correctly.

Add the Hyve Lite pieces the Pro document importer builds on, plus
related improvements surfaced while building it:

- OpenAI::detect_sensitive_data() to flag personal data before content is
  stored, and batch the moderation endpoint (one request per group of
  chunks instead of one request per chunk).
- Shared BaseAPI::query_page() so list endpoints detect further pages
  without a found-rows count; fixes a stale "Load more" when the total
  exceeds a page.
- PostsTable renders a caller-provided status per row while staying
  generic, used by the Pro import queue.
- A Documents source tile in the Knowledge Base (Premium upsell in free).
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Plugin build for 1432f01 is ready 🛎️!

@HardeepAsrani

Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request

…import

# Conflicts:
#	inc/OpenAI.php

Co-authored-by: HardeepAsrani <2649903+HardeepAsrani@users.noreply.github.com>

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown

@copilot resolve the merge conflicts in this pull request

Merge conflicts resolved. The only conflict was in inc/OpenAI.php where moderate_chunks() had two different approaches for the moderation threshold — I adopted the filter-based apply_filters( 'hyve_moderation_threshold', ... ) from development while keeping the batched moderation logic from this branch. Merged in commit 1432f01.

@HardeepAsrani
HardeepAsrani merged commit fc99e5f into development Jul 7, 2026
6 of 7 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.

3 participants