Skip to content

Commit

Permalink
Change the prompt we send for generating titles to use a system message
Browse files Browse the repository at this point in the history
  • Loading branch information
dkotter committed Jul 27, 2023
1 parent a8d37b4 commit 70c8737
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 @@ -649,7 +649,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 @@ -667,9 +667,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 70c8737

Please sign in to comment.