Add (political checks)

This commit is contained in:
2023-11-28 19:32:42 +08:00
parent 50dce76e55
commit 21ae20a600
10 changed files with 66 additions and 2 deletions

View File

@@ -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);
}

View File

@@ -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;
}
}