feat: Add max output tokens setting and integrate with AI content generation
This commit is contained in:
@@ -542,6 +542,14 @@ class Groq_AI_Product_Text_Settings_Page {
|
||||
'groq_ai_product_text_prompts'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'groq_ai_max_output_tokens',
|
||||
__( 'Max output tokens', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||
[ $this, 'render_max_output_tokens_field' ],
|
||||
'groq-ai-product-text-prompts',
|
||||
'groq_ai_product_text_prompts'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'groq_ai_context_fields',
|
||||
__( 'Standaard productcontext', GROQ_AI_PRODUCT_TEXT_DOMAIN ),
|
||||
@@ -1455,6 +1463,25 @@ class Groq_AI_Product_Text_Settings_Page {
|
||||
<?php
|
||||
}
|
||||
|
||||
public function render_max_output_tokens_field() {
|
||||
$settings = $this->plugin->get_settings();
|
||||
$value = isset( $settings['max_output_tokens'] ) ? absint( $settings['max_output_tokens'] ) : 2048;
|
||||
$value = max( 128, min( 8192, $value ) );
|
||||
?>
|
||||
<input type="number"
|
||||
name="<?php echo esc_attr( $this->plugin->get_option_key() ); ?>[max_output_tokens]"
|
||||
min="128"
|
||||
max="8192"
|
||||
step="128"
|
||||
value="<?php echo esc_attr( (string) $value ); ?>"
|
||||
class="small-text"
|
||||
/>
|
||||
<p class="description">
|
||||
<?php esc_html_e( 'Limiet voor lengte van het AI-antwoord. Als teksten afgekapt worden, zet dit hoger (kost vaak wel meer tokens).', GROQ_AI_PRODUCT_TEXT_DOMAIN ); ?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function render_context_fields_field() {
|
||||
$settings = $this->plugin->get_settings();
|
||||
$values = isset( $settings['context_fields'] ) ? $settings['context_fields'] : $this->plugin->get_default_context_fields();
|
||||
|
||||
Reference in New Issue
Block a user