1
This commit is contained in:
@@ -589,7 +589,15 @@ class ExpertFinderService
|
||||
* @param int $delay 延迟秒数(防止打满模型,默认1秒)
|
||||
* @return bool 是否成功推入了一条
|
||||
*/
|
||||
public function enqueueNextCountryFill($delay = 1)
|
||||
/**
|
||||
* 启动国家解析链:找到下一个缺国家的专家推入指定队列。
|
||||
*
|
||||
* @param int $delay 延迟秒数
|
||||
* @param string $queue 队列名(不同队列跑不同 worker,互不阻塞)
|
||||
* @param string $chatUrl 该链使用的模型地址(为空则用默认)
|
||||
* @return bool
|
||||
*/
|
||||
public function enqueueNextCountryFill($delay = 1, $queue = 'FetchExperts', $chatUrl = '')
|
||||
{
|
||||
$row = Db::name('expert')
|
||||
->where('affiliation', '<>', '')
|
||||
@@ -600,19 +608,22 @@ class ExpertFinderService
|
||||
->find();
|
||||
|
||||
if (!$row) {
|
||||
$this->log('[CountryFill] no more pending experts');
|
||||
$this->log('[CountryFill] no more pending experts, queue=' . $queue);
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'expert_id' => intval($row['expert_id']),
|
||||
'affiliation' => trim((string)$row['affiliation']),
|
||||
'queue' => $queue,
|
||||
'chat_url' => $chatUrl,
|
||||
];
|
||||
|
||||
$jobClass = 'app\api\job\FillExpertCountry@fire';
|
||||
if ($delay > 0) {
|
||||
Queue::later($delay, 'app\api\job\FillExpertCountry@fire', $data, 'FetchExpertCity');
|
||||
Queue::later($delay, $jobClass, $data, $queue);
|
||||
} else {
|
||||
Queue::push('app\api\job\FillExpertCountry@fire', $data, 'FetchExpertCity');
|
||||
Queue::push($jobClass, $data, $queue);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -621,7 +632,7 @@ class ExpertFinderService
|
||||
/**
|
||||
* 对单个专家执行国家解析(同步),由队列 Job FillExpertCountry 调用,也可直接调用测试。
|
||||
*/
|
||||
public function fillExpertCountry($expertId, $affiliation)
|
||||
public function fillExpertCountry($expertId, $affiliation, $chatUrl = '')
|
||||
{
|
||||
$affiliation = trim((string)$affiliation);
|
||||
if ($affiliation === '') {
|
||||
@@ -629,8 +640,11 @@ class ExpertFinderService
|
||||
return;
|
||||
}
|
||||
|
||||
$defaultUrl = trim((string)Env::get('expert_country_chat_url', Env::get('citation_chat_url', 'http://chat.taimed.cn/v1/chat/completions')));
|
||||
$url = ($chatUrl !== '') ? $chatUrl : $defaultUrl;
|
||||
|
||||
$resolver = new CountryResolverService([
|
||||
'chat_url' => trim((string)Env::get('expert_country_chat_url', Env::get('citation_chat_url', 'http://chat.taimed.cn/v1/chat/completions'))),
|
||||
'chat_url' => $url,
|
||||
'chat_model' => trim((string)Env::get('expert_country_chat_model', Env::get('citation_chat_model', 'gpt-4.1'))),
|
||||
'api_key' => trim((string)Env::get('expert_country_chat_api_key', Env::get('citation_chat_api_key', ''))),
|
||||
'timeout' => max(20, intval(Env::get('expert_country_chat_timeout', 60))),
|
||||
|
||||
Reference in New Issue
Block a user