This commit is contained in:
2023-11-28 04:39:36 +08:00
parent a9ac0e48b3
commit dc37274b6c
86 changed files with 2106 additions and 191 deletions

View File

@@ -14,7 +14,7 @@ public static function getSiteSummary($parent_categories, $user_prompt, $model_m
$category_list = implode('|', $parent_categories->pluck('name')->toArray());
$system_prompt = "Based on the website content containing an AI tool, return a valid JSON containing:\n{\n\"is_ai_tool\":(true|false),\n\"ai_tool_name\":\"(AI Tool Name)\",\n\"is_app_web_both\":\"(app|web|both)\",\n\"tagline\":\"(One line tagline in 6-8 words)\",\n\"summary\": \"(Summary of AI tool in 2-3 parapgraphs, 140-180 words using grade 8 US english)\",\n\"pricing_type\": \"(Free|Free Trial|Freemium|Subscription|Usage Based)\",\n\"main_category\": \"(AI Training|Art|Audio|Avatars|Business|Chatbots|Coaching|Content Generation|Data|Dating|Design|Dev|Education|Emailing|Finance|Gaming|GPTs|Health|Legal|Marketing|Music|Networking|Personal Assistance|Planning|Podcasting|Productivity|Project Management|Prompting|Reporting|Research|Sales|Security|SEO|Shopping|Simulation|Social|Speech|Support|Task|Testing|Training|Translation|UI\/UX|Video|Workflow|Writing)\",\n\"keywords\":[\"(Identify relevant keywords for this AI Tool, 1-2 words each, at least)\"],\n\"qna\":[{\"q\":\"Typical FAQ that readers want to know, up to 5 questions\",\"a\":\"Answer of the question\"}]\n}";
$system_prompt = "Based on the website content containing an AI tool, return a valid JSON containing:\n{\n\"is_ai_tool\":(true|false),\n\"ai_tool_name\":\"(AI Tool Name)\",\n\"is_app_web_both\":\"(app|web|both)\",\n\"tagline\":\"(One line tagline in 6-8 words)\",\n\"summary\": \"(Summary of AI tool in 2-3 parapgraphs, 200-240 words using grade 8 US english, start with AI tool name)\",\n\"pricing_type\": \"(Free|Free Trial|Freemium|Subscription|Usage Based)\",\n\"main_category\": \"(AI Training|Art|Audio|Avatars|Business|Chatbots|Coaching|Content Generation|Data|Dating|Design|Dev|Education|Emailing|Finance|Gaming|GPTs|Health|Legal|Marketing|Music|Networking|Personal Assistance|Planning|Podcasting|Productivity|Project Management|Prompting|Reporting|Research|Sales|Security|SEO|Shopping|Simulation|Social|Speech|Support|Task|Testing|Training|Translation|UI\/UX|Video|Workflow|Writing)\",\n\"keywords\":[\"(Identify relevant keywords for this AI Tool, 1-2 words each, at least)\"],\n\"qna\":[{\"q\":\"Typical FAQ that readers want to know, up to 5 questions\",\"a\":\"Answer of the question\"}]\n}";
return self::getChatCompletion($user_prompt, $system_prompt, $openai_config, $model_max_tokens, $timeout);
}

View File

@@ -3,3 +3,4 @@
require 'string_helper.php';
require 'geo_helper.php';
require 'proxy_helper.php';
require 'route_helper.php';

View File

@@ -0,0 +1,13 @@
<?php
if (! function_exists('get_route_search_result')) {
function get_route_search_result($query)
{
return route('front.search.results',
[
'query' => strtolower(urlencode($query)),
]);
}
}

View File

@@ -1,11 +1,42 @@
<?php
use Carbon\Carbon;
use Illuminate\Support\Str;
if (! function_exists('epoch_now_timestamp')) {
function epoch_now_timestamp()
if (! function_exists('dmy')) {
function dmy(Carbon $carbon)
{
return (int) round(microtime(true) * 1000);
return $carbon->format('d M Y');
}
}
if (! function_exists('epoch_now_timestamp')) {
function epoch_now_timestamp($multiplier = 1000)
{
return (int) round(microtime(true) * $multiplier);
}
}
if (! function_exists('add_params_to_url')) {
function add_params_to_url(string $url, array $newParams): string
{
$url = parse_url($url);
parse_str($url['query'] ?? '', $existingParams);
$newQuery = array_merge($existingParams, $newParams);
$newUrl = $url['scheme'].'://'.$url['host'].($url['path'] ?? '');
if ($newQuery) {
$newUrl .= '?'.http_build_query($newQuery);
}
if (isset($url['fragment'])) {
$newUrl .= '#'.$url['fragment'];
}
return $newUrl;
}
}
@@ -175,6 +206,34 @@ function str_first_sentence($str)
}
if (! function_exists('str_extract_sentences')) {
function str_extract_sentences($str, $count = 1)
{
// Split the string at ., !, or ?, including the punctuation in the result
$sentences = preg_split('/([.!?])\s*/', $str, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
$extractedSentences = [];
$currentSentence = '';
foreach ($sentences as $key => $sentence) {
if ($key % 2 == 0) {
// This is a sentence fragment
$currentSentence = $sentence;
} else {
// This is a punctuation mark
$currentSentence .= $sentence;
$extractedSentences[] = trim($currentSentence);
if (count($extractedSentences) >= $count) {
break;
}
}
}
return $extractedSentences;
}
}
if (! function_exists('unslug')) {
function unslug($slug, $delimiter = '-')
{