diff --git a/src/main/java/com/lanyuanxiaoyao/ChatClientFactory.java b/src/main/java/com/lanyuanxiaoyao/ChatClientFactory.java index ebfb9ba..4d92d05 100644 --- a/src/main/java/com/lanyuanxiaoyao/ChatClientFactory.java +++ b/src/main/java/com/lanyuanxiaoyao/ChatClientFactory.java @@ -31,8 +31,8 @@ public class ChatClientFactory { .defaultOptions( OpenAiChatOptions.builder() // .model("deepseek-ai/DeepSeek-R1") - .model("Qwen/Qwen3-8B") - // .model("Qwen/Qwen3-32B") + // .model("Qwen/Qwen3-8B") + .model("Qwen/Qwen3-32B") .build() ) .build() @@ -46,17 +46,17 @@ public class ChatClientFactory { OpenAiChatModel.builder() .openAiApi( OpenAiApi.builder() - .baseUrl(ZHIPU_URL) - .apiKey(ZHIPU_API_KEY) - .completionsPath("/v4/chat/completions") - // .baseUrl(SILICONFLOW_URL) - // .apiKey(SILICONFLOW_API_KEY) + // .baseUrl(ZHIPU_URL) + // .apiKey(ZHIPU_API_KEY) + // .completionsPath("/v4/chat/completions") + .baseUrl(SILICONFLOW_URL) + .apiKey(SILICONFLOW_API_KEY) .build() ) .defaultOptions( OpenAiChatOptions.builder() - .model("glm-4v-flash") - // .model("Qwen/Qwen2.5-VL-72B-Instruct") + // .model("glm-4v-flash") + .model("Qwen/Qwen2.5-VL-72B-Instruct") .build() ) .build() diff --git a/src/main/java/com/lanyuanxiaoyao/PrecariatApplication.java b/src/main/java/com/lanyuanxiaoyao/PrecariatApplication.java index 8f1cd01..87816f3 100644 --- a/src/main/java/com/lanyuanxiaoyao/PrecariatApplication.java +++ b/src/main/java/com/lanyuanxiaoyao/PrecariatApplication.java @@ -2,6 +2,7 @@ package com.lanyuanxiaoyao; import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.FileUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONArray; import cn.hutool.json.JSONObject; @@ -9,6 +10,7 @@ import cn.hutool.json.JSONUtil; import cn.hutool.poi.excel.ExcelUtil; import cn.hutool.poi.excel.ExcelWriter; import jakarta.annotation.Resource; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import lombok.extern.slf4j.Slf4j; @@ -30,14 +32,14 @@ import org.springframework.util.MimeTypeUtils; @SpringBootApplication public class PrecariatApplication implements ApplicationRunner { private final List informationList = List.of( - // new FunctionInformation("数据中心-数据集管理", "/Users/lanyuanxiaoyao/Pictures/星海AI中台/数据中心/数据集管理"), + // new FunctionInformation("数据中心-数据集管理", "C:\\Users\\lanyuanxiaoyao\\Desktop\\星海AI中台\\数据中心\\数据集管理") // new FunctionInformation("数据中心-数据网盘", "/Users/lanyuanxiaoyao/Pictures/星海AI中台/数据中心/数据网盘"), // new FunctionInformation("数据中心-数据审批", "/Users/lanyuanxiaoyao/Pictures/星海AI中台/数据中心/数据审批") - new FunctionInformation("标注中心-标签模板", "/Users/lanyuanxiaoyao/Pictures/星海AI中台/标注中心/标签模板"), - new FunctionInformation("标注中心-我的任务", "/Users/lanyuanxiaoyao/Pictures/星海AI中台/标注中心/我的任务"), - new FunctionInformation("标注中心-标注项目", "/Users/lanyuanxiaoyao/Pictures/星海AI中台/标注中心/标注项目"), - new FunctionInformation("标注中心-标注场景", "/Users/lanyuanxiaoyao/Pictures/星海AI中台/标注中心/标注场景"), - new FunctionInformation("标注中心-标注总览", "/Users/lanyuanxiaoyao/Pictures/星海AI中台/标注中心/标注总览") + // new FunctionInformation("标注中心-标签模板", "/Users/lanyuanxiaoyao/Pictures/星海AI中台/标注中心/标签模板"), + // new FunctionInformation("标注中心-我的任务", "/Users/lanyuanxiaoyao/Pictures/星海AI中台/标注中心/我的任务"), + new FunctionInformation("标注中心-标注项目", "C:\\Users\\lanyuanxiaoyao\\SynologyDrive\\document\\工作\\202506 标注中心\\星海AI中台功能截图\\标注中心\\标注项目") + // new FunctionInformation("标注中心-标注场景", "/Users/lanyuanxiaoyao/Pictures/星海AI中台/标注中心/标注场景"), + // new FunctionInformation("标注中心-标注总览", "/Users/lanyuanxiaoyao/Pictures/星海AI中台/标注中心/标注总览") ); @Resource private ChatClient chatClient; @@ -75,13 +77,12 @@ public class PrecariatApplication implements ApplicationRunner { 菜单的当前展开/折叠状态(根据图像显示)。 选中的菜单项(如有高亮显示)。 页面结构: 描述区域间的包含关系(如:主内容区包含一个标题和一个数据列表)。 - 列表/表格 (关键): - 清晰列出所有表头/列标题的名称。 - 描述每列内容的形式(纯文本、数字、日期、带图标的标签、按钮等)。 - 避免列举具体数据行内容。 - 明确指出行末尾或行内是否存在可见的操作元素(如图标按钮、文字链接按钮),并描述其视觉特征(如:每行末尾有“编辑”图标按钮和“删除”文字链接)。 + 列表/表格 (关键): + 清晰列出所有表头/列标题的名称。 + 描述每列内容的形式(纯文本、数字、日期、带图标的标签、按钮等)。 + 避免列举具体数据行内容。 + 明确指出行末尾或行内是否存在可见的操作元素(如图标按钮、文字链接按钮),并描述其视觉特征(如:每行末尾有“编辑”图标按钮和“删除”文字链接)。 交互元素: 描述所有可见按钮、输入框、下拉选择框、单选框、复选框、选项卡等的文字标签和视觉状态(如:激活/未激活、选中/未选中)。 - 视觉元素: 描述图标(注明其旁边的文字或位置)、分割线、背景色块、图片占位符等及其位置。 3.禁止事项 (强化): 禁止遗漏: 确保扫描并描述了页面的所有可见区域和元素。 @@ -115,26 +116,50 @@ public class PrecariatApplication implements ApplicationRunner { .content(); } + private void generateExplain(FunctionInformation information, Boolean overwrite) { + FileUtil.listFileNames(information.getImagesPath()) + .stream() + .filter(name -> StrUtil.equals(FileUtil.extName(name), "png")) + .map(name -> FileUtil.file(information.getImagesPath(), name)) + .map(FileUtil::getAbsolutePath) + .forEach(imagePath -> { + log.info("explain: {}", imagePath); + String explainTextPath = StrUtil.format( + "{}/{}.txt", + FileUtil.getParent(imagePath, 1), + FileUtil.getName(imagePath) + ); + if (!overwrite && FileUtil.exist(explainTextPath)) { + return; + } + String description = describeScreenshoot(imagePath); + FileUtil.writeBytes( + description.getBytes(StandardCharsets.UTF_8), + explainTextPath + ); + }); + } + @Override public void run(ApplicationArguments args) { List lines = new ArrayList<>(); for (FunctionInformation information : informationList) { + generateExplain(information, false); List descriptions = FileUtil.listFileNames(information.getImagesPath()) - .parallelStream() - .filter(name -> StrUtil.equals(FileUtil.extName(name), "png")) + .stream() + .filter(name -> StrUtil.equals(FileUtil.extName(name), "txt")) .map(name -> FileUtil.file(information.getImagesPath(), name)) .map(FileUtil::getAbsolutePath) - .map(imagePath -> { - String description = describeScreenshoot(imagePath); - log.info("{}\n{}", imagePath, description); - return description; - }) + .map(imagePath -> FileUtil.readString(imagePath, StandardCharsets.UTF_8)) .toList(); + if (ObjectUtil.isEmpty(descriptions)) { + continue; + } String response = chatClient.prompt(StrUtil.format( // language=TEXT """ 你将被提供某个管理系统关于“{}”功能的所有相关网页内容描述。 - 这些描述包含页面元素、功能名称、以及同一页面在不同操作(如点击按钮、选择下拉框)后的状态变化。请仔细分析,合并描述中相同的页面内容和功能。 + 这些描述包含页面元素、功能名称、以及同一页面在不同操作(如点击按钮、选择下拉框)后的状态变化,其中部分功能会有共用的页面(如新增弹框、删除弹框等),请仔细分析,合并描述中相同的页面内容和功能。 1.功能列表分析要求 核心目标:从提供的网页描述中,详尽识别并抽象出所有业务逻辑功能。 @@ -177,7 +202,7 @@ public class PrecariatApplication implements ApplicationRunner { )); } } - try (ExcelWriter writer = ExcelUtil.getWriter(StrUtil.format("/Users/lanyuanxiaoyao/Project/Precariat/{}.xlsx", DateUtil.current()))) { + try (ExcelWriter writer = ExcelUtil.getWriter(StrUtil.format("{}.xlsx", DateUtil.current()))) { writer.addHeaderAlias("group", "一级功能"); writer.addHeaderAlias("name", "二级功能"); writer.addHeaderAlias("subName", "三级功能");