Skip to content

Commit e0b8b77

Browse files
committed
更新版本V0.0.71
1 parent c0dae06 commit e0b8b77

File tree

13 files changed

+307
-254
lines changed

13 files changed

+307
-254
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,22 @@
3030

3131
# 版本更新介绍
3232

33-
> 最新更新:2025-12-19
33+
> 最新更新:2025-12-20
3434
35-
> 0.0.70 公测版本介绍 如果你要使用本插件请务必进我们的官方 QQ 群(1018231382)!
35+
> 0.0.71 公测版本介绍 如果你要使用本插件请务必进我们的官方 QQ 群(1018231382)!
3636
>
3737
> 1. API翻译模式回归,现在翻译接口重写目前只支持 阿里巴巴翻译接口、Bing翻译接口、有道翻译接口(该接口有请求限制不建议使用),目前这三个接口都是免费,后续会写付费的翻译接口对接
3838
>
39+
> 2. 修改了硅基AI和OpenAI翻译的问题,回归成原有的模式
40+
>
3941
4042
<details>
4143
<summary>点击查看往期更多更新内容</summary>
4244

45+
> 0.0.70 公测版本介绍 2025-12-19
46+
>
47+
> 1. API翻译模式回归,现在翻译接口重写目前只支持 阿里巴巴翻译接口、Bing翻译接口、有道翻译接口(该接口有请求限制不建议使用),目前这三个接口都是免费,后续会写付费的翻译接口对接
48+
>
4349
4450
> 0.0.69 公测版本介绍 2025-12-06
4551
>

README_EN.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,23 @@ Due to limited personal time, the frequency of updating plug-ins will not be ver
2424

2525
# Version update introduction
2626

27-
> Last updated: 2025-12-18
27+
> Last updated: 2025-12-20
2828
29-
> 0.0.70 Public Beta Version Introduction: If you want to use this plugin, please be sure to join our official QQ group (1018231382)!
29+
> 0.0.71 Public Beta Version Introduction: If you want to use this plugin, please be sure to join our official QQ group (1018231382)!
3030
>
3131
> 1. The API translation mode has returned. Currently, the translation interface has been rewritten and only supports Alibaba Translation Interface, Bing Translation interface, and Youdao Translation interface (this interface has request restrictions and is not recommended for use). At present, all three interfaces are free, and we will write paid translation interfaces for integration in the future
3232
>
33+
> 2. The issues with silicon-based AI and OpenAI translation have been modified, and the original model has been restored
34+
>
3335
3436
<details>
3537
<summary>Click here for more updates from the past</summary>
3638

