Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions includes/admin/feedzy-rss-feeds-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,13 +493,25 @@ private function chat_gpt_rewrite() {
$content = wp_strip_all_tags( $content );
$content = substr( $content, 0, apply_filters( 'feedzy_chat_gpt_content_limit', 3000 ) );
$prompt_content = $this->current_job->data->ChatGPT;
$ai_provider = 'openai';

$additional_data = array(
'ai_provider' => 'openai',
);

if ( isset( $this->current_job->data ) && isset( $this->current_job->data->aiProvider ) ) {
$ai_provider = $this->current_job->data->aiProvider;
$additional_data['ai_provider'] = $this->current_job->data->aiProvider;
}

if (
'openai' === $additional_data['ai_provider'] &&
isset( $this->current_job->data ) && isset( $this->current_job->data->aiModel )
) {
$additional_data['ai_model'] = $this->current_job->data->aiModel;
}

$content = str_replace( array( '{content}' ), array( $content ), $prompt_content );
$openai = new \Feedzy_Rss_Feeds_Pro_Openai();
$rewrite_content = $openai->call_api( $this->settings, $content, '', array( 'ai_provider' => $ai_provider ) );
$rewrite_content = $openai->call_api( $this->settings, $content, '', $additional_data );
// Replace prompt content string for specific cases.
$rewrite_content = str_replace( explode( '{content}', $prompt_content ), '', trim( $rewrite_content, '"' ) );
return $rewrite_content;
Expand Down
35 changes: 29 additions & 6 deletions includes/admin/feedzy-rss-feeds-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,39 @@ public function enqueue_styles_admin() {
$asset_file = include FEEDZY_ABSPATH . '/build/action-popup/index.asset.php';
wp_enqueue_script( $this->plugin_name . '_action_popup', FEEDZY_ABSURL . 'build/action-popup/index.js', array_merge( $asset_file['dependencies'], array( 'wp-editor', 'wp-api' ) ), $asset_file['version'], true );

$openai_model = '';
$open_router_model = '';
$integration_settings = get_option( 'feedzy-rss-feeds-settings', array() );

$all_open_ai_models = apply_filters( 'feedzy_openai_models', array() );
$deprecated_open_ai_models = apply_filters( 'feedzy_openai_deprecated_models', array() );
$active_open_ai_models = array_values( array_diff( $all_open_ai_models, $deprecated_open_ai_models ) );

if ( ! empty( $integration_settings['openai_api_model'] ) ) {
$openai_model = $integration_settings['openai_api_model'];
}

if ( ! empty( $integration_settings['openrouter_api_model'] ) ) {
$open_router_model = $integration_settings['openrouter_api_model'];
}

wp_localize_script(
$this->plugin_name . '_action_popup',
'feedzyData',
array(
'isPro' => feedzy_is_pro(),
'isBusinessPlan' => apply_filters( 'feedzy_is_license_of_type', false, 'business' ),
'isAgencyPlan' => apply_filters( 'feedzy_is_license_of_type', false, 'agency' ),
'apiLicenseStatus' => $this->api_license_status(),
'isHighPrivileges' => current_user_can( 'manage_options' ),
'languageList' => $this->get_lang_list(),
'isPro' => feedzy_is_pro(),
'isBusinessPlan' => apply_filters( 'feedzy_is_license_of_type', false, 'business' ),
'isAgencyPlan' => apply_filters( 'feedzy_is_license_of_type', false, 'agency' ),
'apiLicenseStatus' => $this->api_license_status(),
'isHighPrivileges' => current_user_can( 'manage_options' ),
'languageList' => $this->get_lang_list(),
'integrationSettings' => get_option( 'feedzy-rss-feeds-settings' ),
'integrations' => array(
'openAIModel' => $openai_model,
'openRouterModel' => $open_router_model,
),
'activeOpenAIModels' => $active_open_ai_models,
'deprecatedOpenAIModels' => $deprecated_open_ai_models,
)
);

Expand Down
Loading
Loading