更新星火认知模型分析信息
This commit is contained in:
parent
76a52dc9d9
commit
1ef7446e43
@ -26,6 +26,7 @@ class AiAianalyse
|
||||
{
|
||||
if ($job->attempts() > 3) {
|
||||
//通过这个方法可以检查这个任务已经重试了几次了
|
||||
$job->delete();
|
||||
}
|
||||
$type_name = Db::name('category_business')->where('id', $data['category_child'])->value('name');
|
||||
$data_field = json_decode($data['data_field'], true);
|
||||
@ -37,7 +38,6 @@ class AiAianalyse
|
||||
try {
|
||||
$chat=new ChatClient($this->app_id,$this->api_key,$this->api_secret);
|
||||
$client = new Client($chat->assembleAuthUrl('wss://spark-api.xf-yun.com/v2.1/chat'));
|
||||
// 连接到 WebSocket 服务器
|
||||
if ($client) {
|
||||
$header = [
|
||||
"app_id" => $this->app_id,
|
||||
@ -69,14 +69,13 @@ class AiAianalyse
|
||||
$response = $client->receive();
|
||||
$resp = json_decode($response, true);
|
||||
$code = $resp["header"]["code"] ?? 0;
|
||||
if($code == 0){
|
||||
$status = $resp["header"]["status"];
|
||||
$content = $resp['payload']['choices']['text'][0]['content'] ?? '';
|
||||
$answer .= $content;
|
||||
if($status == 2){
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
if($code > 0){
|
||||
break;
|
||||
}
|
||||
$status = $resp["header"]["status"];
|
||||
$content = $resp['payload']['choices']['text'][0]['content'] ?? '';
|
||||
$answer .= $content;
|
||||
if($status == 2){
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -85,7 +84,7 @@ class AiAianalyse
|
||||
'update_time' => time(),
|
||||
];
|
||||
unset($data['data'], $data['data_field']);
|
||||
Db::name('user_informationg_demand')->where($data)->fetchSql(false)->update($update_data);
|
||||
Db::name('user_informationg_demand')->where($data)->update($update_data);
|
||||
}
|
||||
} catch (\Exception $e) {}
|
||||
$job->delete();
|
||||
|
Loading…
x
Reference in New Issue
Block a user