1 line
10 KiB
JSON
1 line
10 KiB
JSON
{"repo": "bistutu/fluentread", "files": {"entrypoints/service/infini.ts": {"ab1be13b31b9aaa874eb7e7d5ac652d722ba649a": {"t": 1785595428.6780427, "n": 1097, "h": "d1c336f3d352a578", "c": "// 引入所需模块\nimport {customModelString, services} from \"../utils/option\";\nimport {method} from \"../utils/constant\";\nimport {commonMsgTemplate} from \"@/entrypoints/utils/template\";\nimport {config} from \"@/entrypoints/utils/config\";\n\nasync function infini(message: any) {\n // 构建请求头\n let headers = new Headers();\n headers.append('Content-Type', 'application/json');\n headers.append('Authorization', `Bearer ${config.token[services.infini]}`);\n\n let model = config.model[services.infini] === customModelString ? config.customModel[services.infini] : config.model[services.infini]\n\n // 发起 fetch 请求\n const resp = await fetch(`https://cloud.infini-ai.com/maas/${model}/nvidia/chat/completions`, {\n method: method.POST,\n headers: headers,\n body: commonMsgTemplate(message.origin)\n });\n\n if (resp.ok) {\n let result = await resp.json();\n return result.choices[0].message.content\n } else {\n console.error(resp);\n throw new Error(`请求失败: ${resp.status} ${resp.statusText} body: ${await resp.text()}`);\n }\n}\n\nexport default infini;\n"}}, "docs/config/translation-engines.md": {"ab1be13b31b9aaa874eb7e7d5ac652d722ba649a": {"t": 1785595428.9834015, "n": 4021, "h": "6dbd20c196071926", "c": "# 翻译引擎配置\n\n流畅阅读支持多种翻译引擎,包括传统机器翻译和大语言模型。本文将介绍各个翻译引擎的配置方法。\n\n## 支持的翻译引擎\n\n### 免费服务\n- **Microsoft 翻译**:免费且无需配置,开箱即用,支持多种语言互译\n- **Google 翻译**:免费且无需配置,支持多种语言,国内暂不支持使用\n- **DeepL (免费版)**:每月 50 万字符免费额度,[开发者平台](https://www.deepl.com/pro-api)\n- **小牛翻译**:[API 文档](https://niutrans.com/dev-page?type=text)\n\n### AI 大模型\n- **OpenAI(推荐⭐️)**:国际领先的大模型服务,支持 GPT-4o 和 GPT-o1-mini 等,[API 文档](https://platform.openai.com/docs/api-reference)\n- **DeepSeek(推荐⭐️)**:国内领先的大模型服务,[开发者中心](https://platform.deepseek.com/)\n- **SiliconCloud(推荐⭐️)**:国内多模型聚合服务,**提供免费模型**,包括 `Qwen2.5-7B-Instruct`、`Meta-Llama-3.1-8B-Instruct`、`gemma-2-9b-it` 等,[API 文档](https://cloud.siliconflow.cn/models)\n- **Kimi**:[API 文档](https://platform.moonshot.cn/)\n- **腾讯混元**:[API 中心](https://cloud.tencent.com/document/product/1729)\n- **字节豆包**:[开发者平台](https://www.volcengine.com/product/doubao)\n- **阿里通义**:[API 文档](https://help.aliyun.com/zh/dashscope/developer-reference/api-details)\n- **智谱清言**:免费提供 `GLM-4-Flash` 模型,[开放平台](https://open.bigmodel.cn/console/overview)\n- **OpenRouter**:国外多模型聚合服务,提供免费模型,[API 参考](https://openrouter.ai/docs)\n- **Groq**:国外多模型聚合服务,提供免费模型,[开发者文档](https://groq.com/)\n- **百度文心**:[开放平台](https://cloud.baidu.com/doc/WENXINWORKSHOP/index.html)\n- **百川智能**:[开发者文档](https://platform.baichuan-ai.com/docs/api)\n- **零一万物**:[API 中心](https://platform.lingyiwanwu.com/)\n- **MiniMax**:[开放平台](https://api.minimax.chat/)\n- **无问芯穹**:[开发者平台](https://cloud.infini-ai.com/promotion)\n- **阶跃星辰**:[开发者平台](https://platform.stepfun.com/)\n- **Claude**:Anthropic 公司的 AI 模型,[API 参考](https://docs.anthropic.com/claude/reference)\n- **Gemini**:谷歌最新的 AI 模型,[API 文档](https://ai.google.dev/)\n- **Ollama**:开源的本地部署模型,[GitHub页面](https://github.com/ollama/ollama)\n\n## 配置示例:以 DeepSeek 为例\n\n<img src=\"/model.png\" alt=\"模型选择\" style=\"width: 60%; max-width: 40%;border: 1px solid #eee;border-radius: 4px;box-shadow: 0 1px 2px rgba(0,0,0,0.05);\" />\n\n### 1. 获取 API Key\n1. 访问 [DeepSeek 开发者中心](https://platform.deepseek.com/)\n2. 注册/登录账号\n3. 进入 API Keys 页面创建密钥\n4. 复制生成的 API Key\n\n<img src=\"/deepseek-apikey.png\" alt=\"DeepSeek API Key\" style=\"width: 80%; max-width: 100%;border: 1px solid #eee;border-radius: 4px;box-shadow: 0 1px 2px rgba(0,0,0,0.05);\" />\n\n### 2. 配置插件\n1. 点击浏览器工具栏中的流畅阅读图标\n2. 点击设置图标,进入设置页面\n3. 选择 \"翻译引擎\" 选项卡\n4. 在引擎列表中选择 \"DeepSeek\"\n5. 选择 `deepseek-chat` 模型,并填入配置信息\n\n<img src=\"/click-fluent_read.png\" alt=\"点击流畅阅读图标\" style=\"width: 80%; max-width: 100%;border: 1px solid #eee;border-radius: 4px;box-shadow: 0 1px 2px rgba(0,0,0,0.05);\" />\n\n\n### 4. 使用效果\n原文:\n```text\nThe quantum computer performs operations on qubits, which can exist in multiple states simultaneously due to quantum superposition.\n```\n\n翻译结果:\n```text\n量子计算机对量子比特进行操作,由于量子叠加原理,这些量子比特可以同时存在于多个状态。\n```\n\n### 5. 高级选项\n\n<img src=\"/advance.png\" alt=\"高级选项\" style=\"width: 40%; max-width: 100%;border: 1px solid #eee;border-radius: 4px;box-shadow: 0 1px 2px rgba(0,0,0,0.05);\" />\n\n#### 代理配置\n如果你所在的网络环境无法直接访问某些 AI 服务,可以配置代理服务器。一般情况下无需配置此项。\n\n\n#### 提示词配置\n大语言模型的翻译效果很大程度上取决于提示词(Prompt)的设置。流畅阅读提供了默认的提示词配置:\n\n##### 系统提示词(System Prompt)\n```text\nYou are a professional, authentic machine translation engine.\nYou only return the translated text, without any explanations.\n```\n\n这个提示词告诉模型:\n- 扮演专业的机器翻译引擎\n- 只返回翻译结果\n- 不添加任何解释或额外信息\n\n##### 用户提示词(User Prompt)\n```\nTranslate the following text into {to}, \noutput translation text directly without any extra information:\n\n{{origin}}\n```\n\n其中:\n```text\n{{to}} 表示目标语言\n{{origin}} 表示原文内容\n```\n\n两者不可或缺。\n\n#### 自定义提示词\n你可以根据需要自定义提示词,以获得不同的翻译效果:\n\n1. **更正式的翻译**\n```text\nYou are a professional translator specializing in formal documentation.\nTranslate with accuracy and maintain professional terminology.\n```\n\n2. **更口语化的翻译**\n```text\nYou are a translator focusing on natural, conversational language.\nTranslate into casual, everyday speech.\n```\n\n3. **技术文档翻译**\n```text\nYou are a technical documentation translator.\nMaintain precise technical terms and professional standards.\n```\n\n::: tip 提示\n1. 修改提示词时请保持简洁明确\n2. 避免添加过多限制条件\n3. 确保提示词与目标语言相匹配\n:::\n\n## 下一步\n\n- 访问 [GitHub Issues](https://github.com/Bistutu/FluentRead/issues) 反馈问题 \n"}}, "entrypoints/utils/constant.ts": {"ab1be13b31b9aaa874eb7e7d5ac652d722ba649a": {"t": 1785809866.577197, "n": 2831, "h": "9ed0c59d0e2a4420", "c": "import { services } from \"./option\";\n\n// 常量工具类\nexport const urls: any = {\n [services.deepL]: \"https://api-free.deepl.com/v2/translate\",\n [services.deeplx]: \"http://localhost:1188/translate\",\n [services.openai]: \"https://api.openai.com/v1/chat/completions\",\n [services.azureOpenai]: \"https://your-resource-name.openai.azure.com/openai/deployments/your-deployment-name/chat/completions?api-version=2024-02-15-preview\",\n [services.moonshot]: \"https://api.moonshot.cn/v1/chat/completions\",\n [services.custom]: \"https://localhost:11434/v1/chat/completions\",\n [services.tongyi]: \"https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions\",\n [services.zhipu]: \"https://open.bigmodel.cn/api/paas/v4/chat/completions\",\n [services.xiaoniu]: \"https://api.niutrans.com/NiuTransServer/translationXML\",\n [services.youdao]: \"https://openapi.youdao.com/api\",\n [services.tencent]: \"https://tmt.tencentcloudapi.com/\",\n [services.claude]: \"https://api.anthropic.com/v1/messages\",\n [services.baichuan]: \"https://api.baichuan-ai.com/v1/chat/completions\",\n [services.lingyi]: \"https://api.lingyiwanwu.com/v1/chat/completions\",\n [services.deepseek]: \"https://api.deepseek.com/chat/completions\",\n [services.jieyue]: \"https://api.stepfun.com/v1/chat/completions\",\n [services.yiyan]: {tokenUrl: \"https://aip.baidubce.com/oauth/2.0/token\"},\n [services.groq]: \"https://api.groq.com/openai/v1/chat/completions\",\n [services.cozecom]: \"https://api.coze.com/open_api/v2/chat\",\n [services.cozecn]: \"https://api.coze.cn/open_api/v2/chat\",\n [services.huanYuan]: \"https://api.hunyuan.cloud.tencent.com/v1/chat/completions\",\n [services.huanYuanTranslation]: \"https://hunyuan.tencentcloudapi.com/\",\n [services.doubao]: \"https://ark.cn-beijing.volces.com/api/v3/chat/completions\",\n [services.siliconCloud]: \"https://api.siliconflow.cn/v1/chat/completions\",\n [services.openrouter]: \"https://openrouter.ai/api/v1/chat/completions\",\n [services.grok]: \"https://api.x.ai/v1/chat/completions\",\n\n // [services.baidufree]:\"https://fanyi.baidu.com/transapi\"\n // [services.baidu]: \"https://fanyi-api.baidu.com/api/trans/vip/translate\",\n}\n\nexport const method = {POST: \"POST\", GET: \"GET\",};\n\nexport const constants = {\n // 键鼠事件\n DoubleClick: \"DoubleClick\",\n LongPress: \"LongPress\",\n MiddleClick: \"MiddleClick\",\n // 触屏设备事件\n TwoFinger: \"TwoFinger\",\n ThreeFinger: \"ThreeFinger\",\n FourFinger: \"FourFinger\",\n DoubleClickScreen: \"DoubleClickScree\",\n TripleClickScreen: \"TripleClickScreen\",\n}\n\nexport const styles = {\n // 仅译文模式\n singleTranslation: 0,\n // 双语对照模式\n bilingualTranslation: 1,\n}\n\n// 右键菜单ID常量\nexport const CONTEXT_MENU_IDS = {\n TRANSLATE_FULL_PAGE: 'fluent-read-translate-full-page',\n RESTORE_ORIGINAL: 'fluent-read-restore-original',\n}\n"}}}} |