|
...
|
...
|
@@ -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());
|
...
|
...
|
|