Skip to content

Commit

Permalink
Keep using the original prompt from the codebase to allow updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdharmesh committed Dec 16, 2024
1 parent 11480be commit 5a6c22b
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
31 changes: 31 additions & 0 deletions includes/Classifai/Features/ContentResizing.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,37 @@ public function get_feature_default_settings(): array {
];
}

/**
* Returns the settings for the feature.
*
* @param string $index The index of the setting to return.
* @return array|mixed
*/
public function get_settings( $index = false ) {
$settings = parent::get_settings( $index );

// Keep using the original prompt from the codebase to allow updates.
if ( $settings && !empty( $settings['condense_text_prompt'] ) ) {
foreach ( $settings['condense_text_prompt'] as $key => $prompt ) {
if( 1 === intval( $prompt['original'] ) ) {
$settings['condense_text_prompt'][ $key ]['prompt'] = $this->condense_prompt;
break;
}
}
}

if ( $settings && !empty( $settings['expand_text_prompt'] ) ) {
foreach ( $settings['expand_text_prompt'] as $key => $prompt ) {
if( 1 === intval( $prompt['original'] ) ) {
$settings['expand_text_prompt'][ $key ]['prompt'] = $this->expand_prompt;
break;
}
}
}

return $settings;
}

/**
* Sanitizes the default feature settings.
*
Expand Down
22 changes: 22 additions & 0 deletions includes/Classifai/Features/DescriptiveTextGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,28 @@ public function get_feature_default_settings(): array {
];
}

/**
* Returns the settings for the feature.
*
* @param string $index The index of the setting to return.
* @return array|mixed
*/
public function get_settings( $index = false ) {
$settings = parent::get_settings( $index );

// Keep using the original prompt from the codebase to allow updates.
if ( $settings && ! empty( $settings[ ChatGPT::ID ]['prompt'] ) ) {
foreach ( $settings[ ChatGPT::ID ]['prompt'] as $key => $prompt ) {
if( 1 === intval( $prompt['original'] ) ) {
$settings[ ChatGPT::ID ]['prompt'][ $key ]['prompt'] = $this->prompt;
break;
}
}
}

return $settings;
}

/**
* Sanitizes the default feature settings.
*
Expand Down
22 changes: 22 additions & 0 deletions includes/Classifai/Features/ExcerptGeneration.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,28 @@ public function get_feature_default_settings(): array {
];
}

/**
* Returns the settings for the feature.
*
* @param string $index The index of the setting to return.
* @return array|mixed
*/
public function get_settings( $index = false ) {
$settings = parent::get_settings( $index );

// Keep using the original prompt from the codebase to allow updates.
if ( $settings && !empty( $settings['generate_excerpt_prompt'] ) ) {
foreach ( $settings['generate_excerpt_prompt'] as $key => $prompt ) {
if( 1 === intval( $prompt['original'] ) ) {
$settings['generate_excerpt_prompt'][ $key ]['prompt'] = $this->prompt;
break;
}
}
}

return $settings;
}

/**
* Sanitizes the default feature settings.
*
Expand Down
22 changes: 22 additions & 0 deletions includes/Classifai/Features/TitleGeneration.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,28 @@ public function get_feature_default_settings(): array {
];
}

/**
* Returns the settings for the feature.
*
* @param string $index The index of the setting to return.
* @return array|mixed
*/
public function get_settings( $index = false ) {
$settings = parent::get_settings( $index );

// Keep using the original prompt from the codebase to allow updates.
if ( $settings && ! empty( $settings['generate_title_prompt'] ) ) {
foreach ( $settings['generate_title_prompt'] as $key => $prompt ) {
if( 1 === intval( $prompt['original'] ) ) {
$settings['generate_title_prompt'][ $key ]['prompt'] = $this->prompt;
break;
}
}
}

return $settings;
}

/**
* Sanitizes the default feature settings.
*
Expand Down

0 comments on commit 5a6c22b

Please sign in to comment.