diff --git a/app/Helpers/FirstParty/OpenAI/OpenAI.php b/app/Helpers/FirstParty/OpenAI/OpenAI.php index e4af1ae..88710db 100644 --- a/app/Helpers/FirstParty/OpenAI/OpenAI.php +++ b/app/Helpers/FirstParty/OpenAI/OpenAI.php @@ -13,7 +13,7 @@ public static function getRssPostMetaGpt3($user_prompt, $model_max_tokens = 1536 $openai_config = 'openai-gpt-3-5-turbo-1106'; - $system_prompt = "Based on given article, populate the following in valid JSON format:\n{\n\"title\":\"(Title based on article)\",\n\"keywords\":[\"(Important keywords in 1-2 words per keyword, letters only)\"],\n\"category\":\"(Updates|Opinions|Features|New Launches|How Tos|Reviews)\",\n\"summary\":\"(Summarise in 50-80 words to help readers understand this article, US grade 9 english)\",\n\"entities\":[\"(List of identified human or business legal entites in 1-2 words per entity, letters only)\"],\n\"society_impact\":\"(Explain in 30-50 words how it impact society on technological aspect, US grade 9 english)\",\n\"society_impact_level\":\"(low|medium|high)\"\n}"; + $system_prompt = "Based on given article, populate the following in valid JSON format:\n{\n\"title\":\"(Title based on article)\",\n\"is_ai_or_tech_news\":(true|false),\n\"is_government_or_political_news\":(true|false),\n\"keywords\":[\"(Important keywords in 1-2 words per keyword, letters only)\"],\n\"category\":\"(Updates|Opinions|Features|New Launches|How Tos|Reviews)\",\n\"summary\":\"(Summarise in 50-80 words to help readers understand this article, US grade 9 english)\",\n\"entities\":[\"(List of identified human or business legal entites in 1-2 words per entity, letters only)\"],\n\"society_impact\":\"(Explain in 30-50 words how it impact society on technological aspect, US grade 9 english)\",\n\"society_impact_level\":\"(low|medium|high)\"\n}"; return self::getChatCompletion($user_prompt, $system_prompt, $openai_config, $model_max_tokens, $timeout); } diff --git a/app/Helpers/Global/string_helper.php b/app/Helpers/Global/string_helper.php index f32c868..6056036 100644 --- a/app/Helpers/Global/string_helper.php +++ b/app/Helpers/Global/string_helper.php @@ -3,6 +3,24 @@ use GrahamCampbell\Markdown\Facades\Markdown; use Illuminate\Support\Str; +if (! function_exists('get_country_names')) { + function get_country_names($lowercase = false) { + $countryCodes = config('platform.country_codes'); + $countryNames = []; + + foreach ($countryCodes as $code => $country) { + $name = $country['name']; + if ($lowercase) { + $name = strtolower($name); + } + $countryNames[] = $name; + } + + return $countryNames; + } +} + + if (! function_exists('is_valid_url')) { function is_valid_url($url) { @@ -162,7 +180,19 @@ function get_domain_from_url($url) { $parse = parse_url($url); - return $parse['host']; + // Check if 'host' key exists in the parsed URL array + if (!isset($parse['host'])) { + return null; // or you can throw an exception or handle this case as per your requirement + } + + $host = $parse['host']; + + // Check if the domain starts with 'www.' and remove it + if (substr($host, 0, 4) === 'www.') { + $host = substr($host, 4); + } + + return $host; } } diff --git a/app/Http/Controllers/Tests/TestController.php b/app/Http/Controllers/Tests/TestController.php index e1971bd..8f39de7 100644 --- a/app/Http/Controllers/Tests/TestController.php +++ b/app/Http/Controllers/Tests/TestController.php @@ -16,6 +16,14 @@ class TestController extends Controller { + public function blacklistkw(Request $request) + { + $country_names = get_country_names(true); + + dd($country_names); + + } + public function prm(Request $request) { $id = $request->input('id'); diff --git a/app/Jobs/Tasks/BrowseRSSLatestNewsTask.php b/app/Jobs/Tasks/BrowseRSSLatestNewsTask.php index 3fbbd9e..ce3418a 100644 --- a/app/Jobs/Tasks/BrowseRSSLatestNewsTask.php +++ b/app/Jobs/Tasks/BrowseRSSLatestNewsTask.php @@ -49,6 +49,8 @@ public static function handleSingle($rss_url, $hours = 3) continue; } + $blacklist_rss_post_keywords = array_merge($blacklist_rss_post_keywords, get_country_names(true)); + foreach ($blacklist_rss_post_keywords as $blacklist_keyword) { if (str_contains(strtolower($title), $blacklist_keyword)) diff --git a/app/Jobs/Tasks/ParseRssPostMetadataTask.php b/app/Jobs/Tasks/ParseRssPostMetadataTask.php index 788d3ff..e2fed0e 100644 --- a/app/Jobs/Tasks/ParseRssPostMetadataTask.php +++ b/app/Jobs/Tasks/ParseRssPostMetadataTask.php @@ -147,6 +147,28 @@ public static function handle(int $rss_post_id) $rss_post->status = 'published'; } + if (!$rss_post->status != 'blocked') + { + if (isset($post_meta_response->output->is_ai_or_tech_news)) + { + if ($post_meta_response->output->is_ai_or_tech_news != true) + { + $rss_post->status = 'blocked'; + } + else + { + if (isset($post_meta_response->output->is_government_or_political_news)) + { + if($post_meta_response->output->is_ai_or_tech_news == true) + { + $rss_post->status = 'blocked'; + } + } + } + } + + } + if ($rss_post->save()) { if ($rss_post->status == 'published') { diff --git a/public/futurewalker-600x400-banner.png b/public/futurewalker-600x400-banner.png new file mode 100644 index 0000000..d5c6467 Binary files /dev/null and b/public/futurewalker-600x400-banner.png differ diff --git a/public/futurewalker-600x400-banner.webp b/public/futurewalker-600x400-banner.webp new file mode 100644 index 0000000..1cdd310 Binary files /dev/null and b/public/futurewalker-600x400-banner.webp differ diff --git a/public/futurewalker-600x600-banner.jpg b/public/futurewalker-600x600-banner.jpg new file mode 100644 index 0000000..2d5864e Binary files /dev/null and b/public/futurewalker-600x600-banner.jpg differ diff --git a/public/futurewalker-600x600-banner.webp b/public/futurewalker-600x600-banner.webp new file mode 100644 index 0000000..741f0bb Binary files /dev/null and b/public/futurewalker-600x600-banner.webp differ diff --git a/routes/tests.php b/routes/tests.php index ddb9e13..5906622 100644 --- a/routes/tests.php +++ b/routes/tests.php @@ -99,6 +99,8 @@ return 'ok'; }); +Route::get('/blacklistkw', [App\Http\Controllers\Tests\TestController::class, 'blacklistkw']); + Route::get('/prm', [App\Http\Controllers\Tests\TestController::class, 'prm']); Route::get('/opml', [App\Http\Controllers\Tests\TestController::class, 'opml']);