39+
> 0.0.70 Public Beta Version 2025-12-19
40+
>
41+
> 1. The API translation mode has returned. Currently, the translation interface has been rewritten and only supports Alibaba Translation Interface, Bing Translation interface, and Youdao Translation interface (this interface has request restrictions and is not recommended for use). At present, all three interfaces are free, and we will write paid translation interfaces for integration in the future
42+
>
43+
3744
> 0.0.69 Public Beta Version 2025-12-06
3845
>
3946
> 1. Merger PR [#50](https://github.com/weilin9999/WeiLin-Comfyui-Tools/pull/50) thank you for your friend's help

app/server/ai_server/siliconflow.py

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def _lang_to_name(code: str) -> str:
1717

1818

1919
# 硅基AI翻译接口
20-
async def translateObject(objectData: str, target_lang_code: str = "zh") -> str:
20+
async def translateObject(text: str, target_lang_code: str = "zh") -> str:
2121
ai_info_setting = get_ai_info_setting()
2222
api_key = ai_info_setting.get("api_key", "")
2323
base_url = ai_info_setting.get(
@@ -28,18 +28,14 @@ async def translateObject(objectData: str, target_lang_code: str = "zh") -> str:
2828

2929
url = f"{base_url}/chat/completions"
3030

31+
32+
target_lang_name = _lang_to_name(target_lang_code)
33+
prompt = f"将以下AI绘画提示词翻译成{target_lang_name},只输出翻译结果:{text}"
34+
3135
payload = {
3236
"model": model,
33-
"messages": [
34-
{
35-
"role": "system",
36-
"content": f"ying You are a data translation processing expert, translate the text field of the JSON string data passed by the user into {_lang_to_name(target_lang_code)} (excluding numbers and other special characters, only translate the text) and fill in the corresponding translate field. You only need to return the corresponding JSON string data and do not modify any other data or parameters"
37-
},
38-
{
39-
"content": objectData,
40-
"role": "user"
41-
}
42-
],
37+
"messages": [{"role": "user", "content": prompt}],
38+
"temperature": 0,
4339
"stream": False,
4440
"max_tokens": 4096,
4541
"enable_thinking": False,
@@ -51,15 +47,42 @@ async def translateObject(objectData: str, target_lang_code: str = "zh") -> str:
5147
"top_k": 50,
5248
"frequency_penalty": 0.5,
5349
"n": 1,
54-
"response_format": {"type": "json_object"},
50+
"response_format": {"type": "text"},
5551
"tools": []
5652
}
53+
54+
# payload = {
55+
# "model": model,
56+
# "messages": [
57+
# {
58+
# "role": "system",
59+
# "content": f"ying You are a data translation processing expert, translate the text field of the JSON string data passed by the user into {_lang_to_name(target_lang_code)} (excluding numbers and other special characters, only translate the text) and fill in the corresponding translate field. You only need to return the corresponding JSON string data and do not modify any other data or parameters"
60+
# },
61+
# {
62+
# "content": objectData,
63+
# "role": "user"
64+
# }
65+
# ],
66+
# "stream": False,
67+
# "max_tokens": 4096,
68+
# "enable_thinking": False,
69+
# "thinking_budget": 4096,
70+
# "min_p": 0.05,
71+
# "stop": None,
72+
# "temperature": 0,
73+
# "top_p": 0.7,
74+
# "top_k": 50,
75+
# "frequency_penalty": 0.5,
76+
# "n": 1,
77+
# "response_format": {"type": "json_object"},
78+
# "tools": []
79+
# }
5780
headers = {
5881
"Authorization": f"Bearer {api_key}",
5982
"Content-Type": "application/json"
6083
}
6184

62-
response = requests.post(url, json=payload, headers=headers)
85+
response = requests.post(url, json=payload, headers=headers,timeout=(5,10))
6386
dataResponse = response.json()
6487
if response.status_code != 200:
6588
raise RuntimeError(

app/server/prompt_server.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -810,11 +810,13 @@ async def _tanslater_text(request):
810810
strObjectData = data['str_object']
811811
if current_setting == "openai":
812812
# OpenAI 只需要目标语种来写 prompt
813-
result = await openai_translate(strObjectData, data_setting['translate_target_lang'])
813+
# result = await openai_translate(strObjectData, data_setting['translate_target_lang'])
814+
result = await openai_translate(text, data_setting['translate_target_lang'])
814815
elif current_setting == "other_ai_plate":
815816
aiInfoData = get_ai_info_setting()
816817
if aiInfoData.get("base_url") == "https://api.siliconflow.cn/v1":
817-
result = await translateObject(strObjectData, data_setting['translate_target_lang'])
818+
# result = await translateObject(strObjectData, data_setting['translate_target_lang'])
819+
result = await translateObject(text, data_setting['translate_target_lang'])
818820
else:
819821
# 仍然走 translators(含 'translater' 与历史的 'network')
820822
result = api_service_translate(
@@ -839,11 +841,13 @@ async def _tanslater_input_text(request):
839841
strObjectData = data['str_object']
840842
if current_setting == "openai":
841843
# 反向时把“源语种代码”当成目标,复用同一 prompt 模板
842-
result = await openai_translate(strObjectData, data_setting['translate_source_lang'])
844+
# result = await openai_translate(strObjectData, data_setting['translate_source_lang'])
845+
result = await openai_translate(text, data_setting['translate_source_lang'])
843846
elif current_setting == "other_ai_plate":
844847
aiInfoData = get_ai_info_setting()
845848
if aiInfoData.get("base_url") == "https://api.siliconflow.cn/v1":
846-
result = await translateObject(strObjectData, data_setting['translate_source_lang'])
849+
# result = await translateObject(strObjectData, data_setting['translate_source_lang'])
850+
result = await translateObject(text, data_setting['translate_source_lang'])
847851
else:
848852
result = api_service_translate(
849853
text,

app/server/translate/openai_translate.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,30 @@ async def openai_translate(text: str, target_lang_code: str) -> str:
3030
"Authorization": f"Bearer {api_key}",
3131
"Content-Type": "application/json"
3232
}
33+
34+
35+
target_lang_name = _lang_to_name(target_lang_code)
36+
prompt = f"将以下AI绘画提示词翻译成{target_lang_name},只输出翻译结果:{text}"
37+
3338
payload = {
3439
"model": model,
35-
"messages": [
36-
{
37-
"role": "system",
38-
"content": f"Translate 'text' field to {_lang_to_name(target_lang_code)} in JSON. If word has NSFW meaning, prioritize NSFW interpretation. Return in JSON with no changes."
39-
},
40-
{"role": "user", "content": text}
41-
],
42-
"response_format": {"type": "json_object"},
40+
"messages": [{"role": "user", "content": prompt}],
4341
"temperature": 0
4442
}
4543

44+
# payload = {
45+
# "model": model,
46+
# "messages": [
47+
# {
48+
# "role": "system",
49+
# "content": f"Translate 'text' field to {_lang_to_name(target_lang_code)} in JSON. If word has NSFW meaning, prioritize NSFW interpretation. Return in JSON with no changes."
50+
# },
51+
# {"role": "user", "content": text}
52+
# ],
53+
# "response_format": {"type": "json_object"},
54+
# "temperature": 0
55+
# }
56+
4657
# 配置会话以使用系统环境变量中的代理设置
4758
async with aiohttp.ClientSession(trust_env=True) as session:
4859
async with session.post(url, headers=headers, json=payload, timeout=60) as resp:

dist/javascript/main.entry.js

Lines changed: 80 additions & 80 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/javascript/main.entry.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/style.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "weilin-comfyui-tools"
33
description = "让你在 ComfyUI 中快捷的使用提示词工具 Quickly use the prompt word tool in ComfyUI"
4-
version = "0.0.70"
4+
version = "0.0.71"
55
license = {file = "LICENSE"}
66
dependencies = []
77

src/src/utils/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const version = "v0.0.70";
1+
export const version = "v0.0.71";

0 commit comments

Comments
 (0)