增加主动更新标题索引的功能
parent
553c66878c
commit
cec2ca565d
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace Isekai\AIToolbox\Job;
|
||||
|
||||
use Job;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Title;
|
||||
|
||||
class UpdateTitleIndexJob extends Job {
|
||||
public function __construct(Title $title, array $params){
|
||||
parent::__construct('IsekaiAIUpdateTitleIndex', $title, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发AI后端更新标题索引
|
||||
*/
|
||||
public function run() {
|
||||
$services = MediaWikiServices::getInstance();
|
||||
$config = $services->getMainConfig();
|
||||
|
||||
$endpoint = $config->get('wgIsekaiAIBackendEndpoint');
|
||||
|
||||
$title = $this->title;
|
||||
$pageTitle = $title->getText();
|
||||
|
||||
$factory = MediaWikiServices::getInstance()->getHttpRequestFactory();
|
||||
$req = $factory->create($endpoint + '/sys/embedding_search/title/update', [
|
||||
'method' => 'POST',
|
||||
'postData' => [
|
||||
'title' => $pageTitle
|
||||
],
|
||||
'timeout' => 10
|
||||
], __METHOD__);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue