Skip to content

Commit e2a437a

Browse files
release: version 1.2.1
### New Features - **Background Knowledge Base Updates**: Your Knowledge Base now updates in the background, automatically processing updated posts with the help of a cron job. - **URL Crawl Update Option**: Added an option to update existing content from URL Crawls, ensuring your Knowledge Base stays current. ### Bug Fixes - **Chat Timing Display**: Chatbot timing now displays accurately in a 24-hour format. - **Internationalization Compatibility**: Frontend strings are now fully i18n-compatible, making Hyve easier to localize.
2 parents b5e06eb + d94383d commit e2a437a

22 files changed

+344
-191
lines changed

.github/workflows/create-buld-url.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ on:
44
pull_request:
55
types: [opened, synchronize, ready_for_review]
66
branches-ignore:
7-
- 'update_dependencies'
7+
- 'dependabot/**'
88
jobs:
99
dev-zip:
1010
name: Build ZIP and upload to s3
11-
if: github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
11+
if: github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name && github.actor != 'dependabot[bot]'
1212
runs-on: ubuntu-latest
1313
outputs:
1414
branch-name: ${{ steps.retrieve-branch-name.outputs.branch_name }}
@@ -54,7 +54,7 @@ jobs:
5454

5555
comment-on-pr:
5656
name: Comment on PR with links to plugin ZIPs
57-
if: ${{ github.head_ref && github.head_ref != null }}
57+
if: ${{ github.head_ref && github.head_ref != null && github.actor != 'dependabot[bot]' }}
5858
runs-on: ubuntu-latest
5959
needs: dev-zip
6060
env:

assets/images/black-friday.jpg

89.9 KB
Loading

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"automattic/vipwpcs": "^3.0",
3636
"phpcompatibility/php-compatibility": "^9.3",
3737
"phpunit/phpunit": "^9.6",
38-
"yoast/phpunit-polyfills": "^2.0"
38+
"yoast/phpunit-polyfills": "^3.0"
3939
},
4040
"config": {
4141
"platform": {
@@ -51,6 +51,6 @@
5151
"hkulekci/qdrant": "^0.5.7",
5252
"symfony/http-client": "^6.4",
5353
"nyholm/psr7": "^1.8",
54-
"yethee/tiktoken": "^0.6.0"
54+
"yethee/tiktoken": "^0.7.0"
5555
}
5656
}

composer.lock

+28-27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inc/API.php

+17-45
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use ThemeIsle\HyveLite\BaseAPI;
1212
use ThemeIsle\HyveLite\Cosine_Similarity;
1313
use ThemeIsle\HyveLite\Qdrant_API;
14-
use ThemeIsle\HyveLite\Tokenizer;
1514
use ThemeIsle\HyveLite\OpenAI;
1615

1716
/**
@@ -463,55 +462,28 @@ public function get_data( $request ) {
463462
* @throws \Exception If Qdrant API fails.
464463
*/
465464
public function add_data( $request ) {
466-
$data = $request->get_param( 'data' );
467-
$post_id = $data['ID'];
468-
$data = Tokenizer::tokenize( $data );
469-
$chunks = array_column( $data, 'post_content' );
470-
$moderation = OpenAI::instance()->moderate_chunks( $chunks, $post_id );
471-
472-
if ( is_wp_error( $moderation ) ) {
473-
return rest_ensure_response( [ 'error' => $this->get_error_message( $moderation ) ] );
474-
}
475-
476-
if ( true !== $moderation && 'override' !== $request->get_param( 'action' ) ) {
477-
update_post_meta( $post_id, '_hyve_moderation_failed', 1 );
478-
update_post_meta( $post_id, '_hyve_moderation_review', $moderation );
465+
$data = $request->get_param( 'data' );
466+
$post_id = $data['ID'];
467+
$action = $request->get_param( 'action' );
468+
$process = $this->table->add_post( $post_id, $action );
479469

480-
return rest_ensure_response(
481-
[
482-
'error' => __( 'The content failed moderation policies.', 'hyve-lite' ),
483-
'code' => 'content_failed_moderation',
484-
'review' => $moderation,
485-
]
486-
);
487-
}
470+
if ( is_wp_error( $process ) ) {
471+
if ( 'content_failed_moderation' === $process->get_error_code() ) {
472+
$data = $process->get_error_data();
473+
$review = isset( $data['review'] ) ? $data['review'] : [];
488474

489-
if ( 'update' === $request->get_param( 'action' ) ) {
490-
if ( Qdrant_API::is_active() ) {
491-
try {
492-
$delete_result = Qdrant_API::instance()->delete_point( $post_id );
493-
494-
if ( ! $delete_result ) {
495-
throw new \Exception( __( 'Failed to delete point in Qdrant.', 'hyve-lite' ) );
496-
}
497-
} catch ( \Exception $e ) {
498-
return rest_ensure_response( [ 'error' => $e->getMessage() ] );
499-
}
475+
return rest_ensure_response(
476+
[
477+
'error' => $process->get_error_message(),
478+
'code' => $process->get_error_code(),
479+
'review' => $review,
480+
]
481+
);
500482
}
501483

502-
$this->table->delete_by_post_id( $post_id );
503-
delete_post_meta( $post_id, '_hyve_needs_update' );
484+
return rest_ensure_response( [ 'error' => $this->get_error_message( $process ) ] );
504485
}
505486

506-
foreach ( $data as $datum ) {
507-
$id = $this->table->insert( $datum );
508-
$this->table->process_post( $id );
509-
}
510-
511-
update_post_meta( $post_id, '_hyve_added', 1 );
512-
delete_post_meta( $post_id, '_hyve_moderation_failed' );
513-
delete_post_meta( $post_id, '_hyve_moderation_review' );
514-
515487
return rest_ensure_response( true );
516488
}
517489

@@ -574,7 +546,7 @@ public function get_threads( $request ) {
574546
$post_data = [
575547
'ID' => $post_id,
576548
'title' => get_the_title( $post_id ),
577-
'date' => get_the_date( 'd/m/Y g:i A', $post_id ),
549+
'date' => get_the_date( 'c', $post_id ),
578550
'thread' => get_post_meta( $post_id, '_hyve_thread_data', true ),
579551
'thread_id' => get_post_meta( $post_id, '_hyve_thread_id', true ),
580552
];

0 commit comments

Comments
 (0)