Skip to content

Commit

Permalink
release: version 1.2.1
Browse files Browse the repository at this point in the history
### 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.
  • Loading branch information
HardeepAsrani authored Nov 7, 2024
2 parents b5e06eb + d94383d commit e2a437a
Show file tree
Hide file tree
Showing 22 changed files with 344 additions and 191 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/create-buld-url.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on:
pull_request:
types: [opened, synchronize, ready_for_review]
branches-ignore:
- 'update_dependencies'
- 'dependabot/**'
jobs:
dev-zip:
name: Build ZIP and upload to s3
if: github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
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]'
runs-on: ubuntu-latest
outputs:
branch-name: ${{ steps.retrieve-branch-name.outputs.branch_name }}
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:

comment-on-pr:
name: Comment on PR with links to plugin ZIPs
if: ${{ github.head_ref && github.head_ref != null }}
if: ${{ github.head_ref && github.head_ref != null && github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
needs: dev-zip
env:
Expand Down
Binary file added assets/images/black-friday.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"automattic/vipwpcs": "^3.0",
"phpcompatibility/php-compatibility": "^9.3",
"phpunit/phpunit": "^9.6",
"yoast/phpunit-polyfills": "^2.0"
"yoast/phpunit-polyfills": "^3.0"
},
"config": {
"platform": {
Expand All @@ -51,6 +51,6 @@
"hkulekci/qdrant": "^0.5.7",
"symfony/http-client": "^6.4",
"nyholm/psr7": "^1.8",
"yethee/tiktoken": "^0.6.0"
"yethee/tiktoken": "^0.7.0"
}
}
55 changes: 28 additions & 27 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 17 additions & 45 deletions inc/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use ThemeIsle\HyveLite\BaseAPI;
use ThemeIsle\HyveLite\Cosine_Similarity;
use ThemeIsle\HyveLite\Qdrant_API;
use ThemeIsle\HyveLite\Tokenizer;
use ThemeIsle\HyveLite\OpenAI;

/**
Expand Down Expand Up @@ -463,55 +462,28 @@ public function get_data( $request ) {
* @throws \Exception If Qdrant API fails.
*/
public function add_data( $request ) {
$data = $request->get_param( 'data' );
$post_id = $data['ID'];
$data = Tokenizer::tokenize( $data );
$chunks = array_column( $data, 'post_content' );
$moderation = OpenAI::instance()->moderate_chunks( $chunks, $post_id );

if ( is_wp_error( $moderation ) ) {
return rest_ensure_response( [ 'error' => $this->get_error_message( $moderation ) ] );
}

if ( true !== $moderation && 'override' !== $request->get_param( 'action' ) ) {
update_post_meta( $post_id, '_hyve_moderation_failed', 1 );
update_post_meta( $post_id, '_hyve_moderation_review', $moderation );
$data = $request->get_param( 'data' );
$post_id = $data['ID'];
$action = $request->get_param( 'action' );
$process = $this->table->add_post( $post_id, $action );

return rest_ensure_response(
[
'error' => __( 'The content failed moderation policies.', 'hyve-lite' ),
'code' => 'content_failed_moderation',
'review' => $moderation,
]
);
}
if ( is_wp_error( $process ) ) {
if ( 'content_failed_moderation' === $process->get_error_code() ) {
$data = $process->get_error_data();
$review = isset( $data['review'] ) ? $data['review'] : [];

if ( 'update' === $request->get_param( 'action' ) ) {
if ( Qdrant_API::is_active() ) {
try {
$delete_result = Qdrant_API::instance()->delete_point( $post_id );

if ( ! $delete_result ) {
throw new \Exception( __( 'Failed to delete point in Qdrant.', 'hyve-lite' ) );
}
} catch ( \Exception $e ) {
return rest_ensure_response( [ 'error' => $e->getMessage() ] );
}
return rest_ensure_response(
[
'error' => $process->get_error_message(),
'code' => $process->get_error_code(),
'review' => $review,
]
);
}

$this->table->delete_by_post_id( $post_id );
delete_post_meta( $post_id, '_hyve_needs_update' );
return rest_ensure_response( [ 'error' => $this->get_error_message( $process ) ] );
}

foreach ( $data as $datum ) {
$id = $this->table->insert( $datum );
$this->table->process_post( $id );
}

update_post_meta( $post_id, '_hyve_added', 1 );
delete_post_meta( $post_id, '_hyve_moderation_failed' );
delete_post_meta( $post_id, '_hyve_moderation_review' );

return rest_ensure_response( true );
}

Expand Down Expand Up @@ -574,7 +546,7 @@ public function get_threads( $request ) {
$post_data = [
'ID' => $post_id,
'title' => get_the_title( $post_id ),
'date' => get_the_date( 'd/m/Y g:i A', $post_id ),
'date' => get_the_date( 'c', $post_id ),
'thread' => get_post_meta( $post_id, '_hyve_thread_data', true ),
'thread_id' => get_post_meta( $post_id, '_hyve_thread_id', true ),
];
Expand Down
Loading

0 comments on commit e2a437a

Please sign in to comment.