Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:10up/classifai into enhancement/…
Browse files Browse the repository at this point in the history
…react-settings-ui-v2
  • Loading branch information
iamdharmesh committed Dec 13, 2024
2 parents 382dbff + 8ebd7d6 commit f18d105
Show file tree
Hide file tree
Showing 23 changed files with 1,108 additions and 1,364 deletions.
3 changes: 3 additions & 0 deletions hookdocs/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
},
"migration-guide-v2-to-v3": {
"title": "Migration guide (version 2 to version 3)"
},
"prompt-examples": {
"title": "Prompt examples"
}
}
19 changes: 19 additions & 0 deletions hookdocs/prompt-examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ClassifAI comes with multiple Features that utilize generative AI. These Features use prompts to generate content. ClassifAI ships with default prompts that have been crafted to work for a wide variety of use cases. However, these prompts may not work best for your use case. To help with this, ClassifAI allows you to create custom prompts that you can tailor to your specific needs.

The following are some example prompts for specific Features and use cases that can be used in place of the default prompts that ship with ClassifAI.

## Image Processing

### Descriptive Text Generator

Generate just alt text for an image:

> You are an assistant that generates alt text for images that are used on a website. Alternative (Alt) Text is a brief text description of an image, and is an essential part of making content accessible. Alt Text is read aloud by screen readers to provide information about the image to the reader. You will be provided with an image and will generate alt text for that image. Try and follow the following guidelines when generating Alt Text: 1. Keep it short, usually 1-2 sentences. 2. Consider key elements of the image, instead of describing every little detail. 3. No need to say "image of" or "picture of". Before returning the text, re-evaluate your response and ensure you're following the above points, in particular ensuring the alt text is short, 1-2 sentences max.
Generate just an image caption:

> You are an assistant that generates captions for images that are used on a website. You will be provided with an image and will generate a caption for that image. Please describe the main item you see in the image, giving details but staying concise. There is no need to say "the image contains" or similar, just describe what is actually in the image.
Generate just an image description:

> You are an assistant that generates descriptions of images that are used on a website. You will be provided with an image and will describe the main item you see in the image, giving details but staying concise. There is no need to say "the image contains" or similar, just describe what is actually in the image. Ensure it is descriptive and accurate but not overly verbose.
14 changes: 7 additions & 7 deletions includes/Classifai/Admin/Notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ public function render_activation_notice() {
/**
* Display a dismissable admin notice when a threshold may need updating.
*
* We used to recommend thresholds between 70-75% but in the latest
* version of the AI Vision API, seems 55% is a better threshold.
* We used to recommend thresholds between 50-55% but in the latest
* version of the AI Vision API, seems 70% is a better threshold.
*/
public function thresholds_update_notice() {
$features = [
Expand All @@ -145,7 +145,7 @@ public function thresholds_update_notice() {
switch ( $feature_instance::ID ) {
case DescriptiveTextGenerator::ID:
$key = 'descriptive_confidence_threshold';
$message = __( 'The previous recommended threshold for descriptive text generation was 75% but we find better results now at around 55%.', 'classifai' );
$message = __( 'The previous recommended threshold for descriptive text generation was 55% but we find better results now at around 70%.', 'classifai' );
break;
}

Expand All @@ -154,8 +154,8 @@ public function thresholds_update_notice() {
continue;
}

// Don't show the notice if the threshold is already at 55% or lower.
if ( $key && isset( $settings[ $key ] ) && $settings[ $key ] <= 55 ) {
// Don't show the notice if the threshold is already at 70% or higher.
if ( $key && isset( $settings[ $key ] ) && $settings[ $key ] >= 70 ) {
continue;
}
?>
Expand All @@ -166,9 +166,9 @@ public function thresholds_update_notice() {
echo wp_kses_post(
sprintf(
// translators: %1$s: Feature specific message; %2$s: URL to Feature settings.
__( 'ClassifAI has updated to the v3.2 of the Azure AI Vision API. %1$s <a href="%2$s">Click here to adjust those settings</a>.', 'classifai' ),
__( 'ClassifAI has updated to the v4.0 of the Azure AI Vision API. %1$s <a href="%2$s">Click here to adjust those settings</a>.', 'classifai' ),
esc_html( $message ),
esc_url( admin_url( "tools.php?page=classifai&tab=image_processing&feature=$name" ) )
esc_url( admin_url( "tools.php?page=classifai#/image_processing/$name" ) )
)
);
?>
Expand Down
9 changes: 9 additions & 0 deletions includes/Classifai/Features/DescriptiveTextGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Classifai\Features;

use Classifai\Providers\Azure\ComputerVision;
use Classifai\Providers\OpenAI\ChatGPT;
use Classifai\Services\ImageProcessing;
use WP_REST_Server;
use WP_REST_Request;
Expand All @@ -21,6 +22,13 @@ class DescriptiveTextGenerator extends Feature {
*/
const ID = 'feature_descriptive_text_generator';

/**
* Prompt for generating descriptive text.
*
* @var string
*/
public $prompt = 'You are an assistant that generates descriptions of images that are used on a website. You will be provided with an image and will describe the main item you see in the image, giving details but staying concise. There is no need to say "the image contains" or similar, just describe what is actually in the image. This text will be important for screen readers, so make sure it is descriptive and accurate but not overly verbose. Before returning the text, re-evaluate your response and ensure you are following the above points, in particular ensuring the text is concise.';

/**
* Constructor.
*/
Expand All @@ -33,6 +41,7 @@ public function __construct() {
// Contains just the providers this feature supports.
$this->supported_providers = [
ComputerVision::ID => __( 'Microsoft Azure AI Vision', 'classifai' ),
ChatGPT::ID => __( 'OpenAI', 'classifai' ),
];
}

Expand Down
2 changes: 1 addition & 1 deletion includes/Classifai/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function computer_vision_max_filesize(): int {
*
* @return {int} Filtered filesize in bytes.
*/
return apply_filters( 'classifai_computer_vision_max_filesize', 4 * MB_IN_BYTES ); // 4MB default.
return apply_filters( 'classifai_computer_vision_max_filesize', 20 * MB_IN_BYTES ); // 20MB default.
}

/**
Expand Down
Loading

0 comments on commit f18d105

Please sign in to comment.