小更新,expert库的领域

This commit is contained in:
wangjinlei
2026-07-20 16:25:40 +08:00
parent f09af1d4e4
commit a396ff86da
5 changed files with 66 additions and 21 deletions

View File

@@ -85,14 +85,13 @@ class ExpertFinder extends Base
}
/**
* 启动国家解析:同时启动两条链,分别用不同模型并行处理。
* 只需调一次,两条链各自链式执行直到全部处理完
* 启动国家解析链:只需调一次,链式执行直到全部处理
* 每条任务在 fillExpertCountry 内按 affiliation 上下文长度动态选择模型地址
*/
public function batchFillCountry(){
$service = new ExpertFinderService();
// $chain1 = $service->enqueueNextCountryFill(0, 'FetchExpertCity', '');
$chain2 = $service->enqueueNextCountryFill(0, 'FetchExpertCityOne', 'http://125.39.141.154:10002/v1/chat/completions');
$started = $service->enqueueNextCountryFill(0, 'FetchExpertCityOne', '');
$pending = Db::name('expert')
->where('affiliation', '<>', '')
@@ -101,8 +100,7 @@ class ExpertFinder extends Base
->count();
return jsonSuccess([
// 'chain1_started' => $chain1,
'chain2_started' => $chain2,
'chain_started' => $started,
'pending' => $pending,
]);
}

View File

@@ -6,12 +6,13 @@ use think\queue\Job;
use app\common\ExpertFinderService;
/**
* 队列任务:用本地大模型从 affiliation 推断国家,写入 expert.country_id / country。
* 队列任务:用大模型从 affiliation 推断国家,写入 expert.country_id / country。
* 处理完当前专家后,自动找下一个推入同一队列(链式执行),直到全部处理完。
*
* 支持多队列并行:通过 $data['queue'] 和 $data['chat_url'] 区分不同的链/模型。
* 模型地址:默认不传 chat_url由 ExpertFinderService::fillExpertCountry
* 按 affiliation 长度在本地/远程模型间动态选择;显式传入 chat_url 时强制使用。
*
* 单条任务受本地 LLM 响应时间影响(一般 2-10s常驻 worker 由 QueueJob
* 单条任务受 LLM 响应时间影响(一般 2-10s常驻 worker 由 QueueJob
* 在进程超 6h 或遇致命 DB 错误时主动 exit(1) 让 supervisor 拉起新进程。
*/
class FillExpertCountry
@@ -19,20 +20,20 @@ class FillExpertCountry
public function fire(Job $job, $data)
{
$expertId = intval(isset($data['expert_id']) ? $data['expert_id'] : 0);
$affiliation = isset($data['affiliation']) ? trim((string)$data['affiliation']) : '';
$queue = isset($data['queue']) ? (string)$data['queue'] : 'FetchExperts';
// 留空则每条任务按上下文长度自行选模型,不要把上一条的 URL 固定传下去
$chatUrl = isset($data['chat_url']) ? (string)$data['chat_url'] : '';
$service = new ExpertFinderService();
if ($expertId && $affiliation !== '') {
$service->fillExpertCountry($expertId, $affiliation, $chatUrl);
}
$job->delete();
if ($expertId && $affiliation !== '') {
$service->fillExpertCountry($expertId, $affiliation, $chatUrl);
}
$job->delete();
// 链式:处理完当前专家立刻拉下一个进来
$service->enqueueNextCountryFill(1, $queue, $chatUrl);
// 链式:下一条也不透传固定 URL继续按条动态选模型
$service->enqueueNextCountryFill(1, $queue, '');
}
}