作者 周海龙

合并分支 'zhl' 到 'master'

修改deepseek平台



查看合并请求 !2436
... ... @@ -47,7 +47,7 @@ class GeoQuestionRes extends Command
sleep(300);
continue;
}
echo date('Y-m-d H:i:s').'执行的任务id:'.$task_id.PHP_EOL;
$this->output('执行的任务ID:' . $task_id);
$geoQuestionModel = new GeoQuestion();
$taskInfo = $geoQuestionModel->read(['id'=>$task_id]);
if ($taskInfo === false) {
... ... @@ -85,23 +85,20 @@ class GeoQuestionRes extends Command
GET_RESULT:
$error_num++;
try {
if ($error_num >= 3) {
if ($error_num > 3) {
$this->output('任务ID:' . $task_id . ', 项目ID:' . $taskInfo['project_id'] . ', 平台:' . $platform . ', 问题:' . $question . ', 获取失败.');
continue;
}
$this->output('执行平台:' . $platform . '执行次数:' . $error_num);
$this->output('平台:' . $platform . ', 执行次数:' . $error_num);
switch ($platform){
case 'google_ai_overview':
// overview 数据结构不确定, 需要单独处理数据
$data = $geo_service->getGooglePlatformResult($question);
$result = $this->dealGoogleData($data);
break;
case 'deep_seek':
$data = $geo_service->getDeepSeekResult($question);
$result = $this->dealDeepSeek($data);
break;
case 'openai-not-network':
$data = $geo_service->getDeepSeekResult($question,'gpt-4o-mini');
$result = $this->dealDeepSeek($data,'gpt-4o-mini');
$data = $geo_service->getChatResult($question, 'gpt-4o-mini');
$result = $this->dealChatData($data, 'gpt-4o-mini');
break;
default:
$result = $geo_service->getAiPlatformResult($question, $platform);
... ... @@ -158,7 +155,7 @@ class GeoQuestionRes extends Command
}
$save_data['text'] = json_encode(!empty($data) ? $data : $result,true);
$geoLogModel->addReturnId($save_data);
echo '执行结束:'.$platform.PHP_EOL;
$this->output('平台:' . $platform . ' 完成');
}
}
$next_time = date('Y-m-d', strtotime('+' . ($projectInfo['geo_frequency'] ?? 3) . ' days'));
... ... @@ -168,13 +165,12 @@ class GeoQuestionRes extends Command
}
/**
* @remark :获取命中的url
* @name :getUrl
* @author :lyh
* @method :post
* @time :2025/7/3 16:38
* 获取命中的url
* @param array $urlArr
* @param array $result_annotations
* @return array
*/
public function getUrl($urlArr = [],$result_annotations = []){
public function getUrl($urlArr = [], $result_annotations = []){
$url = [];
$url_num = [];
if(!empty($urlArr)){
... ... @@ -187,17 +183,16 @@ class GeoQuestionRes extends Command
}
}
}
return ['url'=>$url,'url_num'=>$url_num];
return ['url' => $url, 'url_num' => $url_num];
}
/**
* @remark :获取命中的关键词
* @name :getKeywords
* @author :lyh
* @method :post
* @time :2025/7/3 16:26
* 获取命中的关键词
* @param array $keywordArr
* @param array $result_text
* @return array
*/
public function getKeywords($keywordArr = [],$result_text = []){
public function getKeywords($keywordArr = [], $result_text = []){
$keywords = [];
$keywords_num = [];
if(!empty($keywordArr) && !empty($result_text)){
... ... @@ -210,17 +205,16 @@ class GeoQuestionRes extends Command
}
}
}
return ['keywords'=>$keywords,'keywords_num'=>$keywords_num];
return ['keywords' => $keywords, 'keywords_num' => $keywords_num];
}
/**
* @remark :整合deepSeek
* @name :requestDeepSeek
* @author :lyh
* @method :post
* @time :2025/7/15 10:58
* 处理 会话 返回数据
* @param $data
* @param string $model
* @return array
*/
public function dealDeepSeek($data,$model = 'DeepSeek'){
public function dealChatData($data, $model){
$result = [
'code' => 200,
'model' => $model,
... ...
... ... @@ -70,13 +70,12 @@ class GeoService
}
/**
* @remark :请求deepSeek数据
* @name :getDeepSeek
* @author :lyh
* @method :post
* @time :2025/7/15 10:59
* 请求chat会话, 自定义模型
* @param $content
* @param string $model
* @return mixed|string
*/
public function getDeepSeekResult($content,$model = 'deepseek-r1'){
public function getChatResult($content, $model = 'deepseek-r1'){
$url = $this->api_url . 'v1/chat';
switch ($model){
case 'deepseek-r1':
... ...