feat: integrate image_make with MindSpace assets
This commit is contained in:
+32
-4
@@ -26,16 +26,17 @@ function createPool() {
|
||||
if (compact.startsWith('INSERT INTO h5_asset_plugin_configs')) {
|
||||
plugins.set(params[1], {
|
||||
id: params[0], plugin_id: params[1], enabled: params[2], provider: params[3],
|
||||
llm_provider_key_id: params[4], llm_model: params[5], updated_by: params[6],
|
||||
created_at: params[7], updated_at: params[8],
|
||||
llm_provider_key_id: params[4], llm_model: params[5], config_json: params[6],
|
||||
updated_by: params[7], created_at: params[8], updated_at: params[9],
|
||||
});
|
||||
return [{}];
|
||||
}
|
||||
if (compact.startsWith('UPDATE h5_asset_plugin_configs')) {
|
||||
const pluginId = params[6];
|
||||
const pluginId = params[7];
|
||||
plugins.set(pluginId, {
|
||||
...plugins.get(pluginId), enabled: params[0], provider: params[1],
|
||||
llm_provider_key_id: params[2], llm_model: params[3], updated_by: params[4], updated_at: params[5],
|
||||
llm_provider_key_id: params[2], llm_model: params[3], config_json: params[4],
|
||||
updated_by: params[5], updated_at: params[6],
|
||||
});
|
||||
return [{}];
|
||||
}
|
||||
@@ -100,3 +101,30 @@ test('asset plugins reject unknown providers and unsupported LLM bindings', asyn
|
||||
assert.equal(unsupportedLlm.ok, false);
|
||||
assert.match(unsupportedLlm.message, /不支持 LLM/);
|
||||
});
|
||||
|
||||
test('image_make purposes are disabled by default and resolved independently', async () => {
|
||||
const service = createAssetGatewayConfigService(createPool(), { llmProviderService });
|
||||
await service.updateGlobalConfig({ enabled: true }, { updatedBy: 'admin-1' });
|
||||
const result = await service.updatePluginConfig('asset-generate', {
|
||||
enabled: true,
|
||||
provider: 'image_make',
|
||||
purposes: { hero: true, feed_cover: true },
|
||||
}, { updatedBy: 'admin-1' });
|
||||
|
||||
assert.equal(result.ok, true);
|
||||
const plugin = result.config.plugins.find((item) => item.pluginId === 'asset-generate');
|
||||
assert.deepEqual(plugin.purposes, {
|
||||
inline_image: false,
|
||||
hero: true,
|
||||
card_cover: false,
|
||||
feed_cover: true,
|
||||
});
|
||||
assert.equal((await service.resolveImageGenerationPurpose('hero')).ok, true);
|
||||
assert.equal(plugin.llmProviderKeyId, null);
|
||||
assert.equal(plugin.llmModel, null);
|
||||
assert.deepEqual(await service.resolveImageGenerationPurpose('card_cover'), {
|
||||
ok: false,
|
||||
code: 'purpose_disabled',
|
||||
message: '该图片用途未启用,可安全降级到原有流程',
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user