更新版本V0.0.67
更新版本V0.0.67
This commit is contained in:
@@ -28,9 +28,21 @@
|
||||
|
||||
# 版本更新介绍
|
||||
|
||||
> 最新更新:2025-10-12
|
||||
> 最新更新:2025-10-26
|
||||
|
||||
> 0.0.66 公测版本介绍 如果你要使用本插件请务必进我们的官方 QQ 群(1018231382)!
|
||||
> 0.0.67 公测版本介绍 如果你要使用本插件请务必进我们的官方 QQ 群(1018231382)!
|
||||
>
|
||||
> 1. 修复一键翻译不全的问题
|
||||
>
|
||||
> 2. 合并PR [#46](https://github.com/weilin9999/WeiLin-Comfyui-Tools/pull/46) 感谢各位小伙伴的帮助
|
||||
>
|
||||
> 3. 新增功能:在Tag中的右侧添加了一个删除按钮,方便删除Tag
|
||||
>
|
||||
|
||||
<details>
|
||||
<summary>点击查看往期更多更新内容</summary>
|
||||
|
||||
> 0.0.66 公测版本介绍 2025-10-12
|
||||
>
|
||||
> 1. 修复了一些已知的BUG
|
||||
>
|
||||
@@ -41,9 +53,6 @@
|
||||
> 4. 翻译大修改!本次更新将翻译功能全部重改了,使用AI进行翻译,对接硅基AI进行调用API翻译,如果你想要对接其它的AI平台你可以进群提交建议,后续更新会添加新的平台
|
||||
>
|
||||
|
||||
<details>
|
||||
<summary>点击查看往期更多更新内容</summary>
|
||||
|
||||
> 0.0.65 公测版本介绍 2025-09-23
|
||||
>
|
||||
> 1. 修复了一些已知的BUG
|
||||
|
||||
+15
-5
@@ -24,21 +24,31 @@ Due to limited personal time, the frequency of updating plug-ins will not be ver
|
||||
|
||||
# Version update introduction
|
||||
|
||||
> Last updated: 2025-10-12
|
||||
> Last updated: 2025-10-26
|
||||
|
||||
> 0.0.66 Public Beta Version Introduction: If you want to use this plugin, please be sure to join our official QQ group (1018231382)!
|
||||
> 0.0.67 Public Beta Version Introduction: If you want to use this plugin, please be sure to join our official QQ group (1018231382)!
|
||||
>
|
||||
> 1. Fixed the issue of incomplete one-click translation
|
||||
>
|
||||
> 2. Merger PR [#46](https://github.com/weilin9999/WeiLin-Comfyui-Tools/pull/46) thank you for your friend's help
|
||||
>
|
||||
> 3. New feature: A delete button has been added to the right side of the Tag for convenient Tag deletion
|
||||
>
|
||||
|
||||
<details>
|
||||
<summary>Click here for more updates from the past</summary>
|
||||
|
||||
> 0.0.66 Public Beta Version 2025-10-12
|
||||
>
|
||||
> 1. Fixed some known bugs
|
||||
>
|
||||
> 2. Merger PR # [44] (https://github.com/weilin9999/WeiLin-Comfyui-Tools/pull/44) thank you for your friend's help
|
||||
> 2. Merger PR [#44](https://github.com/weilin9999/WeiLin-Comfyui-Tools/pull/44) thank you for your friend's help
|
||||
>
|
||||
> 3. New features: Tags can be bookmarked with one click in the Tag control bar. The ability to add a newline character has also been added
|
||||
>
|
||||
> 4. Translation overhaul! This update has changed all the translation functions, using AI for translation, and docking silicon based AI for API translation. If you want to connect with other AI platforms, you can submit suggestions in the group, and a new platform will be added in the subsequent update
|
||||
>
|
||||
|
||||
<details>
|
||||
<summary>Click here for more updates from the past</summary>
|
||||
|
||||
> 0.0.65 Public Beta Version 2025-09-23
|
||||
>
|
||||
|
||||
@@ -61,7 +61,16 @@ async def translateObject(objectData: str, target_lang_code: str = "zh") -> str:
|
||||
|
||||
response = requests.post(url, json=payload, headers=headers)
|
||||
dataResponse = response.json()
|
||||
print(f"💡[WeiLin-Comfyui-Tools] 硅基AI翻译接口-翻译完成,以下是使用信息:\n - PromptToken:{dataResponse['usage']['total_tokens']},\n - CompletionTokens:{dataResponse['usage']['completion_tokens']},\n - TotalTokens:{dataResponse['usage']['total_tokens']}")
|
||||
if response.status_code != 200:
|
||||
raise RuntimeError(
|
||||
f"📌[WeiLin-Comfyui-Tools] 硅基AI接口错误: {response.status_code} {dataResponse}")
|
||||
|
||||
print("💡[WeiLin-Comfyui-Tools] 硅基AI翻译接口-翻译结果:", dataResponse["choices"][0]["message"]["content"][:20], "...")
|
||||
try:
|
||||
print(f"💡[WeiLin-Comfyui-Tools] 硅基AI翻译接口-翻译完成,以下是使用信息:\n - PromptToken:{dataResponse['usage']['total_tokens']},\n - CompletionTokens:{dataResponse['usage']['completion_tokens']},\n - TotalTokens:{dataResponse['usage']['total_tokens']}")
|
||||
except KeyError as e:
|
||||
print("💡[WeiLin-Comfyui-Tools] 硅基AI翻译接口-使用信息获取失败,可能是接口返回异常,错误信息:", str(e))
|
||||
print("💡[WeiLin-Comfyui-Tools] 硅基AI翻译接口:", dataResponse["choices"][0]["finish_reason"])
|
||||
return dataResponse["choices"][0]["message"]["content"]
|
||||
|
||||
|
||||
@@ -79,4 +88,8 @@ def getModelList() -> dict:
|
||||
|
||||
response = requests.get(url, headers=headers, params=querystring)
|
||||
|
||||
if response.status_code != 200:
|
||||
raise RuntimeError(
|
||||
f"📌[WeiLin-Comfyui-Tools] 硅基AI接口错误: {response.status_code} {response.json()}")
|
||||
|
||||
return response.json()
|
||||
|
||||
Vendored
+51
-51
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "weilin-comfyui-tools"
|
||||
description = "让你在 ComfyUI 中快捷的使用提示词工具 Quickly use the prompt word tool in ComfyUI"
|
||||
version = "0.0.66"
|
||||
version = "0.0.67"
|
||||
license = {file = "LICENSE"}
|
||||
dependencies = []
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
export const version = "v0.0.66";
|
||||
export const version = "v0.0.67";
|
||||
@@ -1100,3 +1100,26 @@
|
||||
.line-token-btn:active svg {
|
||||
filter: brightness(0.85);
|
||||
}
|
||||
|
||||
.quick-delete-btn {
|
||||
background: transparent;
|
||||
border: none;
|
||||
padding: 2px 2px;
|
||||
margin-left: 2px;
|
||||
cursor: pointer;
|
||||
border-radius: 3px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
transition: background 0.2s;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.quick-delete-btn:hover {
|
||||
background: #fff1f0;
|
||||
}
|
||||
.quick-delete-btn svg {
|
||||
display: block;
|
||||
transition: filter 0.2s;
|
||||
}
|
||||
.quick-delete-btn:active svg {
|
||||
filter: brightness(0.85);
|
||||
}
|
||||
@@ -349,6 +349,15 @@
|
||||
<input v-else-if="!token.isPunctuation" :value="token.text" @input="handleTokenEdit(index, $event)"
|
||||
@blur="finishEditing(index)" @keyup.enter="finishEditing(index)"
|
||||
:ref="el => { if (el) tokenInputRefs[index] = el }">
|
||||
<!-- 右侧快捷删除按钮 -->
|
||||
<button class="quick-delete-btn" @click.stop="deleteToken(index)" :title="t('promptBox.delete')"
|
||||
style="margin-left: 4px;">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none">
|
||||
<path
|
||||
d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
|
||||
fill="#ff4d4f70" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1815,37 +1824,86 @@ const oneClickTranslatePrompt = async () => {
|
||||
// currentIndex = endIndex;
|
||||
// }
|
||||
|
||||
let needTranslateData = []
|
||||
for (let i = 0; i < tokens.value.length; i++) {
|
||||
const token = tokens.value[i];
|
||||
// 检查translate是否包含英文字符 /[a-zA-Z]/.test(token.translate)
|
||||
if (token.translate && token.translate === token.text) {
|
||||
// 提取需要翻译的文本
|
||||
const textToTranslate = token.text;
|
||||
needTranslateData.push({ index: token.id, text: textToTranslate, translate: '' });
|
||||
const batchSize = 2; // 每批最多2个
|
||||
let currentIndex = 0;
|
||||
const MAX_TOKEN_LENGTH = 20; // 超过20单独翻译
|
||||
|
||||
while (currentIndex < tokens.value.length) {
|
||||
let batchTranslateData = [];
|
||||
let batchTokenIds = [];
|
||||
let batchTokenLength = 0;
|
||||
let batchCount = 0;
|
||||
|
||||
// 收集本批次
|
||||
for (let i = currentIndex; i < tokens.value.length; i++) {
|
||||
const token = tokens.value[i];
|
||||
if (
|
||||
token.translate &&
|
||||
/[a-zA-Z]/.test(token.translate) &&
|
||||
!(typeof token.text === 'string' && token.text.startsWith('<wlr'))
|
||||
) {
|
||||
const textToTranslate = token.text;
|
||||
const textLen = textToTranslate.length;
|
||||
|
||||
if (textLen > MAX_TOKEN_LENGTH) {
|
||||
// 单独翻译
|
||||
const jsonString = JSON.stringify([{ index: token.id, text: textToTranslate, translate: '' }]);
|
||||
await tryTranslate(jsonString, [token.id]);
|
||||
currentIndex = i + 1;
|
||||
break;
|
||||
} else {
|
||||
batchTranslateData.push({ index: token.id, text: textToTranslate, translate: '' });
|
||||
batchTokenIds.push(token.id);
|
||||
batchTokenLength += textLen;
|
||||
batchCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// 满2个就发起翻译
|
||||
if (batchCount === batchSize) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (batchTranslateData.length > 0) {
|
||||
const jsonString = JSON.stringify(batchTranslateData);
|
||||
await tryTranslate(jsonString, batchTokenIds);
|
||||
}
|
||||
|
||||
// 跳过已处理的token
|
||||
currentIndex += batchCount > 0 ? batchCount : 1;
|
||||
}
|
||||
|
||||
const jsonString = JSON.stringify(needTranslateData)
|
||||
};
|
||||
|
||||
translatorApi.translaterText(jsonString, "").then(res => {
|
||||
if (res) {
|
||||
if (res.data) {
|
||||
const jsonData = JSON.parse(res.data)
|
||||
// console.log(jsonData)
|
||||
for (let i = 0; i < jsonData.length; i++) {
|
||||
const item = jsonData[i];
|
||||
const tryTranslate = async (jsonString, tokenIds) => {
|
||||
let retry = 0;
|
||||
while (retry < 2) {
|
||||
try {
|
||||
const res = await translatorApi.translaterText(jsonString, "");
|
||||
if (res && res.data) {
|
||||
const jsonData = JSON.parse(res.data);
|
||||
for (let j = 0; j < jsonData.length; j++) {
|
||||
const item = jsonData[j];
|
||||
const tokenIndex = tokens.value.findIndex(t => t.id === item.index);
|
||||
if (tokenIndex !== -1) {
|
||||
tokens.value[tokenIndex].translate = item.translate;
|
||||
}
|
||||
}
|
||||
return true; // 成功
|
||||
}
|
||||
return false;
|
||||
} catch (e) {
|
||||
retry++;
|
||||
if (retry >= 2) {
|
||||
// 最多重试一次,失败则跳过
|
||||
return false;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
const tempInputText = ref('')
|
||||
|
||||
const finishPromptPutItHistory = () => {
|
||||
|
||||
Reference in New Issue
Block a user