更新
This commit is contained in:
parent
688318d22f
commit
fbea31ba7c
@ -30,6 +30,10 @@ class Pusher
|
|||||||
|
|
||||||
public function onMessage(TcpConnection $connection, $data)
|
public function onMessage(TcpConnection $connection, $data)
|
||||||
{
|
{
|
||||||
|
$data=json_decode($data,true);
|
||||||
|
if(isset($data[0])&&$data[0]['content']==''){
|
||||||
|
return $connection->send(['header'=>['code'=>10003,'message'=>'消息不能为空']]);
|
||||||
|
}
|
||||||
if ($data != '') {
|
if ($data != '') {
|
||||||
$client = new Client($this->assembleAuthUrl('wss://spark-api.xf-yun.com/v2.1/chat'));
|
$client = new Client($this->assembleAuthUrl('wss://spark-api.xf-yun.com/v2.1/chat'));
|
||||||
// 连接到 WebSocket 服务器
|
// 连接到 WebSocket 服务器
|
||||||
@ -60,6 +64,9 @@ class Pusher
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if($code==10004){
|
||||||
|
return $connection->send(['header'=>['code'=>10004,'message'=>'上下文超出限制,请清空后重试']]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,15 +91,13 @@ class Pusher
|
|||||||
"chat" => array(
|
"chat" => array(
|
||||||
"domain" => "generalv2",
|
"domain" => "generalv2",
|
||||||
"temperature" => 0.5,
|
"temperature" => 0.5,
|
||||||
"max_tokens" => 1024
|
"max_tokens" => 8192
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$payload = array(
|
$payload = array(
|
||||||
"message" => array(
|
"message" => array(
|
||||||
"text" => array(
|
"text" => $question
|
||||||
array("role" => "user", "content" => $question)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user