Skip to content

Commit

Permalink
Merge pull request #545 from 10up/feature/modify-title-prompt
Browse files Browse the repository at this point in the history
Change the prompt we send for generating titles to use a `system` message
  • Loading branch information
Sidsector9 authored Jul 31, 2023
2 parents e667db4 + 70c8737 commit 9af6fea
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions includes/Classifai/Providers/OpenAI/ChatGPT.php
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ public function generate_titles( int $post_id = 0, array $args = [] ) {
*
* @return {string} Prompt.
*/
$prompt = apply_filters( 'classifai_chatgpt_title_prompt', 'Write an SEO-friendly title for the following content that will encourage readers to clickthrough, staying within a range of 40 to 60 characters', $post_id, $args );
$prompt = apply_filters( 'classifai_chatgpt_title_prompt', 'Write an SEO-friendly title for the following content that will encourage readers to clickthrough, staying within a range of 40 to 60 characters.', $post_id, $args );

/**
* Filter the request body before sending to ChatGPT.
Expand All @@ -672,9 +672,13 @@ public function generate_titles( int $post_id = 0, array $args = [] ) {
[
'model' => $this->chatgpt_model,
'messages' => [
[
'role' => 'system',
'content' => $prompt,
],
[
'role' => 'user',
'content' => esc_html( $prompt ) . ': ' . $this->get_content( $post_id, absint( $args['num'] ) * 15, false, $args['content'] ) . '',
'content' => $this->get_content( $post_id, absint( $args['num'] ) * 15, false, $args['content'] ) . '',
],
],
'temperature' => 0.9,
Expand Down

0 comments on commit 9af6fea

Please sign in to comment.