Skip to content

Commit 7260873

Browse files
committed
Merge branch 'develop' into tests
2 parents 253b0ea + 2910421 commit 7260873

39 files changed

+1106
-192
lines changed

.gitattributes

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,3 @@
1010
*.md text
1111
*.json text
1212
*.yml text
13-
14-
# Proprietary software authored by Vadim Rõbalko (Habr)
15-
# Contact: vadim@habr.team
16-
# License: proprietary (not open source)

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.5.0] – 2025-07-25
8+
9+
### Added
10+
- **New model support**:
11+
- **Anthropic Claude** (Haiku 3.5, Sonnet 4, Opus 4) via `AnthropicDriver`
12+
- **Google Gemini** (2.0 Flash, 2.5 Flash, 2.5 Flash-Lite, 2.5 Pro) via `GoogleDriver`
13+
- **OpenAI GPT Chat** (GPT-4, GPT-4 Turbo, GPT-4o, GPT-4o Mini) via `OpenAiDriver`
14+
- **HTTP proxy** support (`--proxy` flag / `BBLSLUG_PROXY`) in `HttpClient` and CLI
15+
- **YAML-based registry** (`resources/models.yaml`) replacing the PHP model config
16+
17+
### Changed
18+
- **Registry keys & auth flags**:
19+
- Renamed `gemini:*``google:gemini-*`
20+
- Added `ANTHROPIC_API_KEY` and updated `--api-key-google` / `GOOGLE_API_KEY`
21+
- Updated `README.md` & `Help.php` to list supported models
22+
- Minor cleanups: JSON payload alignment, code/style tweaks, help text refinements
23+
24+
### Removed
25+
- Legacy PHP registry (`resources/models.php`)
26+
727
## [0.4.0] - 2025-07-21
828
### Added
929
- **Model driver abstraction**

LICENSE

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1+
MIT License
2+
13
Copyright (c) 2025 Vadim Rõbalko (Habr)
2-
All rights reserved.
34

4-
This software is proprietary and confidential. Unauthorized copying,
5-
modification, distribution, or use is strictly prohibited without
6-
explicit permission from the author.
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
13+
all copies or substantial portions of the Software.
714

8-
Contact: vadim@habr.team
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
21+
THE SOFTWARE.

README.md

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,33 @@
22

33
**Bblslug** is a versatile translation tool that can be used as both a **CLI utility** and a **PHP library**.
44

5-
It leverages LLM-based APIs (DeepL, OpenAI, Gemini) to translate plain text or HTML while preserving structure, code blocks, and URLs via placeholder filters.
5+
It leverages LLM-based APIs to translate plain text or HTML while preserving structure, code blocks, and URLs via placeholder filters.
6+
7+
APIs supported:
8+
9+
- Anthropic (Claude):
10+
- `anthropic:claude-haiku-3.5` - Claude Haiku 3.5 (latest)
11+
- `anthropic:claude-opus-4` - Claude Opus 4 (20250514)
12+
- `anthropic:claude-sonnet-4` - Claude Sonnet 4 (20250514)
13+
- DeepL
14+
- `deepl:free` - DeepL free tier
15+
- `deepl:pro` - DeepL pro tier
16+
- Google (Gemini)
17+
- `google:gemini-2.0-flash` - Gemini 2.0 Flash
18+
- `google:gemini-2.5-flash` - Gemini 2.5 Flash
19+
- `google:gemini-2.5-flash-lite` - Gemini 2.5 Flash Lite
20+
- `google:gemini-2.5-pro` - Gemini 2.5 Pro
21+
- OpenAI (GPT)
22+
- `openai:gpt-4` - OpenAI GPT-4
23+
- `openai:gpt-4-turbo` - OpenAI GPT-4 Turbo
24+
- `openai:gpt-4o` - OpenAI GPT-4o
25+
- `openai:gpt-4o-mini` - OpenAI GPT-4o Mini
626

727
## Features
828

929
- Supports **html** and **plain text** (`--format=text|html`)
1030
- Placeholder-based protection with filters: `html_pre`, `html_code`, `url`, etc.
11-
- Model selection via `--model=vendor:name` (`deepl:free`, `deepl:pro`, `openai:gpt-4o`, `gemini:1.5-pro`, …)
31+
- Model selection via `--model=vendor:name` (`deepl:pro`, `google:gemini-2.5-flash`, `openai:gpt-4o`, …)
1232
- Fully configurable backend registry
1333
- **Dry-run** mode to preview placeholders without making API calls
1434
- **Verbose** mode (`--verbose`) to print request previews
@@ -28,17 +48,33 @@ chmod +x vendor/bin/bblslug
2848
2. **Export your API key(s)** before running:
2949

