Pot翻译软件介绍
都搜索到这里了应该不用怎么介绍吧,本次我的插件则是专门针对它的划词翻译的。大模型的接入使我们在翻译的时候不用担心pdf的复制粘贴的格式错乱问题。
- Pot翻译软件下载链接:https://www.pot-app.com/
集成SprakLite的翻译插件开发
目前作者设计的部分大模型插件都是要钱购买API的,这不符合我们一贯的白嫖风格,所以集成一个可以白嫖的大模型就成为了当下的难题。虽然但是,大部分同学甚至连github也上不了,更不用说看懂并更改代码了,所以我帮大家搞好了一切。(毕竟SparkLite是完全免费的、无限token)
- Pot官方模板链接:https://github.com/pot-app/pot-app-translate-plugin-template
主要代码如下:
async function translate(text, from, to, options) {
const { utils } = options;
const { tauriFetch: fetch } = utils;
// 星火大模型 API URL 和 Authorization Token
const URL = "https://spark-api-open.xf-yun.com/v1/chat/completions"; // 星火大模型的 API URL
const MODEL = "lite"; // 模型类型,根据实际需求调整
const API_PASSWORD="nLfUQCAeJWwOBcHEfnIm:uhtjZtjISPJZIXCJROPk"
//此处的API仅能调用免费的sprakLite,并且我不会往星火里面充一分钱,所以不用想盗刷我的什么的。
// 请求体的构建, 输入你自己领域的系统提示词,这样会让翻译更加精准,最好先输入英文的提示词。
/**
您是计算机科学、人工智能和计算生物数学领域的专家。
请将英文文本翻译成中文,确保翻译专业、优雅、流畅,避免典型的机器翻译风格。
其次,作为专家,您应该能够识别原始文本中的任何格式和排版问题,并将这些问题纠正为更好的格式。
最后,您需要识别段落中任何明显不相关的部分,并自动省略这些部分,以确保翻译的连贯性和流畅性。
请仅输出翻译后的文本,不要提供解释。
*/
const body = {
model: MODEL,
messages: [
{
role: "system",
content: "You are an expert in computer science, artificial intelligence, and computational bio-mathematics. Please translate the English text into Chinese, ensuring that the translation is professional, elegant, and fluent, avoiding the typical style of machine translation. Secondly, as an expert, you should be able to identify any formatting and typography issues in the original text and correct these to output in a better format. Finally, you need to identify any clearly irrelevant parts within the paragraph and automatically omit these sections to ensure coherence and smoothness in the translation. Please output only the translated text without providing explanations."
},
{ role: "user", content: `Translate into Chinese ${text}` }
]
};
const headers = {
'Content-Type': 'application/json',
'Authorization': `Bearer ${API_PASSWORD}`,
};
try {
// 调用 星火大模型 API
let res = await fetch(URL, {
method: 'POST',
headers: headers,
body: {
type: 'Json',
payload: body
}
});
if (res.ok) {
let result = res.data;
const { choices } = result;
if (choices && choices.length > 0) {
return choices[0].message.content.trim();
} else {
throw `Unexpected Response Format: ${JSON.stringify(result)}`;
}
} else {
throw `Http Request Error\nHttp Status: ${res.status}\n${JSON.stringify(res.data)}`;
}
} catch (error) {
throw `Translation Error: ${error}`;
}
}
如何使用
方法1(什么都不想动的)
- 百度云下载地址:https://pan.baidu.com/s/1qy96DfI37RHNvM0O5wIocA?pwd=2024
- github下载地址:https://github.com/qcjySONG/Pot_with_SparkLite
下载的文件夹里面会有一个名字为plugin.com.pot-app.SparkLite.potext的东西,直接安装即可,如下图所示:
但是请注意,我集成的插件当中的提示词为:** 您是计算机科学、人工智能和计算生物数学领域的专家。**假设你是其它领域的同学,则要使用方法二,不然翻译的或许没那么好。
方法二(要改动一下txt的)
- 百度云下载地址:https://pan.baidu.com/s/1qy96DfI37RHNvM0O5wIocA?pwd=2024
- github下载地址:https://github.com/qcjySONG/Pot_with_SparkLite
打开文件夹,找到main.js文件,选择用记事本打开。
改完之后就是打包过程,复制plugin.com.pot-app.SparkLite.potext,然后看下图操作:
:
-