作者 赵彬吉

update

... ... @@ -143,7 +143,7 @@ class UpdateSeoTdk extends Command
$this->seo_tdk($project_id);
DB::disconnect('custom_mysql');
}catch (\Exception $e){
echo date('Y-m-d H:i:s') . ' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL;
echo date('Y-m-d H:i:s') . 'line: '. $e->getLine() .' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL;
}
echo date('Y-m-d H:i:s') . ' end: ' . $project_id . PHP_EOL;
}
... ... @@ -366,6 +366,7 @@ class UpdateSeoTdk extends Command
public function ai_send($prompt)
{
$text = Gpt::instance()->openai_chat_qqs($prompt);
echo 'GPT result:' . $text . PHP_EOL;
$text = Common::deal_keywords($text);
return Common::deal_str($text);
}
... ...
... ... @@ -74,7 +74,7 @@ class Common
if (isset($result['texts']['sl']) && isset(Translate::$tls_list[$result['texts']['sl']])) {
$lang = Translate::$tls_list[$result['texts']['sl']]['text'];
} else {
$lang = 'Chinese';
$lang = 'English';
}
}
$str = 'Please answer in '.$lang;
... ...
... ... @@ -14,9 +14,20 @@ use Illuminate\Support\Facades\Log;
*/
class Gpt
{
public $api = 'http://openai.waimaoq.com/';
/**
* 头
* @var string[]
*/
public $header = [
'apikey' => 'UkzZljFv83Z2qBi5YR1o3f2otAVWtug6',
'X-CmerApi-Host' => 'bizopenai.p.cmer.com',
];
public $header = [];
/**
* 请求域名
* @var string
*/
public $api = 'https://api.cmer.com';
private static $instance;
... ... @@ -35,7 +46,7 @@ class Gpt
*/
public function openai_chat_qqs($content, $system_content = '')
{
$url = $this->api . 'v2/openai_chat_qqs';
$url = $this->api . '/v1/openai_chat';
$data = [
'messages' => [],
... ... @@ -57,9 +68,10 @@ class Gpt
->withBody(json_encode($data, JSON_UNESCAPED_UNICODE), 'application/json')
->post($url);
$json = $result->json();
if (!isset($json['text'])) {
if (!isset($json['text']) || $json['code'] !==200) {
Log::error('openai_chat_qqs data:', $data);
Log::error('openai_chat_qqs result:' . (time() - $time), $json === null ? ['null'] : $json);
$json = [];
}
} catch (\Throwable $e) {
Log::error('openai_chat_qqs time ' . (time() - $time) . ' error:' . $e->getMessage());
... ...