作者 zhl

修改deepseek平台

@@ -47,7 +47,7 @@ class GeoQuestionRes extends Command @@ -47,7 +47,7 @@ class GeoQuestionRes extends Command
47 sleep(300); 47 sleep(300);
48 continue; 48 continue;
49 } 49 }
50 - echo date('Y-m-d H:i:s').'执行的任务id:'.$task_id.PHP_EOL; 50 + $this->output('执行的任务ID:' . $task_id);
51 $geoQuestionModel = new GeoQuestion(); 51 $geoQuestionModel = new GeoQuestion();
52 $taskInfo = $geoQuestionModel->read(['id'=>$task_id]); 52 $taskInfo = $geoQuestionModel->read(['id'=>$task_id]);
53 if ($taskInfo === false) { 53 if ($taskInfo === false) {
@@ -85,23 +85,20 @@ class GeoQuestionRes extends Command @@ -85,23 +85,20 @@ class GeoQuestionRes extends Command
85 GET_RESULT: 85 GET_RESULT:
86 $error_num++; 86 $error_num++;
87 try { 87 try {
88 - if ($error_num >= 3) { 88 + if ($error_num > 3) {
  89 + $this->output('任务ID:' . $task_id . ', 项目ID:' . $taskInfo['project_id'] . ', 平台:' . $platform . ', 问题:' . $question . ', 获取失败.');
89 continue; 90 continue;
90 } 91 }
91 - $this->output('执行平台:' . $platform . '执行次数:' . $error_num); 92 + $this->output('平台:' . $platform . ', 执行次数:' . $error_num);
92 switch ($platform){ 93 switch ($platform){
93 case 'google_ai_overview': 94 case 'google_ai_overview':
94 // overview 数据结构不确定, 需要单独处理数据 95 // overview 数据结构不确定, 需要单独处理数据
95 $data = $geo_service->getGooglePlatformResult($question); 96 $data = $geo_service->getGooglePlatformResult($question);
96 $result = $this->dealGoogleData($data); 97 $result = $this->dealGoogleData($data);
97 break; 98 break;
98 - case 'deep_seek':  
99 - $data = $geo_service->getDeepSeekResult($question);  
100 - $result = $this->dealDeepSeek($data);  
101 - break;  
102 case 'openai-not-network': 99 case 'openai-not-network':
103 - $data = $geo_service->getDeepSeekResult($question,'gpt-4o-mini');  
104 - $result = $this->dealDeepSeek($data,'gpt-4o-mini'); 100 + $data = $geo_service->getChatResult($question, 'gpt-4o-mini');
  101 + $result = $this->dealChatData($data, 'gpt-4o-mini');
105 break; 102 break;
106 default: 103 default:
107 $result = $geo_service->getAiPlatformResult($question, $platform); 104 $result = $geo_service->getAiPlatformResult($question, $platform);
@@ -158,7 +155,7 @@ class GeoQuestionRes extends Command @@ -158,7 +155,7 @@ class GeoQuestionRes extends Command
158 } 155 }
159 $save_data['text'] = json_encode(!empty($data) ? $data : $result,true); 156 $save_data['text'] = json_encode(!empty($data) ? $data : $result,true);
160 $geoLogModel->addReturnId($save_data); 157 $geoLogModel->addReturnId($save_data);
161 - echo '执行结束:'.$platform.PHP_EOL; 158 + $this->output('平台:' . $platform . ' 完成');
162 } 159 }
163 } 160 }
164 $next_time = date('Y-m-d', strtotime('+' . ($projectInfo['geo_frequency'] ?? 3) . ' days')); 161 $next_time = date('Y-m-d', strtotime('+' . ($projectInfo['geo_frequency'] ?? 3) . ' days'));
@@ -168,13 +165,12 @@ class GeoQuestionRes extends Command @@ -168,13 +165,12 @@ class GeoQuestionRes extends Command
168 } 165 }
169 166
170 /** 167 /**
171 - * @remark :获取命中的url  
172 - * @name :getUrl  
173 - * @author :lyh  
174 - * @method :post  
175 - * @time :2025/7/3 16:38 168 + * 获取命中的url
  169 + * @param array $urlArr
  170 + * @param array $result_annotations
  171 + * @return array
176 */ 172 */
177 - public function getUrl($urlArr = [],$result_annotations = []){ 173 + public function getUrl($urlArr = [], $result_annotations = []){
178 $url = []; 174 $url = [];
179 $url_num = []; 175 $url_num = [];
180 if(!empty($urlArr)){ 176 if(!empty($urlArr)){
@@ -187,17 +183,16 @@ class GeoQuestionRes extends Command @@ -187,17 +183,16 @@ class GeoQuestionRes extends Command
187 } 183 }
188 } 184 }
189 } 185 }
190 - return ['url'=>$url,'url_num'=>$url_num]; 186 + return ['url' => $url, 'url_num' => $url_num];
191 } 187 }
192 188
193 /** 189 /**
194 - * @remark :获取命中的关键词  
195 - * @name :getKeywords  
196 - * @author :lyh  
197 - * @method :post  
198 - * @time :2025/7/3 16:26 190 + * 获取命中的关键词
  191 + * @param array $keywordArr
  192 + * @param array $result_text
  193 + * @return array
199 */ 194 */
200 - public function getKeywords($keywordArr = [],$result_text = []){ 195 + public function getKeywords($keywordArr = [], $result_text = []){
201 $keywords = []; 196 $keywords = [];
202 $keywords_num = []; 197 $keywords_num = [];
203 if(!empty($keywordArr) && !empty($result_text)){ 198 if(!empty($keywordArr) && !empty($result_text)){
@@ -210,17 +205,16 @@ class GeoQuestionRes extends Command @@ -210,17 +205,16 @@ class GeoQuestionRes extends Command
210 } 205 }
211 } 206 }
212 } 207 }
213 - return ['keywords'=>$keywords,'keywords_num'=>$keywords_num]; 208 + return ['keywords' => $keywords, 'keywords_num' => $keywords_num];
214 } 209 }
215 210
216 /** 211 /**
217 - * @remark :整合deepSeek  
218 - * @name :requestDeepSeek  
219 - * @author :lyh  
220 - * @method :post  
221 - * @time :2025/7/15 10:58 212 + * 处理 会话 返回数据
  213 + * @param $data
  214 + * @param string $model
  215 + * @return array
222 */ 216 */
223 - public function dealDeepSeek($data,$model = 'DeepSeek'){ 217 + public function dealChatData($data, $model){
224 $result = [ 218 $result = [
225 'code' => 200, 219 'code' => 200,
226 'model' => $model, 220 'model' => $model,
@@ -70,13 +70,12 @@ class GeoService @@ -70,13 +70,12 @@ class GeoService
70 } 70 }
71 71
72 /** 72 /**
73 - * @remark :请求deepSeek数据  
74 - * @name :getDeepSeek  
75 - * @author :lyh  
76 - * @method :post  
77 - * @time :2025/7/15 10:59 73 + * 请求chat会话, 自定义模型
  74 + * @param $content
  75 + * @param string $model
  76 + * @return mixed|string
78 */ 77 */
79 - public function getDeepSeekResult($content,$model = 'deepseek-r1'){ 78 + public function getChatResult($content, $model = 'deepseek-r1'){
80 $url = $this->api_url . 'v1/chat'; 79 $url = $this->api_url . 'v1/chat';
81 switch ($model){ 80 switch ($model){
82 case 'deepseek-r1': 81 case 'deepseek-r1':