mtranserver 4.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +155 -0
  3. package/dist/bergamot-translator-41rtjv31.wasm +0 -0
  4. package/dist/cld2-8mh0n580.wasm +0 -0
  5. package/dist/config/index.d.ts +23 -0
  6. package/dist/config/index.d.ts.map +1 -0
  7. package/dist/core/engine.d.ts +51 -0
  8. package/dist/core/engine.d.ts.map +1 -0
  9. package/dist/core/factory.d.ts +16 -0
  10. package/dist/core/factory.d.ts.map +1 -0
  11. package/dist/core/interfaces.d.ts +19 -0
  12. package/dist/core/interfaces.d.ts.map +1 -0
  13. package/dist/core/loader.d.ts +22 -0
  14. package/dist/core/loader.d.ts.map +1 -0
  15. package/dist/favicon-16x16-xwsy16sv.png +0 -0
  16. package/dist/favicon-32x32-zstv2hmc.png +0 -0
  17. package/dist/icon-tjp1feba.png +0 -0
  18. package/dist/index-B7vzjIqN-ma6ncj8z.css +1 -0
  19. package/dist/index-D6lVFqDO-3a1nn40g.js +53 -0
  20. package/dist/index-g3cdpfvc.html +15 -0
  21. package/dist/index.d.ts +5 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +7282 -0
  24. package/dist/index.js.map +31 -0
  25. package/dist/lib/bergamot/bergamot-translator.d.ts +3 -0
  26. package/dist/lib/bergamot/bergamot-translator.d.ts.map +1 -0
  27. package/dist/lib/cld2/cld2.d.ts +6 -0
  28. package/dist/lib/cld2/cld2.d.ts.map +1 -0
  29. package/dist/logger/index.d.ts +21 -0
  30. package/dist/logger/index.d.ts.map +1 -0
  31. package/dist/main.js +216629 -0
  32. package/dist/main.js.map +391 -0
  33. package/dist/models/index.d.ts +2 -0
  34. package/dist/models/index.d.ts.map +1 -0
  35. package/dist/models/records.d.ts +33 -0
  36. package/dist/models/records.d.ts.map +1 -0
  37. package/dist/mtran.d.ts +38 -0
  38. package/dist/mtran.d.ts.map +1 -0
  39. package/dist/oauth2-redirect-bqxabm9x.js +1 -0
  40. package/dist/services/detector.d.ts +15 -0
  41. package/dist/services/detector.d.ts.map +1 -0
  42. package/dist/services/engine.d.ts +3 -0
  43. package/dist/services/engine.d.ts.map +1 -0
  44. package/dist/services/index.d.ts +3 -0
  45. package/dist/services/index.d.ts.map +1 -0
  46. package/dist/swagger-initializer-55m7yyx2.js +20 -0
  47. package/dist/swagger-ui-bfxfcsxh.css +3 -0
  48. package/dist/swagger-ui-bundle-a3dgbj09.js +2 -0
  49. package/dist/swagger-ui-bycaq9jd.js +2 -0
  50. package/dist/swagger-ui-standalone-preset-9dtac9s6.js +2 -0
  51. package/dist/utils/cache.d.ts +3 -0
  52. package/dist/utils/cache.d.ts.map +1 -0
  53. package/dist/utils/index.d.ts +5 -0
  54. package/dist/utils/index.d.ts.map +1 -0
  55. package/dist/utils/lang-alias.d.ts +2 -0
  56. package/dist/utils/lang-alias.d.ts.map +1 -0
  57. package/dist/utils/memory.d.ts +2 -0
  58. package/dist/utils/memory.d.ts.map +1 -0
  59. package/dist/utils/port.d.ts +2 -0
  60. package/dist/utils/port.d.ts.map +1 -0
  61. package/dist/utils/version.d.ts +2 -0
  62. package/dist/utils/version.d.ts.map +1 -0
  63. package/package.json +60 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,155 @@
