* add ai model upgrade.
This commit is contained in:
@@ -92,7 +92,8 @@ $config->upgrade->execFlow['18_6'] = array('functions' => 'removeProductL
|
||||
$config->upgrade->execFlow['18_7'] = array('functions' => 'processHistoryDataForMetric,metric-updateMetricDate');
|
||||
$config->upgrade->execFlow['18_8'] = array('functions' => 'upgradeTesttaskMembers,deleteGeneralReportBlock,stopOldCron');
|
||||
$config->upgrade->execFlow['18_9'] = array('functions' => 'addDefaultTraincoursePriv,renameBIModule,migrateXuanClientSettings');
|
||||
$config->upgrade->execFlow['20.0.alpha1'] = array('functions' => 'revertStoryCustomFields,hideOA');
|
||||
$config->upgrade->execFlow['18_10_1'] = array('functions' => 'migrateAIModelConfig');
|
||||
$config->upgrade->execFlow['20.0.alpha1'] = array('functions' => 'revertStoryCustomFields,hideOA,migrateAIModelConfig');
|
||||
|
||||
if(!empty($config->isINT))
|
||||
{
|
||||
|
||||
@@ -8469,6 +8469,50 @@ class upgradeModel extends model
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate configured AI model (from pre 18.11) into table.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function migrateAIModelConfig()
|
||||
{
|
||||
$aiSettings = $this->loadModel('setting')->getItems('owner=system&module=ai');
|
||||
if(empty($aiSettings)) return;
|
||||
|
||||
$aiConfig = new stdclass();
|
||||
foreach($aiSettings as $item) $aiConfig->{$item->key} = $item->value;
|
||||
|
||||
$model = new stdclass();
|
||||
$model->type = $aiConfig->type;
|
||||
$model->vendor = $aiConfig->vendor ?: '';
|
||||
$model->enabled = $aiConfig->status == 'on' ? '1' : '0';
|
||||
$model->desc = $aiConfig->description ?: '';
|
||||
$model->createdDate = helper::now();
|
||||
$model->createdBy = 'system';
|
||||
|
||||
$credentials = new stdclass();
|
||||
if($model->type == 'baidu-ernie')
|
||||
{
|
||||
$credentials->secret = $aiConfig->secret ?: '';
|
||||
}
|
||||
else
|
||||
{
|
||||
if($aiConfig->vendor == 'azure')
|
||||
{
|
||||
$credentials->resource = $aiConfig->resource ?: '';
|
||||
$credentials->deployment = $aiConfig->deployment ?: '';
|
||||
}
|
||||
$credentials->key = $aiConfig->key ?: '';
|
||||
}
|
||||
$model->credentials = json_encode($credentials);
|
||||
|
||||
$model->proxy = $aiConfig->proxyType == 'socks5' ? json_encode((object)array('type' => 'socks5', 'addr' => $aiConfig->proxyAddr)) : null;
|
||||
|
||||
$this->dao->insert(TABLE_AI_MODEL)->data($model)->exec();
|
||||
if(!dao::isError()) $this->setting->deleteItems('owner=system&module=ai');
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查办公应用是否有数据,没有就隐藏。
|
||||
* Check if the office app has data, if not, hide it.
|
||||
|
||||
Reference in New Issue
Block a user