更新
This commit is contained in:
parent
cef843725e
commit
703653e25b
@ -33,6 +33,7 @@ class XunFeiController extends BaseApiController
|
|||||||
|
|
||||||
public function chat()
|
public function chat()
|
||||||
{
|
{
|
||||||
|
header('X-Accel-Buffering: no');
|
||||||
$parmas=$this->request->param('content');
|
$parmas=$this->request->param('content');
|
||||||
if(empty($parmas)){
|
if(empty($parmas)){
|
||||||
return $this->success('success');
|
return $this->success('success');
|
||||||
@ -57,12 +58,17 @@ class XunFeiController extends BaseApiController
|
|||||||
if($status != 2){
|
if($status != 2){
|
||||||
$content = $resp['payload']['choices']['text'][0]['content'];
|
$content = $resp['payload']['choices']['text'][0]['content'];
|
||||||
$answer .= $content;
|
$answer .= $content;
|
||||||
|
print($answer);
|
||||||
|
ob_flush(); // 刷新输出缓冲区
|
||||||
|
flush(); // 刷新系统输出缓冲区
|
||||||
}else{
|
}else{
|
||||||
$content = $resp['payload']['choices']['text'][0]['content'];
|
$content = $resp['payload']['choices']['text'][0]['content'];
|
||||||
$answer .= $content;
|
$answer .= $content;
|
||||||
$total_tokens = $resp['payload']['usage']['text']['total_tokens'];
|
$total_tokens = $resp['payload']['usage']['text']['total_tokens'];
|
||||||
print("\n本次消耗token用量:\n");
|
print("\n本次消耗token用量:\n");
|
||||||
print($total_tokens);
|
print($total_tokens);
|
||||||
|
ob_flush(); // 刷新输出缓冲区
|
||||||
|
flush(); // 刷新系统输出缓冲区
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@ -70,11 +76,12 @@ class XunFeiController extends BaseApiController
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ob_flush(); // 刷新输出缓冲区
|
||||||
|
flush(); // 刷新系统输出缓冲区
|
||||||
|
return $this->success('success');
|
||||||
|
|
||||||
print("\n返回结果为:\n");
|
|
||||||
print($answer);
|
|
||||||
} else {
|
} else {
|
||||||
echo "无法连接到 WebSocket 服务器";
|
return $this->fail('无法连接到 WebSocket 服务器');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user