From 3db9352a428fb20cc9406ebf26413a106c75e78c Mon Sep 17 00:00:00 2001 From: lq1405 <2769838458@qq.com> Date: Mon, 15 Sep 2025 16:58:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E7=9B=91=E6=8E=A7=20=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=8F=90=E7=A4=BA=E8=AF=8D=E9=A2=84=E8=AE=BE=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=20mj=E5=8F=A4=E9=A3=8E=E6=8F=90=E7=A4=BA=E8=AF=8D?= =?UTF-8?q?=E6=94=B9=E5=90=8D=20=E5=AD=98=E6=94=BE=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B9=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 123.txt | 9 +- package.json | 2 +- src/define/data/aiData/aiData.ts | 13 +- .../aiPrompt/aiWordMerge/aiWordMergeShort.ts | 2 +- src/define/db/service/base/realmBase.ts | 11 +- src/define/define.ts | 118 ++++++++++-------- src/define/model/ai/openaiRequest.d.ts | 2 +- src/define/model/preset.d.ts | 46 +++++++ src/define/window/initFunc.ts | 2 +- src/i18n/locales/en.ts | 2 +- src/i18n/locales/zh-cn.ts | 2 +- src/main/service/aiReason/aiReasonCommon.ts | 14 ++- .../book/subBookHandle/bookPromptHandle.ts | 30 ++++- src/main/service/system/electronInterface.ts | 3 + .../BookTaskDetail/MessageAndProgress.vue | 21 ++-- .../Setting/InferenceSetting/AISetting.vue | 1 - 16 files changed, 194 insertions(+), 84 deletions(-) diff --git a/123.txt b/123.txt index dae0b20..c2d00c5 100644 --- a/123.txt +++ b/123.txt @@ -1 +1,8 @@ -D:\LaiTool\LaiTool_Pro\Database\option.realm \ No newline at end of file + + dbPath : D:\LaiTool\LaiTool_Pro\Database\option.realm + resourcesPath : D:\LaiTool\LaiTool_Pro\resources, + log_folder : D:\LaiTool\LaiToolProCacheData\logger + image_path : D:\LaiTool\LaiToolProCacheData\image + cache_path : D:\LaiTool\LaiToolProCacheData\cache + __dirname : D:\LaiTool\LaiTool_Pro\out\main + \ No newline at end of file diff --git a/package.json b/package.json index a1c779e..7e7923e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "laitool-pro", "productName": "LaiToolPro", - "version": "v3.4.8", + "version": "v3.4.9", "description": "来推 Pro - 一款集音频处理、文案生成、图片生成、视频生成等功能于一体的多合一AI工具软件。", "main": "./out/main/index.js", "author": "xiangbei", diff --git a/src/define/data/aiData/aiData.ts b/src/define/data/aiData/aiData.ts index 1c887fb..2374e86 100644 --- a/src/define/data/aiData/aiData.ts +++ b/src/define/data/aiData/aiData.ts @@ -65,7 +65,7 @@ export const aiOptionsData: AiInferenceModelModel[] = [ }, { value: 'AIStoryboardMasterMJAncientStyle', - label: t('【LaiTool】分镜大师-MJ古风版(上下文-人物场景固定-MJ古风提示词)'), + label: t('【LaiTool】分镜大师-MJ超精细化版(上下文-人物场景固定)'), hasExample: false, mustCharacter: true, requestBody: AIStoryboardMasterMJAncientStyle, @@ -104,10 +104,15 @@ export const aiOptionsData: AiInferenceModelModel[] = [ * @returns AI选项数据 * @throws {Error} 如果没有找到对应的AI选项,则抛出错误 */ -export function GetAIPromptOptionByValue(value: string) { - let aiOptionIndex = aiOptionsData.findIndex((item) => item.value == value) +export async function GetAIPromptOptionByValue(value: string, customOptions?: AiInferenceModelModel[]): Promise { + let optionsData: AiInferenceModelModel[] = []; + optionsData.push(...aiOptionsData); + if (customOptions && customOptions.length > 0) { + optionsData.push(...customOptions) + } + let aiOptionIndex = optionsData.findIndex((item) => item.value == value) if (aiOptionIndex == -1) { throw new Error(t('没有找到对应的AI选项,请先检查配置')) } - return aiOptionsData[aiOptionIndex] + return optionsData[aiOptionIndex] } diff --git a/src/define/data/aiData/aiPrompt/aiWordMerge/aiWordMergeShort.ts b/src/define/data/aiData/aiPrompt/aiWordMerge/aiWordMergeShort.ts index 63314cd..3533e45 100644 --- a/src/define/data/aiData/aiPrompt/aiWordMerge/aiWordMergeShort.ts +++ b/src/define/data/aiData/aiPrompt/aiWordMerge/aiWordMergeShort.ts @@ -1,4 +1,4 @@ -export const AIWordMergeShort = { +export const AIWordMergeShort: OpenAIRequest.Request = { model: 'deepseek-chat', stream: false, messages: [ diff --git a/src/define/db/service/base/realmBase.ts b/src/define/db/service/base/realmBase.ts index 83d8eb5..a577ceb 100644 --- a/src/define/db/service/base/realmBase.ts +++ b/src/define/db/service/base/realmBase.ts @@ -16,6 +16,7 @@ import { TaskListModel } from '../../model/taskList' import { OptionModel } from '../../model/options' import { BookTaskModel } from '../../model/bookTask' import { PresetModel } from '../../model/preset' +import { define } from '@/define/define' const { app } = require('electron') // Determine database path based on environment @@ -40,7 +41,15 @@ export class RealmBaseService extends BaseService { public static async getInstance() { if (RealmBaseService.instance === null) { // 将数写道本地文件 - await fs.promises.writeFile(path.join(process.cwd(), '123.txt'), dbPath, 'utf-8') + await fs.promises.writeFile(path.join(process.cwd(), '123.txt'), + ` + dbPath : ${dbPath} + resourcesPath : ${define.resources_path}, + log_folder : ${define.log_folder} + image_path : ${define.image_path} + cache_path : ${define.cache_path} + __dirname : ${__dirname} + `, 'utf-8') RealmBaseService.instance = new RealmBaseService() await RealmBaseService.instance.open() } diff --git a/src/define/define.ts b/src/define/define.ts index b3706e0..bb4a3e1 100644 --- a/src/define/define.ts +++ b/src/define/define.ts @@ -9,7 +9,8 @@ function joinPath(...segments: string[]): string { // 动态导入模块 let appIsPackaged = false -let basePath = '' +let dataPath = '' +let resourcesPath = '' // Node环境下的初始化 if (isNode) { @@ -18,14 +19,17 @@ if (isNode) { appIsPackaged = app.isPackaged const path = require('path') - basePath = appIsPackaged + dataPath = appIsPackaged + ? path.join(__dirname, '../../../../../LaiToolProCacheData') + : path.join(__dirname, '../../../LaiToolProCacheData') + resourcesPath = appIsPackaged ? path.join(__dirname, '../../../resources') : path.join(__dirname, '../../resources') } catch (e) { // 可能是纯Node环境,没有Electron try { const path = require('path') - basePath = path.join(process.cwd(), 'resources') + dataPath = path.join(process.cwd(), 'LaiToolProCacheData') } catch (e) { console.warn('无法确定Node环境路径基础') } @@ -33,7 +37,8 @@ if (isNode) { } else { // 浏览器环境,使用相对路径或API提供的基础路径 // 这里可以根据实际部署环境调整 - basePath = '/resources' + dataPath = '../LaiToolProCacheData' + resourcesPath = '/resources' } // 创建配置对象 @@ -42,79 +47,84 @@ const define = (() => { const path = require('path') // Node环境使用文件系统路径 - const createPaths = (base: string) => ({ - icon: path.join(base, 'icon.ico'), - package_path: path.join(base, 'package'), - db_path: path.join(base, 'scripts/db'), - scripts_path: path.join(base, 'scripts'), - log_folder: path.join(base, 'logger'), - image_path: path.join(base, 'image'), - resources_path: base, - cache_path: path.join(base, 'cache'), - draft_temp_path: path.join(base, 'tmp/jianyingTemp.zip'), - clip_speed_temp_path: path.join(base, 'tmp/Clip/speeds_tmp.json'), - add_canvases_temp_path: path.join(base, 'tmp/Clip/canvases_tmp.json'), + const createPaths = (dataPath: string, resourcesPath: string) => ({ + log_folder: path.join(dataPath, 'logger'), + image_path: path.join(dataPath, 'image'), + cache_path: path.join(dataPath, 'cache'), + + + icon: path.join(resourcesPath, 'icon.ico'), + package_path: path.join(resourcesPath, 'package'), + db_path: path.join(resourcesPath, 'scripts/db'), + scripts_path: path.join(resourcesPath, 'scripts'), + resources_path: resourcesPath, + dataPath : dataPath, + draft_temp_path: path.join(resourcesPath, 'tmp/jianyingTemp.zip'), + clip_speed_temp_path: path.join(resourcesPath, 'tmp/Clip/speeds_tmp.json'), + add_canvases_temp_path: path.join(resourcesPath, 'tmp/Clip/canvases_tmp.json'), add_sound_channel_mappings_temp_path: path.join( - base, + resourcesPath, 'tmp/Clip/sound_channel_mappings_tmp.json' ), - add_vocal_separations_temp_path: path.join(base, 'tmp/Clip/vocal_separations_tmp.json'), - add_material_video_temp_path: path.join(base, 'tmp/Clip/videoMaterialTemp.json'), - add_tracks_segments_temp_path: path.join(base, 'tmp/Clip/tracks_segments_tmp.json'), - add_tracks_type_temp_path: path.join(base, 'tmp/Clip/tracks_type_tmp.json'), - add_material_animations_temp_path: path.join(base, 'tmp/Clip/material_animations_tmp.json'), - add_material_text_temp_path: path.join(base, 'tmp/Clip/material_text_temp.json'), - add_track_text_segments_temp_path: path.join(base, 'tmp/Clip/track_text_segments_temp.json'), - add_materials_beats_tmp_path: path.join(base, 'tmp/Clip/materials_beats_tmp.json'), - add_materials_audios_tmp_path: path.join(base, 'tmp/Clip/materials_audios_tmp.json'), + add_vocal_separations_temp_path: path.join(resourcesPath, 'tmp/Clip/vocal_separations_tmp.json'), + add_material_video_temp_path: path.join(resourcesPath, 'tmp/Clip/videoMaterialTemp.json'), + add_tracks_segments_temp_path: path.join(resourcesPath, 'tmp/Clip/tracks_segments_tmp.json'), + add_tracks_type_temp_path: path.join(resourcesPath, 'tmp/Clip/tracks_type_tmp.json'), + add_material_animations_temp_path: path.join(resourcesPath, 'tmp/Clip/material_animations_tmp.json'), + add_material_text_temp_path: path.join(resourcesPath, 'tmp/Clip/material_text_temp.json'), + add_track_text_segments_temp_path: path.join(resourcesPath, 'tmp/Clip/track_text_segments_temp.json'), + add_materials_beats_tmp_path: path.join(resourcesPath, 'tmp/Clip/materials_beats_tmp.json'), + add_materials_audios_tmp_path: path.join(resourcesPath, 'tmp/Clip/materials_audios_tmp.json'), add_tracks_audio_segments_tmp_path: path.join( - base, + resourcesPath, 'tmp/Clip/tracks_audio_segments_tmp.json' ), - add_keyframe_tmp_path: path.join(base, 'tmp/Clip/keyframe_tmp.json'), + add_keyframe_tmp_path: path.join(resourcesPath, 'tmp/Clip/keyframe_tmp.json'), lms_url: 'https://lms.laitool.cn', remotemj_api: 'https://api.laitool.net/', remote_token: 'f85d39ed5a40fd09966f13f12b6cf0f0', devPasswaord: 'woshinidaye' }) - return createPaths(basePath) + return createPaths(dataPath, resourcesPath) } else { // 浏览器环境使用URL路径 - const createPaths = (base: string) => ({ - icon: joinPath(base, 'icon.ico'), - package_path: joinPath(base, 'package'), - db_path: joinPath(base, 'scripts/db'), - scripts_path: joinPath(base, 'scripts'), - log_folder: joinPath(base, 'logger'), - image_path: joinPath(base, 'image'), - resources_path: base, - cache_path: joinPath(base, 'cache'), - draft_temp_path: joinPath(base, 'tmp/jianyingTemp.zip'), - clip_speed_temp_path: joinPath(base, 'tmp/Clip/speeds_tmp.json'), - add_canvases_temp_path: joinPath(base, 'tmp/Clip/canvases_tmp.json'), + const createPaths = (dataPath: string, resourcesPath: string) => ({ + log_folder: joinPath(dataPath, 'logger'), + image_path: joinPath(dataPath, 'image'), + cache_path: joinPath(dataPath, 'cache'), + + icon: joinPath(resourcesPath, 'icon.ico'), + package_path: joinPath(resourcesPath, 'package'), + db_path: joinPath(resourcesPath, 'scripts/db'), + scripts_path: joinPath(resourcesPath, 'scripts'), + resources_path: resourcesPath, + dataPath : dataPath, + draft_temp_path: joinPath(resourcesPath, 'tmp/jianyingTemp.zip'), + clip_speed_temp_path: joinPath(resourcesPath, 'tmp/Clip/speeds_tmp.json'), + add_canvases_temp_path: joinPath(resourcesPath, 'tmp/Clip/canvases_tmp.json'), add_sound_channel_mappings_temp_path: joinPath( - base, + resourcesPath, 'tmp/Clip/sound_channel_mappings_tmp.json' ), - add_vocal_separations_temp_path: joinPath(base, 'tmp/Clip/vocal_separations_tmp.json'), - add_material_video_temp_path: joinPath(base, 'tmp/Clip/videoMaterialTemp.json'), - add_tracks_segments_temp_path: joinPath(base, 'tmp/Clip/tracks_segments_tmp.json'), - add_tracks_type_temp_path: joinPath(base, 'tmp/Clip/tracks_type_tmp.json'), - add_material_animations_temp_path: joinPath(base, 'tmp/Clip/material_animations_tmp.json'), - add_material_text_temp_path: joinPath(base, 'tmp/Clip/material_text_temp.json'), - add_track_text_segments_temp_path: joinPath(base, 'tmp/Clip/track_text_segments_temp.json'), - add_materials_beats_tmp_path: joinPath(base, 'tmp/Clip/materials_beats_tmp.json'), - add_materials_audios_tmp_path: joinPath(base, 'tmp/Clip/materials_audios_tmp.json'), - add_tracks_audio_segments_tmp_path: joinPath(base, 'tmp/Clip/tracks_audio_segments_tmp.json'), - add_keyframe_tmp_path: joinPath(base, 'tmp/Clip/keyframe_tmp.json'), + add_vocal_separations_temp_path: joinPath(resourcesPath, 'tmp/Clip/vocal_separations_tmp.json'), + add_material_video_temp_path: joinPath(resourcesPath, 'tmp/Clip/videoMaterialTemp.json'), + add_tracks_segments_temp_path: joinPath(resourcesPath, 'tmp/Clip/tracks_segments_tmp.json'), + add_tracks_type_temp_path: joinPath(resourcesPath, 'tmp/Clip/tracks_type_tmp.json'), + add_material_animations_temp_path: joinPath(resourcesPath, 'tmp/Clip/material_animations_tmp.json'), + add_material_text_temp_path: joinPath(resourcesPath, 'tmp/Clip/material_text_temp.json'), + add_track_text_segments_temp_path: joinPath(resourcesPath, 'tmp/Clip/track_text_segments_temp.json'), + add_materials_beats_tmp_path: joinPath(resourcesPath, 'tmp/Clip/materials_beats_tmp.json'), + add_materials_audios_tmp_path: joinPath(resourcesPath, 'tmp/Clip/materials_audios_tmp.json'), + add_tracks_audio_segments_tmp_path: joinPath(resourcesPath, 'tmp/Clip/tracks_audio_segments_tmp.json'), + add_keyframe_tmp_path: joinPath(resourcesPath, 'tmp/Clip/keyframe_tmp.json'), lms_url: 'https://lms.laitool.cn', remotemj_api: 'https://api.laitool.net/', remote_token: 'f85d39ed5a40fd09966f13f12b6cf0f0', devPasswaord: 'woshinidaye' }) - return createPaths(basePath) + return createPaths(dataPath, resourcesPath) } })() diff --git a/src/define/model/ai/openaiRequest.d.ts b/src/define/model/ai/openaiRequest.d.ts index 8aa5bb1..891ae75 100644 --- a/src/define/model/ai/openaiRequest.d.ts +++ b/src/define/model/ai/openaiRequest.d.ts @@ -25,7 +25,7 @@ declare namespace OpenAIRequest { /** 温度参数,控制生成内容的随机性 (0-1) */ temperature?: number /** 消息列表,包含系统提示和用户输入 */ - messages: AIMessage[] + messages: RequestMessage[] } /** diff --git a/src/define/model/preset.d.ts b/src/define/model/preset.d.ts index be1f6ca..1153890 100644 --- a/src/define/model/preset.d.ts +++ b/src/define/model/preset.d.ts @@ -85,4 +85,50 @@ declare namespace PresetModel { /** 场景预设集合 */ [PresetCategory.Scene]: Preset[] } + + /** + * AI预设模板接口 - 用于Midjourney绘画提示词生成 + */ + interface AIPresetTemplate { + /** 预设唯一标识符 */ + id: string + + /** 预设名称 */ + name: string + + /** 是否包含示例 */ + hasExample: boolean + + /** 是否必须包含角色描述 */ + mustCharacter: boolean + + /** 示例数组 */ + examples: any[] + + /** 占位符值对象 */ + placeholderValues: { + /** 角色描述内容 */ + characterContent?: string + /** 上下文内容 */ + contextContent?: string + /** 文本内容 */ + textContent?: string + } + + /** 检测到的占位符列表 */ + detectedPlaceholders: string[] + + /** 预览内容 */ + previewContent: { + /** 系统提示词 */ + system: string + /** 用户输入内容 */ + user: string + /** 生成结果 */ + result?: string + } + + /** 请求体配置 */ + requestBody: OpenAIRequest.Request + } } diff --git a/src/define/window/initFunc.ts b/src/define/window/initFunc.ts index 2998f84..33e7afd 100644 --- a/src/define/window/initFunc.ts +++ b/src/define/window/initFunc.ts @@ -130,7 +130,7 @@ export class InitFunc { */ async InitProjectPath() { try { - let projectPath = path.resolve(define.resources_path, 'project') + let projectPath = path.resolve(define.dataPath, 'project') const optionRealmService = await OptionRealmService.getInstance() let projectPathOption = optionRealmService.GetOptionByKey(OptionKeyName.Software.ProjectPath) if ( diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts index e3bb9e0..2de917e 100644 --- a/src/i18n/locales/en.ts +++ b/src/i18n/locales/en.ts @@ -1730,7 +1730,7 @@ export default { '【LaiTool】分镜大师-通用版(上下文-人物场景固定-类型推理)': '【LaiTool】Storyboard Master - Universal (Context - Fixed characters and scenes - Type inference)', '【LaiTool】分镜大师-全面版-AI增强(上下文-人物场景固定-单帧)': '【LaiTool】Storyboard Master - Comprehensive AI Enhanced (Context - Fixed characters and scenes - Single frame)', '【LaiTool】分镜大师-全能优化版(上下文-人物固定)': '【LaiTool】Storyboard Master - All-in-One Optimized (Context - Fixed characters)', - '【LaiTool】分镜大师-MJ古风版(上下文-人物场景固定-MJ古风提示词)': '【LaiTool】Storyboard Master - MJ Ancient Style (Context - Fixed characters and scenes - MJ ancient style prompts)', + "【LaiTool】分镜大师-MJ超精细化版(上下文-人物场景固定)": "【LaiTool】Storyboard Master - MJ Ultra-Detailed (Context - Fixed characters and scenes)", '【LaiTool】分镜大师-SD英文版(上下文-人物场景固定-SD-英文提示词)': '【LaiTool】Storyboard Master - SD English (Context - Fixed characters and scenes - SD English prompts)', '【LaiTool】分镜大师-单帧分镜提示词(上下文-单帧-人物自动推理)': '【LaiTool】Storyboard Master - Single Frame Prompts (Context - Single frame - Auto character inference)', "没有找到对应的AI选项,请先检查配置": "No corresponding AI option found, please check configuration first", diff --git a/src/i18n/locales/zh-cn.ts b/src/i18n/locales/zh-cn.ts index c4939d0..54d7fb3 100644 --- a/src/i18n/locales/zh-cn.ts +++ b/src/i18n/locales/zh-cn.ts @@ -1730,7 +1730,7 @@ export default { '【LaiTool】分镜大师-通用版(上下文-人物场景固定-类型推理)': '【LaiTool】分镜大师-通用版(上下文-人物场景固定-类型推理)', '【LaiTool】分镜大师-全面版-AI增强(上下文-人物场景固定-单帧)': '【LaiTool】分镜大师-全面版-AI增强(上下文-人物场景固定-单帧)', '【LaiTool】分镜大师-全能优化版(上下文-人物固定)': '【LaiTool】分镜大师-全能优化版(上下文-人物固定)', - '【LaiTool】分镜大师-MJ古风版(上下文-人物场景固定-MJ古风提示词)': '【LaiTool】分镜大师-MJ古风版(上下文-人物场景固定-MJ古风提示词)', + "【LaiTool】分镜大师-MJ超精细化版(上下文-人物场景固定)" : "【LaiTool】分镜大师-MJ超精细化版(上下文-人物场景固定)", '【LaiTool】分镜大师-SD英文版(上下文-人物场景固定-SD-英文提示词)': '【LaiTool】分镜大师-SD英文版(上下文-人物场景固定-SD-英文提示词)', '【LaiTool】分镜大师-单帧分镜提示词(上下文-单帧-人物自动推理)': '【LaiTool】分镜大师-单帧分镜提示词(上下文-单帧-人物自动推理)', "没有找到对应的AI选项,请先检查配置": "没有找到对应的AI选项,请先检查配置", diff --git a/src/main/service/aiReason/aiReasonCommon.ts b/src/main/service/aiReason/aiReasonCommon.ts index 8ea537d..ae3d377 100644 --- a/src/main/service/aiReason/aiReasonCommon.ts +++ b/src/main/service/aiReason/aiReasonCommon.ts @@ -2,7 +2,7 @@ import { OptionRealmService } from '@/define/db/service/optionService' import { OptionKeyName } from '@/define/enum/option' import { optionSerialization } from '../option/optionSerialization' import { SettingModal } from '@/define/model/setting' -import { isEmpty } from 'lodash' +import { cloneDeep, isEmpty } from 'lodash' import { GetOpenAISuccessResponse } from '@/define/response/openAIResponse' import { GetApiDefineDataById } from '@/define/data/apiData' import axios from 'axios' @@ -88,8 +88,8 @@ export class AiReasonCommon { * @returns {any} - 返回当前的推理模型信息 * @throws {Error} - 如果推理模型不存在,则抛出错误 */ - GetInferenceModelMessage(): AiInferenceModelModel { - let selectInferenceModel = GetAIPromptOptionByValue(this.aiReasonSetting.aiPromptValue) + async GetInferenceModelMessage(optionsData?: AiInferenceModelModel[]): Promise { + let selectInferenceModel = await GetAIPromptOptionByValue(this.aiReasonSetting.aiPromptValue, optionsData) if (isEmpty(selectInferenceModel)) { throw new Error(t('请检查推理模型是否存在!')) } @@ -258,12 +258,14 @@ export class AiReasonCommon { bookTaskDetails: Book.SelectBookTaskDetail[], contextCount: number, characterString: string, - sceneString: string + sceneString: string, + optionsData?: AiInferenceModelModel[] ) { await this.GetAISetting() + console.log(currentBookTaskDetail.id, currentBookTaskDetail.afterGpt) // 获取当前的推理模式信息 - let selectInferenceModel = this.GetInferenceModelMessage() + let selectInferenceModel = await this.GetInferenceModelMessage(optionsData) // 内置模式 let context = this.GetBookTaskDetailContextData( @@ -276,7 +278,7 @@ export class AiReasonCommon { throw new Error(t('当前模式需要提前分析或者设置角色场景数据,请先分析角色/场景数据!')) } - let requestBody = selectInferenceModel.requestBody + let requestBody = cloneDeep(selectInferenceModel.requestBody) if (requestBody == null) { throw new Error(t('未找到对应的分镜预设的请求数据,请检查')) } diff --git a/src/main/service/book/subBookHandle/bookPromptHandle.ts b/src/main/service/book/subBookHandle/bookPromptHandle.ts index a65b40b..45e74ba 100644 --- a/src/main/service/book/subBookHandle/bookPromptHandle.ts +++ b/src/main/service/book/subBookHandle/bookPromptHandle.ts @@ -2,7 +2,7 @@ import { OperateBookType, PromptMergeType } from '@/define/enum/bookEnum' import { Book } from '@/define/model/book/book' import { errorMessage, SendReturnMessage, successMessage } from '@/public/generalTools' -import { isEmpty } from 'lodash' +import { cloneDeep, isEmpty } from 'lodash' import { AiReasonCommon } from '../../aiReason/aiReasonCommon' import { DEFINE_STRING } from '@/define/ipcDefineString' import { GeneralResponse } from '@/define/model/generalResponse' @@ -20,6 +20,9 @@ import { aiHandle } from '../../ai' import { AICharacterAnalyseRequestData } from '@/define/data/aiData/aiPrompt/CharacterAndScene/aiCharacterAnalyseRequestData' import { AISceneAnalyseRequestData } from '@/define/data/aiData/aiPrompt/CharacterAndScene/aiSceneAnalyseRequestData' import { t } from '@/i18n' +import { OptionRealmService } from '@/define/db/service/optionService' +import { PresetModel } from '@/define/model/preset' +import { AiInferenceModelModel } from '@/define/data/aiData/aiData' export class BookPromptHandle extends BookBasicHandle { aiReasonCommon: AiReasonCommon @@ -152,6 +155,25 @@ export class BookPromptHandle extends BookBasicHandle { sceneString = '场景设定:' + '\n' + sceneString } + // 获取自定义的提示词数据 + let optionsData: AiInferenceModelModel[] = []; + const optionRealmService = await OptionRealmService.getInstance(); + let customInferencePreset = optionRealmService.GetOptionByKey(OptionKeyName.InferenceAI.CustomInferencePreset); + if (customInferencePreset != null && customInferencePreset.value != null && !isEmpty(customInferencePreset.value)) { + let customInferencePresetData = optionSerialization(customInferencePreset, t('设置 -> 推理设置 -> 自定义预设'), []); + for (let i = 0; i < customInferencePresetData.length; i++) { + const element = customInferencePresetData[i]; + optionsData.push({ + value: element.id, + label: element.name, + hasExample: element.hasExample, + mustCharacter: element.mustCharacter, + requestBody: element.requestBody, + allAndExampleContent: null + }) + } + } + // 添加异步任务 for (let i = 0; i < bookTaskDetails.length; i++) { const element = bookTaskDetails[i] @@ -161,7 +183,7 @@ export class BookPromptHandle extends BookBasicHandle { allBookTaskDetails, 15, // 上下文关联行数 characterString, - sceneString + sceneString, optionsData ) console.log(element.afterGpt, content) // 修改推理出来的数据 @@ -330,9 +352,9 @@ export class BookPromptHandle extends BookBasicHandle { let requestData: OpenAIRequest.Request if (type == PresetCategory.Character) { - requestData = AICharacterAnalyseRequestData + requestData = cloneDeep(AICharacterAnalyseRequestData) } else if (type == PresetCategory.Scene) { - requestData = AISceneAnalyseRequestData + requestData = cloneDeep(AISceneAnalyseRequestData) } else { throw new Error(t('未知的分析类型,请检查')) } diff --git a/src/main/service/system/electronInterface.ts b/src/main/service/system/electronInterface.ts index 109a27a..02dc80e 100644 --- a/src/main/service/system/electronInterface.ts +++ b/src/main/service/system/electronInterface.ts @@ -52,6 +52,9 @@ export default class ElectronInterface { destination: string ): Promise { try { + if ((await CheckFileOrDirExist(source)) == false) { + return successMessage(null, t('复制文件夹成功'), 'SystemIpc_COPY_FOLDER_CONTENTS') + } // 使用更完善的复制方法 await CopyFileOrFolder(source, destination, false) diff --git a/src/renderer/src/components/Original/BookTaskDetail/MessageAndProgress.vue b/src/renderer/src/components/Original/BookTaskDetail/MessageAndProgress.vue index 7cb6128..6aca1f8 100644 --- a/src/renderer/src/components/Original/BookTaskDetail/MessageAndProgress.vue +++ b/src/renderer/src/components/Original/BookTaskDetail/MessageAndProgress.vue @@ -78,6 +78,7 @@ import { useSoftwareStore, useBookStore, useThemeStore } from '@/renderer/src/st import { isEmpty } from 'lodash' import { getBasename } from '@/renderer/src/common/file' import { t } from '@/i18n' +import { checkImageExists } from '@/renderer/src/common/image' let gptPromptPercentage = ref(0) let promptPercentage = ref(0) @@ -96,14 +97,16 @@ let srtPath = ref('') let imageFolderPath = ref('') // 计算所有的数据的百分比 -function ComputePercentage() { +async function ComputePercentage() { if (bookStore && bookStore.selectBookTaskDetail && bookStore.selectBookTaskDetail.length > 0) { let total = bookStore.selectBookTaskDetail.length let gptPromptCount = 0 let promptCount = 0 let imageCount = 0 let reversePromptCount = 0 - bookStore.selectBookTaskDetail.forEach((item) => { + + for (let i = 0; i < bookStore.selectBookTaskDetail.length; i++) { + const item = bookStore.selectBookTaskDetail[i] if (!isEmpty(item.gptPrompt)) { gptPromptCount++ } @@ -112,14 +115,18 @@ function ComputePercentage() { } // 计算图片的百分比。这个条件比较复杂 - if (item.outImagePath) { + if ( + item.outImagePath && + !isEmpty(item.outImagePath) && + (await checkImageExists(item.outImagePath)) + ) { imageCount++ } if (item.reversePrompt && item.reversePrompt.length > 0) { reversePromptCount++ } - }) + } // 计算推理提示词的百分比 gptPromptPercentage.value = Math.floor((gptPromptCount / total) * 100) @@ -209,9 +216,9 @@ onMounted(() => { ComputePath() // 这边开始定时执行计算 - setInterval(() => { - ComputePercentage() - }, 5000) + setInterval(async () => { + await ComputePercentage() + }, 15000) }) function ErrorPosition(type) { diff --git a/src/renderer/src/components/Setting/InferenceSetting/AISetting.vue b/src/renderer/src/components/Setting/InferenceSetting/AISetting.vue index 10aebe0..f56c488 100644 --- a/src/renderer/src/components/Setting/InferenceSetting/AISetting.vue +++ b/src/renderer/src/components/Setting/InferenceSetting/AISetting.vue @@ -326,7 +326,6 @@ const handleDeleteCustomPreset = (presetData) => { onPositiveClick: async () => { // 实际执行删除操作 try { - debugger // 获取现有的自定义预设数据 let res = await window.option.GetOptionByKey( OptionKeyName.InferenceAI.CustomInferencePreset