PowerShell-клиент predict.ps1 + charset=utf-8 в ответах сервиса (фикс кириллицы в PS 5.1)

This commit is contained in:
DUB-AI committed 2026-10-27 16:47:45 +07:00
1 parent 8dbca3f4a3
commit 98e4031037
4 files changed
+91 -1

No files matched your search

+21
View File
@@ -84,6 +84,27 @@ const { tracks } = await res.json();
Типизированная версия — `examples/typescript/predict.ts` (запуск: `npx tsx predict.ts --text "..."`).
### PowerShell (examples/powershell/predict.ps1)
Скрипт (работает и в Windows PowerShell 5.1, и в PowerShell 7):
```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File examples\powershell\predict.ps1 -Text "Перевод: Дублированный | MovieDalen"
pwsh -File examples\powershell\predict.ps1 -HtmlFile page.html -Url http://host:8000
```
Однострочник (POST с кириллицей; UTF-8 байтами — важно для PS 5.1, где
строковый `-Body` уходит в ISO-8859-1):
```powershell
$b = [Text.Encoding]::UTF8.GetBytes((@{ text = "Перевод: Дублированный | MovieDalen" } | ConvertTo-Json))
(Invoke-RestMethod -Uri http://127.0.0.1:8000/predict -Method Post -ContentType "application/json" -Body $b).tracks
```
Проверка живости: `Invoke-RestMethod http://127.0.0.1:8000/health`.
Ответ сервис отдаёт с `charset=utf-8`, поэтому кириллица в ответе
корректно декодируется и в PS 5.1.
## Путь Б: ONNX без Python
Экспорт (из корня проекта, после обучения):