polyglot-gpu 1.0.2__tar.gz
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.
- polyglot_gpu-1.0.2/.github/dependabot.yml +10 -0
- polyglot_gpu-1.0.2/.github/workflows/ci.yml +45 -0
- polyglot_gpu-1.0.2/.github/workflows/pages.yml +50 -0
- polyglot_gpu-1.0.2/.github/workflows/publish.yml +20 -0
- polyglot_gpu-1.0.2/.gitignore +12 -0
- polyglot_gpu-1.0.2/CHANGELOG.md +25 -0
- polyglot_gpu-1.0.2/LICENSE +21 -0
- polyglot_gpu-1.0.2/Makefile +13 -0
- polyglot_gpu-1.0.2/PKG-INFO +195 -0
- polyglot_gpu-1.0.2/README.es.md +169 -0
- polyglot_gpu-1.0.2/README.fr.md +169 -0
- polyglot_gpu-1.0.2/README.hi.md +169 -0
- polyglot_gpu-1.0.2/README.it.md +169 -0
- polyglot_gpu-1.0.2/README.ja.md +169 -0
- polyglot_gpu-1.0.2/README.md +170 -0
- polyglot_gpu-1.0.2/README.pt-BR.md +169 -0
- polyglot_gpu-1.0.2/README.zh.md +169 -0
- polyglot_gpu-1.0.2/SCORECARD.md +49 -0
- polyglot_gpu-1.0.2/SECURITY.md +19 -0
- polyglot_gpu-1.0.2/SHIP_GATE.md +80 -0
- polyglot_gpu-1.0.2/pyproject.toml +43 -0
- polyglot_gpu-1.0.2/site/astro.config.mjs +13 -0
- polyglot_gpu-1.0.2/site/package-lock.json +6141 -0
- polyglot_gpu-1.0.2/site/package.json +17 -0
- polyglot_gpu-1.0.2/site/src/pages/index.astro +33 -0
- polyglot_gpu-1.0.2/site/src/site-config.ts +77 -0
- polyglot_gpu-1.0.2/site/src/styles/global.css +3 -0
- polyglot_gpu-1.0.2/site/tsconfig.json +5 -0
- polyglot_gpu-1.0.2/src/pypolyglot/__init__.py +63 -0
- polyglot_gpu-1.0.2/src/pypolyglot/__main__.py +11 -0
- polyglot_gpu-1.0.2/src/pypolyglot/cache.py +221 -0
- polyglot_gpu-1.0.2/src/pypolyglot/errors.py +95 -0
- polyglot_gpu-1.0.2/src/pypolyglot/glossary.py +60 -0
- polyglot_gpu-1.0.2/src/pypolyglot/languages.py +90 -0
- polyglot_gpu-1.0.2/src/pypolyglot/markdown.py +521 -0
- polyglot_gpu-1.0.2/src/pypolyglot/ollama.py +397 -0
- polyglot_gpu-1.0.2/src/pypolyglot/polish.py +61 -0
- polyglot_gpu-1.0.2/src/pypolyglot/semaphore.py +46 -0
- polyglot_gpu-1.0.2/src/pypolyglot/server.py +182 -0
- polyglot_gpu-1.0.2/src/pypolyglot/translate.py +343 -0
- polyglot_gpu-1.0.2/src/pypolyglot/translate_all.py +183 -0
- polyglot_gpu-1.0.2/src/pypolyglot/validate.py +120 -0
- polyglot_gpu-1.0.2/tests/__init__.py +0 -0
- polyglot_gpu-1.0.2/tests/test_cache.py +93 -0
- polyglot_gpu-1.0.2/tests/test_glossary.py +33 -0
- polyglot_gpu-1.0.2/tests/test_languages.py +43 -0
- polyglot_gpu-1.0.2/tests/test_markdown.py +101 -0
- polyglot_gpu-1.0.2/tests/test_polish.py +34 -0
- polyglot_gpu-1.0.2/tests/test_validate.py +60 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
paths:
|
|
6
|
+
- "src/**"
|
|
7
|
+
- "tests/**"
|
|
8
|
+
- "pyproject.toml"
|
|
9
|
+
- ".github/workflows/**"
|
|
10
|
+
pull_request:
|
|
11
|
+
paths:
|
|
12
|
+
- "src/**"
|
|
13
|
+
- "tests/**"
|
|
14
|
+
- "pyproject.toml"
|
|
15
|
+
- ".github/workflows/**"
|
|
16
|
+
workflow_dispatch:
|
|
17
|
+
|
|
18
|
+
concurrency:
|
|
19
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
20
|
+
cancel-in-progress: true
|
|
21
|
+
|
|
22
|
+
jobs:
|
|
23
|
+
test:
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
strategy:
|
|
26
|
+
matrix:
|
|
27
|
+
python-version: ["3.11", "3.12"]
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@v4
|
|
30
|
+
- uses: actions/setup-python@v5
|
|
31
|
+
with:
|
|
32
|
+
python-version: ${{ matrix.python-version }}
|
|
33
|
+
- run: pip install -e . pytest pytest-asyncio pytest-cov
|
|
34
|
+
- run: pytest tests/ -v --cov=pypolyglot --cov-report=xml
|
|
35
|
+
- name: Upload coverage
|
|
36
|
+
if: matrix.python-version == '3.12'
|
|
37
|
+
uses: codecov/codecov-action@v4
|
|
38
|
+
with:
|
|
39
|
+
files: coverage.xml
|
|
40
|
+
fail_ci_if_error: false
|
|
41
|
+
- name: Dependency audit
|
|
42
|
+
if: matrix.python-version == '3.12'
|
|
43
|
+
run: |
|
|
44
|
+
pip install pip-audit
|
|
45
|
+
pip-audit --skip-editable
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
name: Deploy site to GitHub Pages
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
paths:
|
|
7
|
+
- 'site/**'
|
|
8
|
+
- '.github/workflows/pages.yml'
|
|
9
|
+
workflow_dispatch:
|
|
10
|
+
|
|
11
|
+
concurrency:
|
|
12
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
13
|
+
cancel-in-progress: true
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
pages: write
|
|
18
|
+
id-token: write
|
|
19
|
+
|
|
20
|
+
jobs:
|
|
21
|
+
build:
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v4
|
|
25
|
+
|
|
26
|
+
- uses: actions/setup-node@v4
|
|
27
|
+
with:
|
|
28
|
+
node-version: 22
|
|
29
|
+
|
|
30
|
+
- name: Install site dependencies
|
|
31
|
+
working-directory: site
|
|
32
|
+
run: npm ci
|
|
33
|
+
|
|
34
|
+
- name: Build site
|
|
35
|
+
working-directory: site
|
|
36
|
+
run: npm run build
|
|
37
|
+
|
|
38
|
+
- uses: actions/upload-pages-artifact@v3
|
|
39
|
+
with:
|
|
40
|
+
path: site/dist
|
|
41
|
+
|
|
42
|
+
deploy:
|
|
43
|
+
needs: build
|
|
44
|
+
runs-on: ubuntu-latest
|
|
45
|
+
environment:
|
|
46
|
+
name: github-pages
|
|
47
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
48
|
+
steps:
|
|
49
|
+
- id: deployment
|
|
50
|
+
uses: actions/deploy-pages@v4
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
environment: pypi
|
|
11
|
+
permissions:
|
|
12
|
+
id-token: write
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-python@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.12"
|
|
18
|
+
- run: pip install hatchling build
|
|
19
|
+
- run: python -m build
|
|
20
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.2 (2026-03-06)
|
|
4
|
+
|
|
5
|
+
- Renamed PyPI distribution from `py-polyglot` to `polyglot-gpu` (import name `pypolyglot` unchanged)
|
|
6
|
+
- CLI entry point renamed to `polyglot-gpu`
|
|
7
|
+
|
|
8
|
+
## 1.0.1 (2026-03-06)
|
|
9
|
+
|
|
10
|
+
- Shipcheck compliance: verify script, dependency audit, dependabot
|
|
11
|
+
- Landing page via @mcptoolshop/site-theme
|
|
12
|
+
- Translated READMEs (7 languages)
|
|
13
|
+
|
|
14
|
+
## 1.0.0 (2026-03-06)
|
|
15
|
+
|
|
16
|
+
- Initial release — Python port of polyglot-mcp
|
|
17
|
+
- 57 languages via TranslateGemma + Ollama
|
|
18
|
+
- Dual-use: Python library (`pip install polyglot-gpu`) + MCP server
|
|
19
|
+
- Core translation with chunking, batching, retry, and validation
|
|
20
|
+
- Markdown-aware translation preserving code blocks, tables, HTML
|
|
21
|
+
- Multi-language orchestrator with concurrent translation
|
|
22
|
+
- Segment-level caching with fuzzy matching (translation memory)
|
|
23
|
+
- Software glossary for accurate technical translations
|
|
24
|
+
- Auto-start Ollama and auto-pull models
|
|
25
|
+
- GPU-safe concurrency control via semaphore
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mcp-tool-shop
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: polyglot-gpu
|
|
3
|
+
Version: 1.0.2
|
|
4
|
+
Summary: Local GPU translation Python library + MCP server — TranslateGemma via Ollama, 57 languages, zero cloud dependency
|
|
5
|
+
Project-URL: Homepage, https://github.com/mcp-tool-shop-org/py-polyglot
|
|
6
|
+
Project-URL: Repository, https://github.com/mcp-tool-shop-org/py-polyglot
|
|
7
|
+
Project-URL: Issues, https://github.com/mcp-tool-shop-org/py-polyglot/issues
|
|
8
|
+
Author-email: mcp-tool-shop <64996768+mcp-tool-shop@users.noreply.github.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: gpu,mcp,ollama,polyglot,translategemma,translation
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Requires-Dist: httpx>=0.25.0
|
|
23
|
+
Requires-Dist: mcp[cli]>=1.26.0
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
<p align="center">
|
|
27
|
+
<a href="README.ja.md">日本語</a> | <a href="README.zh.md">中文</a> | <a href="README.es.md">Español</a> | <a href="README.fr.md">Français</a> | <a href="README.hi.md">हिन्दी</a> | <a href="README.it.md">Italiano</a> | <a href="README.pt-BR.md">Português (BR)</a>
|
|
28
|
+
</p>
|
|
29
|
+
|
|
30
|
+
<p align="center">
|
|
31
|
+
<img src="https://raw.githubusercontent.com/mcp-tool-shop-org/brand/main/logos/polyglot-mcp/readme.png" alt="py-polyglot" width="400">
|
|
32
|
+
</p>
|
|
33
|
+
|
|
34
|
+
<p align="center"><strong>Local GPU translation Python library + MCP server — TranslateGemma via Ollama, 57 languages, zero cloud dependency.</strong></p>
|
|
35
|
+
|
|
36
|
+
<p align="center">
|
|
37
|
+
<a href="https://github.com/mcp-tool-shop-org/py-polyglot/actions"><img src="https://github.com/mcp-tool-shop-org/py-polyglot/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
38
|
+
<a href="https://codecov.io/gh/mcp-tool-shop-org/py-polyglot"><img src="https://codecov.io/gh/mcp-tool-shop-org/py-polyglot/branch/main/graph/badge.svg" alt="Codecov"></a>
|
|
39
|
+
<a href="https://pypi.org/project/polyglot-gpu/"><img src="https://img.shields.io/pypi/v/polyglot-gpu" alt="PyPI"></a>
|
|
40
|
+
<a href="https://pypi.org/project/polyglot-gpu/"><img src="https://img.shields.io/pypi/pyversions/polyglot-gpu" alt="Python"></a>
|
|
41
|
+
<a href="https://github.com/mcp-tool-shop-org/py-polyglot/blob/main/LICENSE"><img src="https://img.shields.io/github/license/mcp-tool-shop-org/py-polyglot" alt="License"></a>
|
|
42
|
+
<a href="https://mcp-tool-shop-org.github.io/py-polyglot/"><img src="https://img.shields.io/badge/Landing_Page-live-blue" alt="Landing Page"></a>
|
|
43
|
+
</p>
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
Python port of [polyglot-mcp](https://github.com/mcp-tool-shop-org/polyglot-mcp). Use as a **pip-installable library** for your Python projects or as an **MCP server** for Claude Code, Claude Desktop, and other MCP clients.
|
|
48
|
+
|
|
49
|
+
## Features
|
|
50
|
+
|
|
51
|
+
- **57 languages** — TranslateGemma via Ollama, running 100% locally on your GPU
|
|
52
|
+
- **Zero cloud dependency** — no API keys, no internet required after model download
|
|
53
|
+
- **Dual-use** — Python library API + MCP server in one package
|
|
54
|
+
- **Markdown-aware** — preserves code blocks, tables, HTML, URLs, badges
|
|
55
|
+
- **Smart caching** — segment-level cache with fuzzy matching (translation memory)
|
|
56
|
+
- **Software glossary** — 12 built-in tech terms for accurate translations
|
|
57
|
+
- **Auto-everything** — auto-starts Ollama, auto-pulls models on first use
|
|
58
|
+
- **GPU-safe** — semaphore-controlled concurrency prevents VRAM overload
|
|
59
|
+
|
|
60
|
+
## Requirements
|
|
61
|
+
|
|
62
|
+
- Python >= 3.10
|
|
63
|
+
- [Ollama](https://ollama.com) installed locally
|
|
64
|
+
- GPU with sufficient VRAM for your chosen model:
|
|
65
|
+
- `translategemma:4b` — 3.3 GB (fast, good quality)
|
|
66
|
+
- `translategemma:12b` — 8.1 GB (balanced, recommended)
|
|
67
|
+
- `translategemma:27b` — 17 GB (slow, best quality)
|
|
68
|
+
|
|
69
|
+
## Install
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install polyglot-gpu
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Library Usage
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
import asyncio
|
|
79
|
+
from pypolyglot import translate, translate_markdown, translate_all
|
|
80
|
+
|
|
81
|
+
async def main():
|
|
82
|
+
# Simple translation
|
|
83
|
+
result = await translate("Hello world", "en", "ja")
|
|
84
|
+
print(result.translation) # こんにちは世界
|
|
85
|
+
|
|
86
|
+
# Markdown translation (preserves structure)
|
|
87
|
+
md = "## Features\n\nLocal GPU translation with **zero cloud dependency**."
|
|
88
|
+
result = await translate_markdown(md, "en", "fr")
|
|
89
|
+
print(result.markdown)
|
|
90
|
+
|
|
91
|
+
# Multi-language (7 languages at once)
|
|
92
|
+
result = await translate_all(md, source_lang="en")
|
|
93
|
+
for r in result.results:
|
|
94
|
+
print(f"{r.name}: {r.status}")
|
|
95
|
+
|
|
96
|
+
asyncio.run(main())
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Options
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from pypolyglot import translate, TranslateOptions, GlossaryEntry
|
|
103
|
+
|
|
104
|
+
# Custom model
|
|
105
|
+
result = await translate("Hello", "en", "ja",
|
|
106
|
+
TranslateOptions(model="translategemma:4b"))
|
|
107
|
+
|
|
108
|
+
# Custom glossary
|
|
109
|
+
result = await translate("Deploy the Widget", "en", "ja",
|
|
110
|
+
TranslateOptions(glossary=[
|
|
111
|
+
GlossaryEntry("Widget", {"ja": "ウィジェット"})
|
|
112
|
+
]))
|
|
113
|
+
|
|
114
|
+
# Streaming
|
|
115
|
+
result = await translate("Hello world", "en", "ja",
|
|
116
|
+
TranslateOptions(on_token=lambda t: print(t, end="")))
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## MCP Server Usage
|
|
120
|
+
|
|
121
|
+
### Claude Code
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"mcpServers": {
|
|
126
|
+
"polyglot-gpu": {
|
|
127
|
+
"command": "polyglot-gpu"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Or run directly:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
python -m pypolyglot
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### MCP Tools
|
|
140
|
+
|
|
141
|
+
| Tool | Description |
|
|
142
|
+
|------|-------------|
|
|
143
|
+
| `translate_text` | Translate text between any of 57 languages |
|
|
144
|
+
| `translate_md` | Translate markdown while preserving structure |
|
|
145
|
+
| `translate_all_langs` | Translate into multiple languages at once |
|
|
146
|
+
| `list_languages` | List all 57 supported languages |
|
|
147
|
+
| `check_status` | Check Ollama + model availability |
|
|
148
|
+
|
|
149
|
+
## Architecture
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
MCP Client (Claude Code, etc.)
|
|
153
|
+
│ MCP protocol (stdio)
|
|
154
|
+
▼
|
|
155
|
+
┌──────────────────┐
|
|
156
|
+
│ server.py │ 5 MCP tools (FastMCP)
|
|
157
|
+
├──────────────────┤
|
|
158
|
+
│ translate.py │ Chunking, batching, streaming
|
|
159
|
+
│ markdown.py │ Markdown segmentation
|
|
160
|
+
│ translate_all │ Multi-language orchestrator
|
|
161
|
+
│ semaphore.py │ GPU-safe concurrency
|
|
162
|
+
│ validate.py │ Output validation
|
|
163
|
+
├──────────────────┤
|
|
164
|
+
│ ollama.py │ httpx client → localhost:11434
|
|
165
|
+
│ cache.py │ Segment cache + fuzzy memory
|
|
166
|
+
│ glossary.py │ Software term dictionary
|
|
167
|
+
│ languages.py │ 57 language definitions
|
|
168
|
+
│ polish.py │ Post-translation cleanup
|
|
169
|
+
│ errors.py │ Structured error class
|
|
170
|
+
└──────────────────┘
|
|
171
|
+
│ HTTP (httpx)
|
|
172
|
+
▼
|
|
173
|
+
Ollama + TranslateGemma (GPU)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Environment Variables
|
|
177
|
+
|
|
178
|
+
| Variable | Default | Description |
|
|
179
|
+
|----------|---------|-------------|
|
|
180
|
+
| `POLYGLOT_MODEL` | `translategemma:12b` | Default Ollama model |
|
|
181
|
+
| `POLYGLOT_CONCURRENCY` | `1` | Max concurrent Ollama calls |
|
|
182
|
+
|
|
183
|
+
## Security
|
|
184
|
+
|
|
185
|
+
- All translation runs locally — zero data leaves your machine
|
|
186
|
+
- No telemetry, no API keys, no cloud dependency
|
|
187
|
+
- See [SECURITY.md](SECURITY.md) for threat model
|
|
188
|
+
|
|
189
|
+
## License
|
|
190
|
+
|
|
191
|
+
MIT
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
Built by <a href="https://mcp-tool-shop.github.io/">MCP Tool Shop</a>
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="README.ja.md">日本語</a> | <a href="README.zh.md">中文</a> | <a href="README.md">English</a> | <a href="README.fr.md">Français</a> | <a href="README.hi.md">हिन्दी</a> | <a href="README.it.md">Italiano</a> | <a href="README.pt-BR.md">Português (BR)</a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<img src="https://raw.githubusercontent.com/mcp-tool-shop-org/brand/main/logos/polyglot-mcp/readme.png" alt="py-polyglot" width="400">
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center"><strong>Biblioteca de traducción local para GPU en Python + servidor MCP — TraduceGemma a través de Ollama, 57 idiomas, sin dependencia de la nube.</strong></p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://github.com/mcp-tool-shop-org/py-polyglot/actions"><img src="https://github.com/mcp-tool-shop-org/py-polyglot/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
13
|
+
<a href="https://pypi.org/project/polyglot-gpu/"><img src="https://img.shields.io/pypi/v/polyglot-gpu" alt="PyPI"></a>
|
|
14
|
+
<a href="https://pypi.org/project/polyglot-gpu/"><img src="https://img.shields.io/pypi/pyversions/polyglot-gpu" alt="Python"></a>
|
|
15
|
+
<a href="https://github.com/mcp-tool-shop-org/py-polyglot/blob/main/LICENSE"><img src="https://img.shields.io/github/license/mcp-tool-shop-org/py-polyglot" alt="License"></a>
|
|
16
|
+
<a href="https://mcp-tool-shop-org.github.io/py-polyglot/"><img src="https://img.shields.io/badge/Landing_Page-live-blue" alt="Landing Page"></a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
Port de Python de [polyglot-mcp](https://github.com/mcp-tool-shop-org/polyglot-mcp). Úsalo como una **biblioteca instalable con pip** para tus proyectos de Python o como un **servidor MCP** para Claude Code, Claude Desktop y otros clientes MCP.
|
|
22
|
+
|
|
23
|
+
## Características
|
|
24
|
+
|
|
25
|
+
- **57 idiomas** — TraduceGemma a través de Ollama, ejecutándose completamente localmente en tu GPU.
|
|
26
|
+
- **Cero dependencia de la nube** — no requiere claves de API, ni conexión a internet después de la descarga del modelo.
|
|
27
|
+
- **Uso dual** — API de biblioteca de Python + servidor MCP en un solo paquete.
|
|
28
|
+
- **Compatible con Markdown** — conserva bloques de código, tablas, HTML, URLs, insignias.
|
|
29
|
+
- **Caché inteligente** — caché a nivel de segmento con coincidencia difusa (memoria de traducción).
|
|
30
|
+
- **Glosario de software** — 12 términos técnicos integrados para traducciones precisas.
|
|
31
|
+
- **Automatización total** — inicia automáticamente Ollama, descarga automáticamente los modelos en la primera ejecución.
|
|
32
|
+
- **Seguro para GPU** — la concurrencia controlada por semáforo evita la sobrecarga de VRAM.
|
|
33
|
+
|
|
34
|
+
## Requisitos
|
|
35
|
+
|
|
36
|
+
- Python >= 3.10
|
|
37
|
+
- [Ollama](https://ollama.com) instalado localmente
|
|
38
|
+
- GPU con suficiente VRAM para el modelo elegido:
|
|
39
|
+
- `translategemma:4b` — 3.3 GB (rápido, buena calidad)
|
|
40
|
+
- `translategemma:12b` — 8.1 GB (equilibrado, recomendado)
|
|
41
|
+
- `translategemma:27b` — 17 GB (lento, mejor calidad)
|
|
42
|
+
|
|
43
|
+
## Instalación
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install polyglot-gpu
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Uso de la biblioteca
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
import asyncio
|
|
53
|
+
from pypolyglot import translate, translate_markdown, translate_all
|
|
54
|
+
|
|
55
|
+
async def main():
|
|
56
|
+
# Simple translation
|
|
57
|
+
result = await translate("Hello world", "en", "ja")
|
|
58
|
+
print(result.translation) # こんにちは世界
|
|
59
|
+
|
|
60
|
+
# Markdown translation (preserves structure)
|
|
61
|
+
md = "## Features\n\nLocal GPU translation with **zero cloud dependency**."
|
|
62
|
+
result = await translate_markdown(md, "en", "fr")
|
|
63
|
+
print(result.markdown)
|
|
64
|
+
|
|
65
|
+
# Multi-language (7 languages at once)
|
|
66
|
+
result = await translate_all(md, source_lang="en")
|
|
67
|
+
for r in result.results:
|
|
68
|
+
print(f"{r.name}: {r.status}")
|
|
69
|
+
|
|
70
|
+
asyncio.run(main())
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Opciones
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from pypolyglot import translate, TranslateOptions, GlossaryEntry
|
|
77
|
+
|
|
78
|
+
# Custom model
|
|
79
|
+
result = await translate("Hello", "en", "ja",
|
|
80
|
+
TranslateOptions(model="translategemma:4b"))
|
|
81
|
+
|
|
82
|
+
# Custom glossary
|
|
83
|
+
result = await translate("Deploy the Widget", "en", "ja",
|
|
84
|
+
TranslateOptions(glossary=[
|
|
85
|
+
GlossaryEntry("Widget", {"ja": "ウィジェット"})
|
|
86
|
+
]))
|
|
87
|
+
|
|
88
|
+
# Streaming
|
|
89
|
+
result = await translate("Hello world", "en", "ja",
|
|
90
|
+
TranslateOptions(on_token=lambda t: print(t, end="")))
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Uso del servidor MCP
|
|
94
|
+
|
|
95
|
+
### Claude Code
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"mcpServers": {
|
|
100
|
+
"polyglot-gpu": {
|
|
101
|
+
"command": "polyglot-gpu"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
O ejecútalo directamente:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
python -m pypolyglot
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Herramientas MCP
|
|
114
|
+
|
|
115
|
+
| Herramienta | Descripción |
|
|
116
|
+
|------|-------------|
|
|
117
|
+
| `translate_text` | Traduce texto entre cualquiera de los 57 idiomas. |
|
|
118
|
+
| `translate_md` | Traduce Markdown conservando la estructura. |
|
|
119
|
+
| `translate_all_langs` | Traduce a múltiples idiomas a la vez. |
|
|
120
|
+
| `list_languages` | Lista todos los 57 idiomas soportados. |
|
|
121
|
+
| `check_status` | Verifica la disponibilidad de Ollama y el modelo. |
|
|
122
|
+
|
|
123
|
+
## Arquitectura
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
MCP Client (Claude Code, etc.)
|
|
127
|
+
│ MCP protocol (stdio)
|
|
128
|
+
▼
|
|
129
|
+
┌──────────────────┐
|
|
130
|
+
│ server.py │ 5 MCP tools (FastMCP)
|
|
131
|
+
├──────────────────┤
|
|
132
|
+
│ translate.py │ Chunking, batching, streaming
|
|
133
|
+
│ markdown.py │ Markdown segmentation
|
|
134
|
+
│ translate_all │ Multi-language orchestrator
|
|
135
|
+
│ semaphore.py │ GPU-safe concurrency
|
|
136
|
+
│ validate.py │ Output validation
|
|
137
|
+
├──────────────────┤
|
|
138
|
+
│ ollama.py │ httpx client → localhost:11434
|
|
139
|
+
│ cache.py │ Segment cache + fuzzy memory
|
|
140
|
+
│ glossary.py │ Software term dictionary
|
|
141
|
+
│ languages.py │ 57 language definitions
|
|
142
|
+
│ polish.py │ Post-translation cleanup
|
|
143
|
+
│ errors.py │ Structured error class
|
|
144
|
+
└──────────────────┘
|
|
145
|
+
│ HTTP (httpx)
|
|
146
|
+
▼
|
|
147
|
+
Ollama + TranslateGemma (GPU)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Variables de entorno
|
|
151
|
+
|
|
152
|
+
| Variable | Valor predeterminado | Descripción |
|
|
153
|
+
|----------|---------|-------------|
|
|
154
|
+
| `POLYGLOT_MODEL` | `translategemma:12b` | Modelo Ollama predeterminado |
|
|
155
|
+
| `POLYGLOT_CONCURRENCY` | `1` | Número máximo de llamadas concurrentes a Ollama |
|
|
156
|
+
|
|
157
|
+
## Seguridad
|
|
158
|
+
|
|
159
|
+
- Todas las traducciones se realizan localmente — ningún dato sale de tu máquina.
|
|
160
|
+
- Sin telemetría, sin claves de API, sin dependencia de la nube.
|
|
161
|
+
- Consulta [SECURITY.md](SECURITY.md) para el modelo de amenazas.
|
|
162
|
+
|
|
163
|
+
## Licencia
|
|
164
|
+
|
|
165
|
+
MIT
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
Creado por <a href="https://mcp-tool-shop.github.io/">MCP Tool Shop</a>
|