修复 图片进度监控 自定义提示词预设使用 mj古风提示词改名 存放数据文件夹变更

This commit is contained in:
lq1405 2025-09-15 16:58:09 +08:00
parent 8ab4835270
commit 3db9352a42
16 changed files with 194 additions and 84 deletions

View File

@ -1 +1,8 @@
D:\LaiTool\LaiTool_Pro\Database\option.realm
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

View File

@ -1,7 +1,7 @@
{ {
"name": "laitool-pro", "name": "laitool-pro",
"productName": "LaiToolPro", "productName": "LaiToolPro",
"version": "v3.4.8", "version": "v3.4.9",
"description": "来推 Pro - 一款集音频处理、文案生成、图片生成、视频生成等功能于一体的多合一AI工具软件。", "description": "来推 Pro - 一款集音频处理、文案生成、图片生成、视频生成等功能于一体的多合一AI工具软件。",
"main": "./out/main/index.js", "main": "./out/main/index.js",
"author": "xiangbei", "author": "xiangbei",

View File

@ -65,7 +65,7 @@ export const aiOptionsData: AiInferenceModelModel[] = [
}, },
{ {
value: 'AIStoryboardMasterMJAncientStyle', value: 'AIStoryboardMasterMJAncientStyle',
label: t('【LaiTool】分镜大师-MJ古风版(上下文-人物场景固定-MJ古风提示词'), label: t('【LaiTool】分镜大师-MJ超精细化版(上下文-人物场景固定'),
hasExample: false, hasExample: false,
mustCharacter: true, mustCharacter: true,
requestBody: AIStoryboardMasterMJAncientStyle, requestBody: AIStoryboardMasterMJAncientStyle,
@ -104,10 +104,15 @@ export const aiOptionsData: AiInferenceModelModel[] = [
* @returns AI选项数据 * @returns AI选项数据
* @throws {Error} AI选项 * @throws {Error} AI选项
*/ */
export function GetAIPromptOptionByValue(value: string) { export async function GetAIPromptOptionByValue(value: string, customOptions?: AiInferenceModelModel[]): Promise<AiInferenceModelModel> {
let aiOptionIndex = aiOptionsData.findIndex((item) => item.value == value) 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) { if (aiOptionIndex == -1) {
throw new Error(t('没有找到对应的AI选项请先检查配置')) throw new Error(t('没有找到对应的AI选项请先检查配置'))
} }
return aiOptionsData[aiOptionIndex] return optionsData[aiOptionIndex]
} }

View File

@ -1,4 +1,4 @@
export const AIWordMergeShort = { export const AIWordMergeShort: OpenAIRequest.Request = {
model: 'deepseek-chat', model: 'deepseek-chat',
stream: false, stream: false,
messages: [ messages: [

View File

@ -16,6 +16,7 @@ import { TaskListModel } from '../../model/taskList'
import { OptionModel } from '../../model/options' import { OptionModel } from '../../model/options'
import { BookTaskModel } from '../../model/bookTask' import { BookTaskModel } from '../../model/bookTask'
import { PresetModel } from '../../model/preset' import { PresetModel } from '../../model/preset'
import { define } from '@/define/define'
const { app } = require('electron') const { app } = require('electron')
// Determine database path based on environment // Determine database path based on environment
@ -40,7 +41,15 @@ export class RealmBaseService extends BaseService {
public static async getInstance() { public static async getInstance() {
if (RealmBaseService.instance === null) { 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() RealmBaseService.instance = new RealmBaseService()
await RealmBaseService.instance.open() await RealmBaseService.instance.open()
} }

View File

@ -9,7 +9,8 @@ function joinPath(...segments: string[]): string {
// 动态导入模块 // 动态导入模块
let appIsPackaged = false let appIsPackaged = false
let basePath = '' let dataPath = ''
let resourcesPath = ''
// Node环境下的初始化 // Node环境下的初始化
if (isNode) { if (isNode) {
@ -18,14 +19,17 @@ if (isNode) {
appIsPackaged = app.isPackaged appIsPackaged = app.isPackaged
const path = require('path') 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')
: path.join(__dirname, '../../resources') : path.join(__dirname, '../../resources')
} catch (e) { } catch (e) {
// 可能是纯Node环境没有Electron // 可能是纯Node环境没有Electron
try { try {
const path = require('path') const path = require('path')
basePath = path.join(process.cwd(), 'resources') dataPath = path.join(process.cwd(), 'LaiToolProCacheData')
} catch (e) { } catch (e) {
console.warn('无法确定Node环境路径基础') console.warn('无法确定Node环境路径基础')
} }
@ -33,7 +37,8 @@ if (isNode) {
} else { } else {
// 浏览器环境使用相对路径或API提供的基础路径 // 浏览器环境使用相对路径或API提供的基础路径
// 这里可以根据实际部署环境调整 // 这里可以根据实际部署环境调整
basePath = '/resources' dataPath = '../LaiToolProCacheData'
resourcesPath = '/resources'
} }
// 创建配置对象 // 创建配置对象
@ -42,79 +47,84 @@ const define = (() => {
const path = require('path') const path = require('path')
// Node环境使用文件系统路径 // Node环境使用文件系统路径
const createPaths = (base: string) => ({ const createPaths = (dataPath: string, resourcesPath: string) => ({
icon: path.join(base, 'icon.ico'), log_folder: path.join(dataPath, 'logger'),
package_path: path.join(base, 'package'), image_path: path.join(dataPath, 'image'),
db_path: path.join(base, 'scripts/db'), cache_path: path.join(dataPath, 'cache'),
scripts_path: path.join(base, 'scripts'),
log_folder: path.join(base, 'logger'),
image_path: path.join(base, 'image'), icon: path.join(resourcesPath, 'icon.ico'),
resources_path: base, package_path: path.join(resourcesPath, 'package'),
cache_path: path.join(base, 'cache'), db_path: path.join(resourcesPath, 'scripts/db'),
draft_temp_path: path.join(base, 'tmp/jianyingTemp.zip'), scripts_path: path.join(resourcesPath, 'scripts'),
clip_speed_temp_path: path.join(base, 'tmp/Clip/speeds_tmp.json'), resources_path: resourcesPath,
add_canvases_temp_path: path.join(base, 'tmp/Clip/canvases_tmp.json'), 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( add_sound_channel_mappings_temp_path: path.join(
base, resourcesPath,
'tmp/Clip/sound_channel_mappings_tmp.json' 'tmp/Clip/sound_channel_mappings_tmp.json'
), ),
add_vocal_separations_temp_path: path.join(base, 'tmp/Clip/vocal_separations_tmp.json'), add_vocal_separations_temp_path: path.join(resourcesPath, 'tmp/Clip/vocal_separations_tmp.json'),
add_material_video_temp_path: path.join(base, 'tmp/Clip/videoMaterialTemp.json'), add_material_video_temp_path: path.join(resourcesPath, 'tmp/Clip/videoMaterialTemp.json'),
add_tracks_segments_temp_path: path.join(base, 'tmp/Clip/tracks_segments_tmp.json'), add_tracks_segments_temp_path: path.join(resourcesPath, 'tmp/Clip/tracks_segments_tmp.json'),
add_tracks_type_temp_path: path.join(base, 'tmp/Clip/tracks_type_tmp.json'), add_tracks_type_temp_path: path.join(resourcesPath, 'tmp/Clip/tracks_type_tmp.json'),
add_material_animations_temp_path: path.join(base, 'tmp/Clip/material_animations_tmp.json'), add_material_animations_temp_path: path.join(resourcesPath, 'tmp/Clip/material_animations_tmp.json'),
add_material_text_temp_path: path.join(base, 'tmp/Clip/material_text_temp.json'), add_material_text_temp_path: path.join(resourcesPath, 'tmp/Clip/material_text_temp.json'),
add_track_text_segments_temp_path: path.join(base, 'tmp/Clip/track_text_segments_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(base, 'tmp/Clip/materials_beats_tmp.json'), add_materials_beats_tmp_path: path.join(resourcesPath, 'tmp/Clip/materials_beats_tmp.json'),
add_materials_audios_tmp_path: path.join(base, 'tmp/Clip/materials_audios_tmp.json'), add_materials_audios_tmp_path: path.join(resourcesPath, 'tmp/Clip/materials_audios_tmp.json'),
add_tracks_audio_segments_tmp_path: path.join( add_tracks_audio_segments_tmp_path: path.join(
base, resourcesPath,
'tmp/Clip/tracks_audio_segments_tmp.json' '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', lms_url: 'https://lms.laitool.cn',
remotemj_api: 'https://api.laitool.net/', remotemj_api: 'https://api.laitool.net/',
remote_token: 'f85d39ed5a40fd09966f13f12b6cf0f0', remote_token: 'f85d39ed5a40fd09966f13f12b6cf0f0',
devPasswaord: 'woshinidaye' devPasswaord: 'woshinidaye'
}) })
return createPaths(basePath) return createPaths(dataPath, resourcesPath)
} else { } else {
// 浏览器环境使用URL路径 // 浏览器环境使用URL路径
const createPaths = (base: string) => ({ const createPaths = (dataPath: string, resourcesPath: string) => ({
icon: joinPath(base, 'icon.ico'), log_folder: joinPath(dataPath, 'logger'),
package_path: joinPath(base, 'package'), image_path: joinPath(dataPath, 'image'),
db_path: joinPath(base, 'scripts/db'), cache_path: joinPath(dataPath, 'cache'),
scripts_path: joinPath(base, 'scripts'),
log_folder: joinPath(base, 'logger'), icon: joinPath(resourcesPath, 'icon.ico'),
image_path: joinPath(base, 'image'), package_path: joinPath(resourcesPath, 'package'),
resources_path: base, db_path: joinPath(resourcesPath, 'scripts/db'),
cache_path: joinPath(base, 'cache'), scripts_path: joinPath(resourcesPath, 'scripts'),
draft_temp_path: joinPath(base, 'tmp/jianyingTemp.zip'), resources_path: resourcesPath,
clip_speed_temp_path: joinPath(base, 'tmp/Clip/speeds_tmp.json'), dataPath : dataPath,
add_canvases_temp_path: joinPath(base, 'tmp/Clip/canvases_tmp.json'), 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( add_sound_channel_mappings_temp_path: joinPath(
base, resourcesPath,
'tmp/Clip/sound_channel_mappings_tmp.json' 'tmp/Clip/sound_channel_mappings_tmp.json'
), ),
add_vocal_separations_temp_path: joinPath(base, 'tmp/Clip/vocal_separations_tmp.json'), add_vocal_separations_temp_path: joinPath(resourcesPath, 'tmp/Clip/vocal_separations_tmp.json'),
add_material_video_temp_path: joinPath(base, 'tmp/Clip/videoMaterialTemp.json'), add_material_video_temp_path: joinPath(resourcesPath, 'tmp/Clip/videoMaterialTemp.json'),
add_tracks_segments_temp_path: joinPath(base, 'tmp/Clip/tracks_segments_tmp.json'), add_tracks_segments_temp_path: joinPath(resourcesPath, 'tmp/Clip/tracks_segments_tmp.json'),
add_tracks_type_temp_path: joinPath(base, 'tmp/Clip/tracks_type_tmp.json'), add_tracks_type_temp_path: joinPath(resourcesPath, 'tmp/Clip/tracks_type_tmp.json'),
add_material_animations_temp_path: joinPath(base, 'tmp/Clip/material_animations_tmp.json'), add_material_animations_temp_path: joinPath(resourcesPath, 'tmp/Clip/material_animations_tmp.json'),
add_material_text_temp_path: joinPath(base, 'tmp/Clip/material_text_temp.json'), add_material_text_temp_path: joinPath(resourcesPath, 'tmp/Clip/material_text_temp.json'),
add_track_text_segments_temp_path: joinPath(base, 'tmp/Clip/track_text_segments_temp.json'), add_track_text_segments_temp_path: joinPath(resourcesPath, 'tmp/Clip/track_text_segments_temp.json'),
add_materials_beats_tmp_path: joinPath(base, 'tmp/Clip/materials_beats_tmp.json'), add_materials_beats_tmp_path: joinPath(resourcesPath, 'tmp/Clip/materials_beats_tmp.json'),
add_materials_audios_tmp_path: joinPath(base, 'tmp/Clip/materials_audios_tmp.json'), add_materials_audios_tmp_path: joinPath(resourcesPath, 'tmp/Clip/materials_audios_tmp.json'),
add_tracks_audio_segments_tmp_path: joinPath(base, 'tmp/Clip/tracks_audio_segments_tmp.json'), add_tracks_audio_segments_tmp_path: joinPath(resourcesPath, 'tmp/Clip/tracks_audio_segments_tmp.json'),
add_keyframe_tmp_path: joinPath(base, 'tmp/Clip/keyframe_tmp.json'), add_keyframe_tmp_path: joinPath(resourcesPath, 'tmp/Clip/keyframe_tmp.json'),
lms_url: 'https://lms.laitool.cn', lms_url: 'https://lms.laitool.cn',
remotemj_api: 'https://api.laitool.net/', remotemj_api: 'https://api.laitool.net/',
remote_token: 'f85d39ed5a40fd09966f13f12b6cf0f0', remote_token: 'f85d39ed5a40fd09966f13f12b6cf0f0',
devPasswaord: 'woshinidaye' devPasswaord: 'woshinidaye'
}) })
return createPaths(basePath) return createPaths(dataPath, resourcesPath)
} }
})() })()

View File

@ -25,7 +25,7 @@ declare namespace OpenAIRequest {
/** 温度参数,控制生成内容的随机性 (0-1) */ /** 温度参数,控制生成内容的随机性 (0-1) */
temperature?: number temperature?: number
/** 消息列表,包含系统提示和用户输入 */ /** 消息列表,包含系统提示和用户输入 */
messages: AIMessage[] messages: RequestMessage[]
} }
/** /**

View File

@ -85,4 +85,50 @@ declare namespace PresetModel {
/** 场景预设集合 */ /** 场景预设集合 */
[PresetCategory.Scene]: Preset[] [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
}
} }

View File

@ -130,7 +130,7 @@ export class InitFunc {
*/ */
async InitProjectPath() { async InitProjectPath() {
try { try {
let projectPath = path.resolve(define.resources_path, 'project') let projectPath = path.resolve(define.dataPath, 'project')
const optionRealmService = await OptionRealmService.getInstance() const optionRealmService = await OptionRealmService.getInstance()
let projectPathOption = optionRealmService.GetOptionByKey(OptionKeyName.Software.ProjectPath) let projectPathOption = optionRealmService.GetOptionByKey(OptionKeyName.Software.ProjectPath)
if ( if (

View File

@ -1730,7 +1730,7 @@ export default {
'【LaiTool】分镜大师-通用版(上下文-人物场景固定-类型推理)': '【LaiTool】Storyboard Master - Universal (Context - Fixed characters and scenes - Type inference)', '【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】分镜大师-全面版-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】分镜大师-全能优化版(上下文-人物固定)': '【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】分镜大师-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)', '【LaiTool】分镜大师-单帧分镜提示词(上下文-单帧-人物自动推理)': '【LaiTool】Storyboard Master - Single Frame Prompts (Context - Single frame - Auto character inference)',
"没有找到对应的AI选项请先检查配置": "No corresponding AI option found, please check configuration first", "没有找到对应的AI选项请先检查配置": "No corresponding AI option found, please check configuration first",

View File

@ -1730,7 +1730,7 @@ export default {
'【LaiTool】分镜大师-通用版(上下文-人物场景固定-类型推理)': '【LaiTool】分镜大师-通用版(上下文-人物场景固定-类型推理)', '【LaiTool】分镜大师-通用版(上下文-人物场景固定-类型推理)': '【LaiTool】分镜大师-通用版(上下文-人物场景固定-类型推理)',
'【LaiTool】分镜大师-全面版-AI增强上下文-人物场景固定-单帧)': '【LaiTool】分镜大师-全面版-AI增强上下文-人物场景固定-单帧)', '【LaiTool】分镜大师-全面版-AI增强上下文-人物场景固定-单帧)': '【LaiTool】分镜大师-全面版-AI增强上下文-人物场景固定-单帧)',
'【LaiTool】分镜大师-全能优化版(上下文-人物固定)': '【LaiTool】分镜大师-全能优化版(上下文-人物固定)', '【LaiTool】分镜大师-全能优化版(上下文-人物固定)': '【LaiTool】分镜大师-全能优化版(上下文-人物固定)',
'【LaiTool】分镜大师-MJ古风版上下文-人物场景固定-MJ古风提示词': '【LaiTool】分镜大师-MJ古风版上下文-人物场景固定-MJ古风提示词', "【LaiTool】分镜大师-MJ超精细化版上下文-人物场景固定)" : "【LaiTool】分镜大师-MJ超精细化版上下文-人物场景固定)",
'【LaiTool】分镜大师-SD英文版上下文-人物场景固定-SD-英文提示词)': '【LaiTool】分镜大师-SD英文版上下文-人物场景固定-SD-英文提示词)', '【LaiTool】分镜大师-SD英文版上下文-人物场景固定-SD-英文提示词)': '【LaiTool】分镜大师-SD英文版上下文-人物场景固定-SD-英文提示词)',
'【LaiTool】分镜大师-单帧分镜提示词(上下文-单帧-人物自动推理)': '【LaiTool】分镜大师-单帧分镜提示词(上下文-单帧-人物自动推理)', '【LaiTool】分镜大师-单帧分镜提示词(上下文-单帧-人物自动推理)': '【LaiTool】分镜大师-单帧分镜提示词(上下文-单帧-人物自动推理)',
"没有找到对应的AI选项请先检查配置": "没有找到对应的AI选项请先检查配置", "没有找到对应的AI选项请先检查配置": "没有找到对应的AI选项请先检查配置",

View File

@ -2,7 +2,7 @@ import { OptionRealmService } from '@/define/db/service/optionService'
import { OptionKeyName } from '@/define/enum/option' import { OptionKeyName } from '@/define/enum/option'
import { optionSerialization } from '../option/optionSerialization' import { optionSerialization } from '../option/optionSerialization'
import { SettingModal } from '@/define/model/setting' import { SettingModal } from '@/define/model/setting'
import { isEmpty } from 'lodash' import { cloneDeep, isEmpty } from 'lodash'
import { GetOpenAISuccessResponse } from '@/define/response/openAIResponse' import { GetOpenAISuccessResponse } from '@/define/response/openAIResponse'
import { GetApiDefineDataById } from '@/define/data/apiData' import { GetApiDefineDataById } from '@/define/data/apiData'
import axios from 'axios' import axios from 'axios'
@ -88,8 +88,8 @@ export class AiReasonCommon {
* @returns {any} - * @returns {any} -
* @throws {Error} - * @throws {Error} -
*/ */
GetInferenceModelMessage(): AiInferenceModelModel { async GetInferenceModelMessage(optionsData?: AiInferenceModelModel[]): Promise<AiInferenceModelModel> {
let selectInferenceModel = GetAIPromptOptionByValue(this.aiReasonSetting.aiPromptValue) let selectInferenceModel = await GetAIPromptOptionByValue(this.aiReasonSetting.aiPromptValue, optionsData)
if (isEmpty(selectInferenceModel)) { if (isEmpty(selectInferenceModel)) {
throw new Error(t('请检查推理模型是否存在!')) throw new Error(t('请检查推理模型是否存在!'))
} }
@ -258,12 +258,14 @@ export class AiReasonCommon {
bookTaskDetails: Book.SelectBookTaskDetail[], bookTaskDetails: Book.SelectBookTaskDetail[],
contextCount: number, contextCount: number,
characterString: string, characterString: string,
sceneString: string sceneString: string,
optionsData?: AiInferenceModelModel[]
) { ) {
await this.GetAISetting() await this.GetAISetting()
console.log(currentBookTaskDetail.id, currentBookTaskDetail.afterGpt)
// 获取当前的推理模式信息 // 获取当前的推理模式信息
let selectInferenceModel = this.GetInferenceModelMessage() let selectInferenceModel = await this.GetInferenceModelMessage(optionsData)
// 内置模式 // 内置模式
let context = this.GetBookTaskDetailContextData( let context = this.GetBookTaskDetailContextData(
@ -276,7 +278,7 @@ export class AiReasonCommon {
throw new Error(t('当前模式需要提前分析或者设置角色场景数据,请先分析角色/场景数据!')) throw new Error(t('当前模式需要提前分析或者设置角色场景数据,请先分析角色/场景数据!'))
} }
let requestBody = selectInferenceModel.requestBody let requestBody = cloneDeep(selectInferenceModel.requestBody)
if (requestBody == null) { if (requestBody == null) {
throw new Error(t('未找到对应的分镜预设的请求数据,请检查')) throw new Error(t('未找到对应的分镜预设的请求数据,请检查'))
} }

View File

@ -2,7 +2,7 @@ import { OperateBookType, PromptMergeType } from '@/define/enum/bookEnum'
import { Book } from '@/define/model/book/book' import { Book } from '@/define/model/book/book'
import { errorMessage, SendReturnMessage, successMessage } from '@/public/generalTools' import { errorMessage, SendReturnMessage, successMessage } from '@/public/generalTools'
import { isEmpty } from 'lodash' import { cloneDeep, isEmpty } from 'lodash'
import { AiReasonCommon } from '../../aiReason/aiReasonCommon' import { AiReasonCommon } from '../../aiReason/aiReasonCommon'
import { DEFINE_STRING } from '@/define/ipcDefineString' import { DEFINE_STRING } from '@/define/ipcDefineString'
import { GeneralResponse } from '@/define/model/generalResponse' import { GeneralResponse } from '@/define/model/generalResponse'
@ -20,6 +20,9 @@ import { aiHandle } from '../../ai'
import { AICharacterAnalyseRequestData } from '@/define/data/aiData/aiPrompt/CharacterAndScene/aiCharacterAnalyseRequestData' import { AICharacterAnalyseRequestData } from '@/define/data/aiData/aiPrompt/CharacterAndScene/aiCharacterAnalyseRequestData'
import { AISceneAnalyseRequestData } from '@/define/data/aiData/aiPrompt/CharacterAndScene/aiSceneAnalyseRequestData' import { AISceneAnalyseRequestData } from '@/define/data/aiData/aiPrompt/CharacterAndScene/aiSceneAnalyseRequestData'
import { t } from '@/i18n' 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 { export class BookPromptHandle extends BookBasicHandle {
aiReasonCommon: AiReasonCommon aiReasonCommon: AiReasonCommon
@ -152,6 +155,25 @@ export class BookPromptHandle extends BookBasicHandle {
sceneString = '场景设定:' + '\n' + sceneString 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<PresetModel.AIPresetTemplate[]>(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++) { for (let i = 0; i < bookTaskDetails.length; i++) {
const element = bookTaskDetails[i] const element = bookTaskDetails[i]
@ -161,7 +183,7 @@ export class BookPromptHandle extends BookBasicHandle {
allBookTaskDetails, allBookTaskDetails,
15, // 上下文关联行数 15, // 上下文关联行数
characterString, characterString,
sceneString sceneString, optionsData
) )
console.log(element.afterGpt, content) console.log(element.afterGpt, content)
// 修改推理出来的数据 // 修改推理出来的数据
@ -330,9 +352,9 @@ export class BookPromptHandle extends BookBasicHandle {
let requestData: OpenAIRequest.Request let requestData: OpenAIRequest.Request
if (type == PresetCategory.Character) { if (type == PresetCategory.Character) {
requestData = AICharacterAnalyseRequestData requestData = cloneDeep(AICharacterAnalyseRequestData)
} else if (type == PresetCategory.Scene) { } else if (type == PresetCategory.Scene) {
requestData = AISceneAnalyseRequestData requestData = cloneDeep(AISceneAnalyseRequestData)
} else { } else {
throw new Error(t('未知的分析类型,请检查')) throw new Error(t('未知的分析类型,请检查'))
} }

View File

@ -52,6 +52,9 @@ export default class ElectronInterface {
destination: string destination: string
): Promise<ErrorItem | SuccessItem> { ): Promise<ErrorItem | SuccessItem> {
try { try {
if ((await CheckFileOrDirExist(source)) == false) {
return successMessage(null, t('复制文件夹成功'), 'SystemIpc_COPY_FOLDER_CONTENTS')
}
// 使用更完善的复制方法 // 使用更完善的复制方法
await CopyFileOrFolder(source, destination, false) await CopyFileOrFolder(source, destination, false)

View File

@ -78,6 +78,7 @@ import { useSoftwareStore, useBookStore, useThemeStore } from '@/renderer/src/st
import { isEmpty } from 'lodash' import { isEmpty } from 'lodash'
import { getBasename } from '@/renderer/src/common/file' import { getBasename } from '@/renderer/src/common/file'
import { t } from '@/i18n' import { t } from '@/i18n'
import { checkImageExists } from '@/renderer/src/common/image'
let gptPromptPercentage = ref(0) let gptPromptPercentage = ref(0)
let promptPercentage = ref(0) let promptPercentage = ref(0)
@ -96,14 +97,16 @@ let srtPath = ref('')
let imageFolderPath = ref('') let imageFolderPath = ref('')
// //
function ComputePercentage() { async function ComputePercentage() {
if (bookStore && bookStore.selectBookTaskDetail && bookStore.selectBookTaskDetail.length > 0) { if (bookStore && bookStore.selectBookTaskDetail && bookStore.selectBookTaskDetail.length > 0) {
let total = bookStore.selectBookTaskDetail.length let total = bookStore.selectBookTaskDetail.length
let gptPromptCount = 0 let gptPromptCount = 0
let promptCount = 0 let promptCount = 0
let imageCount = 0 let imageCount = 0
let reversePromptCount = 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)) { if (!isEmpty(item.gptPrompt)) {
gptPromptCount++ gptPromptCount++
} }
@ -112,14 +115,18 @@ function ComputePercentage() {
} }
// //
if (item.outImagePath) { if (
item.outImagePath &&
!isEmpty(item.outImagePath) &&
(await checkImageExists(item.outImagePath))
) {
imageCount++ imageCount++
} }
if (item.reversePrompt && item.reversePrompt.length > 0) { if (item.reversePrompt && item.reversePrompt.length > 0) {
reversePromptCount++ reversePromptCount++
} }
}) }
// //
gptPromptPercentage.value = Math.floor((gptPromptCount / total) * 100) gptPromptPercentage.value = Math.floor((gptPromptCount / total) * 100)
@ -209,9 +216,9 @@ onMounted(() => {
ComputePath() ComputePath()
// //
setInterval(() => { setInterval(async () => {
ComputePercentage() await ComputePercentage()
}, 5000) }, 15000)
}) })
function ErrorPosition(type) { function ErrorPosition(type) {

View File

@ -326,7 +326,6 @@ const handleDeleteCustomPreset = (presetData) => {
onPositiveClick: async () => { onPositiveClick: async () => {
// //
try { try {
debugger
// //
let res = await window.option.GetOptionByKey( let res = await window.option.GetOptionByKey(
OptionKeyName.InferenceAI.CustomInferencePreset OptionKeyName.InferenceAI.CustomInferencePreset