From 8fc46dc80c22f7b869d7220e7f03342e3fd7fd70 Mon Sep 17 00:00:00 2001 From: Charles Teh Date: Mon, 25 Sep 2023 20:21:53 +0800 Subject: [PATCH] Update (ai): improve description generation, increase timeout --- app/Helpers/FirstParty/OpenAI/OpenAI.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Helpers/FirstParty/OpenAI/OpenAI.php b/app/Helpers/FirstParty/OpenAI/OpenAI.php index 756fbe7..f8007d4 100644 --- a/app/Helpers/FirstParty/OpenAI/OpenAI.php +++ b/app/Helpers/FirstParty/OpenAI/OpenAI.php @@ -55,7 +55,7 @@ public static function createNewArticleTitle($current_title, $supporting_data) No punctuation in titles especially colons :\n 90-130 characters\n\n - return in following json format {\"main_keyword\":\"(Main Keyword)\",\"title\":\"(Title in 90-130 letters)\",\"short_title\":\"(Short Title in 30-40 letters)\",\"article_type\":\"(How-tos|Guides|Interview|Review|Commentary|Feature|News|Editorial|Report|Research|Case-study|Overview|Tutorial|Update|Spotlight|Insights)\",\"description\":\"(SEO description based on main keyword)\",\"photo_keywords\":[\"photo keyword 1\",\"photo keyword 2\"]}"; + return in following json format {\"main_keyword\":\"(Main Keyword)\",\"title\":\"(Title in 90-130 letters)\",\"short_title\":\"(Short Title in 30-40 letters)\",\"article_type\":\"(How-tos|Guides|Interview|Review|Commentary|Feature|News|Editorial|Report|Research|Case-study|Overview|Tutorial|Update|Spotlight|Insights)\",\"description\":\"(Cliffhanger SEO description based on main keyword, do not start with action verb)\",\"photo_keywords\":[\"photo keyword 1\",\"photo keyword 2\"]}"; $user_prompt = "Article Title: {$current_title}\n Article Description: {$supporting_data}\n"; @@ -94,7 +94,7 @@ public static function suggestArticleTitles($current_title, $supporting_data, $s public static function chatCompletion($system_prompt, $user_prompt, $model) { - $response = Http::timeout(500)->withToken(config('platform.ai.openai.api_key')) + $response = Http::timeout(800)->withToken(config('platform.ai.openai.api_key')) ->post('https://api.openai.com/v1/chat/completions', [ 'model' => $model, 'max_tokens' => 2500,