public function test(){
$http=new Client();
$http->request($this->api_url, [
'method' => 'POST',
'headers' => ["Content-Type"=>"application/json",
"Authorization"=>"Bearer ".$this->token,
"Connection"=>"keep-alive",
"Accept-Encoding"=>"gzip, deflate,br",
"Accept"=>"*/*"],
'data' => json_encode([
"model"=>"gpt-3.5-turbo-0613",
"messages"=>[
[
'role' => 'system',
'content' => 'You are a helpful assistant.',
],
[
'role' => 'user',
'content' => '你好',
]
],
"temperature"=> 0.6
]),
'success' => function ($response) {
//echo $response->getBody();
print_r((string)$response->getBody());
},
'error' => function ($exception) {
// echo $exception;
}
]);
}
我对接chatgpt接口时chatgpt响应乱码,没使用流式返回,
但我测试自己写的接口数据是可以正常返回的,这就奇怪了
Windows11
php7.4
workerman v4.1.13
"Accept-Encoding"=>"gzip, deflate,br", 去掉