feat: Update plugin to version 1.2.0 with new image context features

- Added support for image context in product prompts, allowing images to be sent as URLs or Base64.
- Introduced a new settings page for managing prompt configurations.
- Implemented caching for allowed models per provider to enhance performance.
- Enhanced logging to include image context usage details.
- Added model exclusions management to prevent the use of specific models.
- Updated AJAX controller to handle image context in requests.
- Refactored prompt builder to support image context in prompts.
This commit is contained in:
2025-12-11 20:01:46 +00:00
parent 0a605cf165
commit 732c7ad393
12 changed files with 728 additions and 34 deletions

View File

@@ -33,6 +33,10 @@ class Groq_AI_Provider_Google implements Groq_AI_Provider_Interface {
return false;
}
public function supports_image_context() {
return true;
}
public function fetch_live_models( $api_key ) {
$endpoint = add_query_arg(
[ 'key' => $api_key, 'pageSize' => 100 ],
@@ -92,15 +96,59 @@ class Groq_AI_Provider_Google implements Groq_AI_Provider_Interface {
sprintf( 'https://generativelanguage.googleapis.com/v1beta/models/%s:generateContent', rawurlencode( $model ) )
);
$image_context = isset( $args['image_context'] ) && is_array( $args['image_context'] ) ? $args['image_context'] : [];
$parts = [];
if ( '' !== trim( (string) $system_prompt ) ) {
$parts[] = [
'text' => $system_prompt,
];
}
if ( '' !== trim( (string) $prompt ) ) {
$parts[] = [
'text' => $prompt,
];
}
if ( ! empty( $image_context ) ) {
foreach ( $image_context as $image ) {
if ( empty( $image['data'] ) ) {
continue;
}
$label = isset( $image['label'] ) ? trim( (string) $image['label'] ) : '';
if ( '' !== $label ) {
$parts[] = [
'text' => sprintf(
/* translators: %s: image label */
__( 'Contextafbeelding: %s', 'groq-ai-product-text' ),
$label
),
];
}
$parts[] = [
'inline_data' => [
'mime_type' => ! empty( $image['mime_type'] ) ? $image['mime_type'] : 'image/jpeg',
'data' => $image['data'],
],
];
}
}
if ( empty( $parts ) ) {
$parts[] = [
'text' => $prompt,
];
}
$payload = [
'contents' => [
[
'role' => 'user',
'parts' => [
[
'text' => $system_prompt . "\n\n" . $prompt,
],
],
'parts' => $parts,
],
],
'generationConfig' => [