1
+ # MTranServer
2
+
3
+ [中文](README.md) | [English](docs/README_en.md) | [日本語](docs/README_ja.md) | [Français](docs/README_fr.md) | [Deutsch](docs/README_de.md)
4
+
5
+ <!-- <img src="./images/icon.png" width="64px" height="64px" align="right" alt="MTran"> -->
6
+
7
+ 一个超低资源消耗速度超快的离线翻译模型服务器,无需显卡。单个请求平均响应时间 50 毫秒。支持全世界主要语言的翻译。
8
+
9
+ 注意本模型服务器专注于`离线翻译`、`响应速度`、`跨平台部署`、`本地运行` 达到 `无限免费翻译` 的设计目标,受限于模型大小和优化程度,所以翻译质量肯定是不如大模型翻译的效果。需要高质量的翻译建议使用在线大模型 API。
10
+
11
+ > v4 优化了内存占用,速度进一步提升,增强了稳定性,如果你在使用旧版建议立即升级!
12
+
13
+ <img src="./images/preview.png" width="auto" height="460">
14
+
15
+ ## 在线试用 Demo
16
+
17
+ | 网站 | TOKEN | 其他接口 | 提供者 |
18
+ | -------------------------------- | ------------------------- | ------------------------------------------------------------------------------ | ------- |
19
+ | `https://MTranServer.ipacel.cc/ui/?token=__IpacEL_MT_API_TOKEN__` | `__IpacEL_MT_API_TOKEN__` | 沉浸式翻译: `https://MTranServer.ipacel.cc/imme?token=__IpacEL_MT_API_TOKEN__` | [@ApliNi](https://github.com/ApliNi) |
20
+
21
+ 感谢社区贡献者为用户提供试用服务!
22
+
23
+ ## 使用说明
24
+
25
+ 前往 [Releases](https://github.com/xxnuo/MTranServer/releases) 下载对应平台最新版本,直接在命令行启动程序,即可使用。
26
+
27
+ 目前 [MTranServer](https://github.com/xxnuo/MTranServer) 主要是面向服务器使用环境,所以目前只有命令行服务和 Docker 部署。
28
+
29
+ 有计划提供一个桌面端程序和浏览器插件方便使用,敬请期待。
30
+
31
+ > **重要提示:**
32
+ >
33
+ > 首次翻译某个语言对时,服务器会自动下载对应的翻译模型(除非启用了离线模式),这个过程可能需要等待一段时间(取决于网络速度和模型大小)。
34
+ > 模型下载完成后,翻译请求将享受毫秒级的响应速度。建议在正式使用前先测试一次翻译,让服务器预先下载和加载模型。
35
+ >
36
+ > 程序经常更新,如果遇到问题,可以尝试更新到最新版本。
37
+
38
+ 服务器启动后日志会输出程序自带的一个简单 UI 的地址和在线调试文档的地址,下面是预览
39
+
40
+ ![UI](./images/ui.png)
41
+
42
+ ![文档](./images/swagger.png)
43
+
44
+
45
+ ### 命令行参数
46
+
47
+ ```bash
48
+ ./mtranserver [选项]
49
+
50
+ 选项:
51
+ -version, -v 显示版本信息
52
+ -log-level string 日志级别 (debug, info, warn, error) (默认 "warn")
53
+ -config-dir string 配置目录 (默认 "~/.config/mtran/server")
54
+ -model-dir string 模型目录 (默认 "~/.config/mtran/models")
55
+ -host string 服务器监听地址 (默认 "0.0.0.0")
56
+ -port string 服务器端口 (默认 "8989")
57
+ -ui 启用 Web UI (默认 true)
58
+ -offline 启用离线模式,不自动下载新模型 (默认 false)
59
+ -worker-idle-timeout int Worker 空闲超时时间(秒) (默认 300)
60
+
61
+ 示例:
62
+ ./mtranserver --host 127.0.0.1 --port 8080
63
+ ./mtranserver --ui --offline
64
+ ./mtranserver -v
65
+ ```
66
+
67
+ ### Docker Compose 部署
68
+
69
+ 找一个空目录,编写 `compose.yml` 文件,内容如下:
70
+
71
+ ```yml
72
+ services:
73
+ mtranserver:
74
+ image: xxnuo/mtranserver:latest
75
+ container_name: mtranserver
76
+ restart: unless-stopped
77
+ ports:
78
+ - "8989:8989"
79
+ environment:
80
+ - MT_HOST=0.0.0.0
81
+ - MT_PORT=8989
82
+ - MT_ENABLE_UI=true
83
+ - MT_OFFLINE=false
84
+ # - MT_API_TOKEN=your_secret_token_here
85
+ volumes:
86
+ - ./models:/app/models
87
+ ```
88
+
89
+ ```bash
90
+ docker pull xxnuo/mtranserver:latest
91
+ docker compose up -d
92
+ ```
93
+
94
+ #### 翻译插件兼容接口
95
+
96
+ 服务器提供了多个翻译插件的兼容接口:
97
+
98
+ | 接口 | 方法 | 说明 | 支持的插件 |
99
+ | ------------------------------- | ---- | ---------------------------------- | --------------------------------------------------------------------------- |
100
+ | `/imme` | POST | 沉浸式翻译插件接口 | [沉浸式翻译](https://immersivetranslate.com/) |
101
+ | `/kiss` | POST | 简约翻译插件接口 | [简约翻译](https://github.com/fishjar/kiss-translator) |
102
+ | `/deepl` | POST | DeepL API v2 兼容接口 | 支持 DeepL API 的客户端 |
103
+ | `/google/language/translate/v2` | POST | Google Translate API v2 兼容接口 | 支持 Google Translate API 的客户端 |
104
+ | `/google/translate_a/single` | GET | Google translate_a/single 兼容接口 | 支持 Google 网页翻译的客户端 |
105
+ | `/hcfy` | POST | 划词翻译兼容接口 | [划词翻译](https://github.com/Selection-Translator/crx-selection-translate) |
106
+
107
+ **插件配置说明:**
108
+
109
+ > 注:
110
+ >
111
+ > - [沉浸式翻译](https://immersivetranslate.com/zh-Hans/docs/services/custom/) 在`设置`页面,开发者模式中启用`Beta`特性,即可在`翻译服务`中看到`自定义 API 设置`([官方图文教程](https://immersivetranslate.com/zh-Hans/docs/services/custom/))。然后将`自定义 API 设置`的`每秒最大请求数`拉高以充分发挥服务器性能准备体验飞一般的感觉。我设置的是`每秒最大请求数`为`512`,`每次请求最大段落数`为`1`。你可以根据自己服务器配置设置。
112
+ >
113
+ > - [简约翻译](https://github.com/fishjar/kiss-translator) 在`设置`页面,接口设置中滚动到下面,即可看到自定义接口 `Custom`。同理,设置`最大请求并发数量`、`每次请求间隔时间`以充分发挥服务器性能。我设置的是`最大请求并发数量`为`100`,`每次请求间隔时间`为`1`。你可以根据自己服务器配置设置。
114
+ >
115
+ > 接下来按下表的设置方法设置插件的自定义接口地址。
116
+
117
+ | 名称 | URL | 插件设置 |
118
+ | ---------------- | ---------------------------------------------------- | --------------------------------------------------------------- |
119
+ | 沉浸式翻译无密码 | `http://localhost:8989/imme` | `自定义API 设置` - `API URL` |
120
+ | 沉浸式翻译有密码 | `http://localhost:8989/imme?token=your_token` | 同上,需要更改 URL 尾部的 `your_token` 为你的 `MT_API_TOKEN` 值 |
121
+ | 简约翻译无密码 | `http://localhost:8989/kiss` | `接口设置` - `Custom` - `URL` |
122
+ | 简约翻译有密码 | `http://localhost:8989/kiss` | 同上,需要 `KEY` 填 `your_token` |
123
+ | DeepL 兼容 | `http://localhost:8989/deepl` | 使用 `DeepL-Auth-Key` 或 `Bearer` 认证 |
124
+ | Google 兼容 | `http://localhost:8989/google/language/translate/v2` | 使用 `key` 参数或 `Bearer` 认证 |
125
+ | 划词翻译 | `http://localhost:8989/hcfy` | 支持 `token` 参数或 `Bearer` 认证 |
126
+
127
+ **普通用户参照表格内容设置好插件使用的接口地址就可以使用了。**
128
+
129
+ ## 同类项目
130
+
131
+ 列出一些同类功能的项目,如果有其他需求的用户可以尝试这些项目:
132
+
133
+ | 项目名称 | 内存占用 | 并发性能 | 翻译效果 | 速度 | 其他信息 |
134
+ | ------------------------------------------------------------------ | -------- | -------- | -------- | ---- | --------------------------------------------------------------------------------------------------------------------------------- |
135
+ | [NLLB](https://github.com/facebookresearch/fairseq/tree/nllb) | 很高 | 差 | 一般 | 慢 | 大佬移植到了 Android 的 [RTranslator](https://github.com/niedev/RTranslator) 有很多优化,但占用仍然高,速度也不快 |
136
+ | [LibreTranslate](https://github.com/LibreTranslate/LibreTranslate) | 很高 | 一般 | 一般 | 中等 | 中端 CPU 每秒处理 3 句,高端 CPU 每秒处理 15-20 句,[详情](https://community.libretranslate.com/t/performance-benchmark-data/486) |
137
+ | [OPUS-MT](https://github.com/OpenNMT/CTranslate2#benchmarks) | 高 | 一般 | 略差 | 快 | [性能测试](https://github.com/OpenNMT/CTranslate2#benchmarks) |
138
+ | 其他大模型 | 超高 | 动态 | 非常好 | 很慢 | 对硬件要求很高,如果需要高并发翻译建议使用 vllm 框架,通过内存占用和显存占用来控制翻译并发量 |
139
+ | 本项目 | 低 | 高 | 一般 | 极快 | 单个请求平均响应时间 50ms |
140
+
141
+ > 表中为 CPU、英译中场景下的简单测试,非严格测试,非量化版本对比,仅供参考。
142
+
143
+ # 高级配置说明
144
+
145
+ 请参考 [API.md](API.md) 文件和启动后的 API 文档。
146
+
147
+ ## Star History
148
+
149
+ [![Star History Chart](https://api.star-history.com/svg?repos=xxnuo/MTranServer&type=Timeline)](https://www.star-history.com/#xxnuo/MTranServer&Timeline)
150
+
151
+ ## Thanks
152
+
153
+ [Bergamot Project](https://browser.mt/) for awesome idea of local translation.
154
+
155
+ [Mozilla](https://github.com/mozilla) for the [models](https://github.com/mozilla/firefox-translations-models).
Binary file
@@ -0,0 +1,23 @@
1
+ export interface Config {
2
+ logLevel: string;
3
+ homeDir: string;
4
+ configDir: string;
5
+ modelDir: string;
6
+ host: string;
7
+ port: string;
8
+ enableWebUI: boolean;
9
+ enableOfflineMode: boolean;
10
+ workerIdleTimeout: number;
11
+ workersPerLanguage: number;
12
+ apiToken: string;
13
+ logDir: string;
14
+ logToFile: boolean;
15
+ logConsole: boolean;
16
+ logRequests: boolean;
17
+ maxLengthBreak: number;
18
+ checkUpdate: boolean;
19
+ cacheSize: number;
20
+ }
21
+ export declare function getConfig(): Config;
22
+ export declare function setConfig(config: Partial<Config>): void;
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,MAAM;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,OAAO,CAAC;IACrB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAqED,wBAAgB,SAAS,IAAI,MAAM,CA2ClC;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,QAGhD"}
@@ -0,0 +1,51 @@
1
+ import { BergamotModule } from '@/core/interfaces.js';
2
+ import { ModelBuffers } from '@/core/loader.js';
3
+ export interface TranslationOptions {
4
+ sourceLang?: string;
5
+ targetLang?: string;
6
+ cacheSize?: number;
7
+ }
8
+ export interface TranslateOptions {
9
+ qualityScores?: boolean;
10
+ alignment?: boolean;
11
+ html?: boolean;
12
+ }
13
+ export interface TranslationConfig {
14
+ 'beam-size'?: number;
15
+ 'normalize'?: number;
16
+ 'word-penalty'?: number;
17
+ 'max-length-break'?: number;
18
+ 'mini-batch-words'?: number;
19
+ 'workspace'?: number;
20
+ 'max-length-factor'?: number;
21
+ 'skip-cost'?: boolean;
22
+ 'cpu-threads'?: number;
23
+ 'quiet'?: boolean;
24
+ 'quiet-translation'?: boolean;
25
+ 'gemm-precision'?: string;
26
+ 'alignment'?: string;
27
+ }
28
+ export declare class TranslationEngine {
29
+ private options;
30
+ private bergamot;
31
+ private service;
32
+ private model;
33
+ private isReady;
34
+ private translating;
35
+ private pendingQueue;
36
+ private maxLengthBreak;
37
+ constructor(options?: TranslationOptions);
38
+ init(bergamotModule: BergamotModule, modelBuffers: ModelBuffers, config?: TranslationConfig): Promise<void>;
39
+ translate(text: string, options?: TranslateOptions): string;
40
+ private _sanitizeHTML;
41
+ translateAsync(text: string, options?: TranslateOptions): Promise<string>;
42
+ private _processQueue;
43
+ private _translateInternal;
44
+ private _isFatalWASMError;
45
+ private _translateLongText;
46
+ private _chunkByLength;
47
+ private _hideEmojis;
48
+ private _restoreEmojis;
49
+ destroy(): void;
50
+ }
51
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/core/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,WAAW,kBAAkB;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AASD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,YAAY,CAAmB;IACvC,OAAO,CAAC,cAAc,CAAO;gBAEjB,OAAO,GAAE,kBAAuB;IAItC,IAAI,CAAC,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,GAAE,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAiErH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM;IA8B/D,OAAO,CAAC,aAAa;IAWf,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC;IAOnF,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,kBAAkB;IAwC1B,OAAO,CAAC,iBAAiB;IAUzB,OAAO,CAAC,kBAAkB;IA8C1B,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,cAAc;IAQtB,OAAO,IAAI,IAAI;CAehB"}
@@ -0,0 +1,16 @@
1
+ import { ResourceLoader } from '@/core/loader.js';
2
+ export interface DownloadOptions {
3
+ url: string;
4
+ outputPath: string;
5
+ hash?: string;
6
+ }
7
+ export declare class Downloader {
8
+ private timeout;
9
+ constructor(timeout?: number);
10
+ download(options: DownloadOptions): Promise<void>;
11
+ decompress(inputPath: string, outputPath: string): Promise<void>;
12
+ private downloadBinary;
13
+ }
14
+ export declare function createDownloader(): Downloader;
15
+ export declare function createResourceLoader(): ResourceLoader;
16
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/core/factory.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAGjD,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAAQ;gBAEX,OAAO,GAAE,MAAgB;IAI/B,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAejD,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAMxD,cAAc;CAsB7B;AAED,wBAAgB,gBAAgB,IAAI,UAAU,CAE7C;AAqBD,wBAAgB,oBAAoB,IAAI,cAAc,CAErD"}
@@ -0,0 +1,19 @@
1
+ export interface FileSystem {
2
+ readFile(filepath: string): Promise<Buffer>;
3
+ fileExists(filepath: string): Promise<boolean>;
4
+ joinPath(...paths: string[]): string;
5
+ }
6
+ export interface BergamotModule {
7
+ wasmBinary?: ArrayBuffer | Buffer;
8
+ print?: (msg: string) => void;
9
+ printErr?: (msg: string) => void;
10
+ onRuntimeInitialized?: () => void;
11
+ onAbort?: (msg: string) => void;
12
+ AlignedMemory: any;
13
+ AlignedMemoryList: any;
14
+ TranslationModel: any;
15
+ BlockingService: any;
16
+ VectorString: any;
17
+ VectorResponseOptions: any;
18
+ }
19
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/core/interfaces.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/C,QAAQ,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;CACtC;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC;IAClC,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,oBAAoB,CAAC,EAAE,MAAM,IAAI,CAAC;IAClC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,aAAa,EAAE,GAAG,CAAC;IACnB,iBAAiB,EAAE,GAAG,CAAC;IACvB,gBAAgB,EAAE,GAAG,CAAC;IACtB,eAAe,EAAE,GAAG,CAAC;IACrB,YAAY,EAAE,GAAG,CAAC;IAClB,qBAAqB,EAAE,GAAG,CAAC;CAC5B"}
@@ -0,0 +1,22 @@
1
+ import { FileSystem, BergamotModule } from '@/core/interfaces.js';
2
+ export interface ModelFileNames {
3
+ model?: string;
4
+ lex?: string;
5
+ srcvocab?: string;
6
+ trgvocab?: string;
7
+ }
8
+ export interface ModelBuffers {
9
+ model: Buffer;
10
+ lex: Buffer;
11
+ srcvocab: Buffer;
12
+ trgvocab: Buffer;
13
+ qualityModel?: Buffer;
14
+ }
15
+ export declare class ResourceLoader {
16
+ private fileSystem;
17
+ constructor(fileSystem: FileSystem);
18
+ loadBergamotModule(wasmBinary: ArrayBuffer | Buffer, loadBergamot: any): Promise<BergamotModule>;
19
+ loadModelFiles(modelPath: string, fileNames?: ModelFileNames | null): Promise<ModelBuffers>;
20
+ loadWasmBinary(wasmPath: string): Promise<Buffer>;
21
+ }
22
+ //# sourceMappingURL=loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/core/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGlE,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,cAAc;IACb,OAAO,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAEpC,kBAAkB,CAAC,UAAU,EAAE,WAAW,GAAG,MAAM,EAAE,YAAY,EAAE,GAAG,GAAG,OAAO,CAAC,cAAc,CAAC;IA0BhG,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,GAAE,cAAc,GAAG,IAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAuBjG,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAGxD"}
Binary file
Binary file
Binary file