3050
```bash
51+
export ANTHROPIC_API_KEY=...
3152
export DEEPL_FREE_API_KEY=...
3253
export DEEPL_PRO_API_KEY=...
54+
export GOOGLE_API_KEY=...
3355
export OPENAI_API_KEY=...
34-
export GEMINI_API_KEY=...
3556
```
3657

3758
3. **Input / output**:
3859

3960
- If `--source` is omitted, Bblslug reads from **STDIN**.
4061
- If `--translated` is omitted, Bblslug writes to **STDOUT**.
4162

63+
4. **Optional proxy**:
64+
65+
To route requests through a proxy (e.g. HTTP or SOCKS5), use the `--proxy` option or set the `BBLSLUG_PROXY` environment variable:
66+
67+
```bash
68+
# using CLI flag
69+
vendor/bin/bblslug --proxy="http://localhost:8888" ...
70+
71+
# or set it globally
72+
export BBLSLUG_PROXY="socks5h://127.0.0.1:9050"
73+
```
74+
75+
This works for all HTTP requests and supports authentication (`http://user:pass@host:port`).
76+
77+
4278
### Show available models
4379
```bash
4480
vendor/bin/bblslug --list-models
@@ -141,18 +177,19 @@ $text = file_get_contents('input.html');
141177

142178
// Call library translate method
143179
$result = Bblslug::translate(
144-
modelKey: 'deepl:pro', // Model identifier (e.g. deepl:free, deepl:pro, openai:gpt-4o)
145180
apiKey: getenv('DEEPL_PRO_API_KEY'), // API key for the chosen model
146181
format: 'html', // 'text' or 'html'
182+
modelKey: 'deepl:pro', // Model identifier (e.g. deepl:free, deepl:pro, openai:gpt-4o)
147183
text: $text, // Source text or HTML
148184

149185
// optional parameters:
150186
context: null, // Additional context/prompt (DeepL: context)
151187
dryRun: false, // If true, only prepare placeholders, no API call
152188
filters: ['url', 'html_code'], // List of placeholder filters
189+
proxy: getenv('BBLSLUG_PROXY'), // Optional proxy URI (http://..., socks5h://...)
153190
sourceLang: null, // Source language code (optional; autodetect if null)
154-
targetLang: null, // Target language code (optional; default from registry)
155-
verbose: true // If true, prints debug request/response to stderr
191+
targetLang: null, // Target language code (optional; default from driver settings)
192+
verbose: true, // If true, prints debug request/response to stderr
156193
);
157194

158195
// Result output example
@@ -178,4 +215,4 @@ You can find sample input files under the `examples/` directory.
178215

179216
## License
180217

181-
Private project, not yet open-source.
218+
This project is licensed under the MIT License – see the [LICENSE](LICENSE) file for details.

composer.json

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
{
2-
"name": "tools/bblslug",
2+
"name": "habr/bblslug",
33
"description": "CLI translation tool for HTML and plain text using LLM-based APIs.",
4-
"license": "proprietary",
4+
"keywords": ["translation","LLM","deepl","openai"],
5+
"homepage": "https://github.com/habralab/bblslug",
6+
"license": "MIT",
57
"type": "library",
8+
"authors": [
9+
{
10+
"name": "Vadim Rybalko",
11+
"email": "vadim@habr.team",
12+
"role": "Lead"
13+
}
14+
],
615
"require": {
716
"php": ">=8.0",
817
"ext-curl": "*",
9-
"ext-mbstring": "*"
18+
"ext-mbstring": "*",
19+
"symfony/yaml": "^7.3"
1020
},
1121
"require-dev": {
1222
"squizlabs/php_codesniffer": "^3.13",
@@ -28,11 +38,5 @@
2838
"scripts": {
2939
"lint": "vendor/bin/phpcs --standard=phpcs.xml",
3040
"phpunit": "vendor/bin/phpunit --testdox --colors=always --log-junit .phpunit.junit.xml"
31-
},
32-
"authors": [
33-
{
34-
"name": "Vadim Rybalko",
35-
"role": "Lead"
36-
}
37-
]
41+
}
3842
}

resources/models.php

Lines changed: 0 additions & 123 deletions
This file was deleted.

0 commit comments

Comments
 (0)