feat: 完善模型能力识别与验证

- 自动识别模型类型、视觉、推理和工具能力并保留手动覆盖

- 使用 AgentScope 工具与视觉探测并统一管理端配置反馈
This commit is contained in:
2026-07-27 19:40:23 +08:00
parent 0dc5c3ca55
commit 567fd12706
21 changed files with 1059 additions and 378 deletions

View File

@@ -0,0 +1,80 @@
package tech.easyflow.ai.service.impl;
import org.junit.Assert;
import org.junit.Test;
import tech.easyflow.ai.entity.Model;
import tech.easyflow.ai.service.capability.ModelCapabilityResolution;
import tech.easyflow.ai.service.capability.ModelCapabilitySource;
import java.lang.reflect.Method;
/**
* 模型能力自动识别与手动覆盖合并规则测试。
*/
public class ModelServiceImplCapabilityOverrideTest {
/**
* 验证用户明确关闭的能力不会被模型库重新打开。
*
* @throws ReflectiveOperationException 无法调用待测试方法时抛出
*/
@Test
public void shouldPreserveExplicitCapabilityOverrides() throws ReflectiveOperationException {
Model model = new Model();
model.setSupportImage(Boolean.FALSE);
model.setSupportThinking(Boolean.FALSE);
model.setSupportTool(Boolean.FALSE);
applyResolvedCapabilities(model, detectedCapabilities());
Assert.assertEquals(Boolean.FALSE, model.getSupportImage());
Assert.assertEquals(Boolean.FALSE, model.getSupportThinking());
Assert.assertEquals(Boolean.FALSE, model.getSupportTool());
}
/**
* 验证空能力值会由模型库自动补齐。
*
* @throws ReflectiveOperationException 无法调用待测试方法时抛出
*/
@Test
public void shouldFillCapabilitiesWhenNotConfigured() throws ReflectiveOperationException {
Model model = new Model();
applyResolvedCapabilities(model, detectedCapabilities());
Assert.assertEquals(Boolean.TRUE, model.getSupportImage());
Assert.assertEquals(Boolean.TRUE, model.getSupportThinking());
Assert.assertEquals(Boolean.TRUE, model.getSupportTool());
}
/**
* 创建模型库已确认的对话能力。
*
* @return 全部开启的模型能力
*/
private ModelCapabilityResolution detectedCapabilities() {
return new ModelCapabilityResolution(
Model.MODEL_TYPES[0],
Boolean.TRUE,
Boolean.TRUE,
Boolean.TRUE,
ModelCapabilitySource.CATALOG);
}
/**
* 调用服务内部的能力合并逻辑。
*
* @param model 待合并模型
* @param resolution 自动识别结果
* @throws ReflectiveOperationException 无法调用待测试方法时抛出
*/
private void applyResolvedCapabilities(Model model, ModelCapabilityResolution resolution)
throws ReflectiveOperationException {
ModelServiceImpl service = new ModelServiceImpl();
Method method = ModelServiceImpl.class.getDeclaredMethod(
"applyResolvedChatCapabilities", Model.class, ModelCapabilityResolution.class);
method.setAccessible(true);
method.invoke(service, model, resolution);
}
}