8f6f8969fd
- api/: FastAPI app, X-API-Key 인증(미설정 시 임시키), 엔진 load-once 풀 (+transcribe lock), POST /v1/transcribe(multipart, 동기), /health, /v1/system, /v1/models. 업로드 임시파일 finally 삭제(프라이버시). - postprocess/: llm.correct(scripts/llm_correct.py 승격; opt-in·allowlist·감사로그·재시도) + rules.normalize(EmbeddingGemma 등 정규화). - results/formats.py: txt/srt/vtt. connectivity/tunnel.py: cloudflared quick tunnel(Colab). - cli serve: uvicorn 단일워커 + --tunnel cloudflare; config llm_* 필드; pyproject api/queue extra 분리(+python-multipart, dev httpx). 검증: 22 단위테스트(API TestClient·formats·postprocess) + 실서버 e2e (/health·auth 401·실제 전사(JFK)·SRT·임시파일 삭제). KO 품질은 turbo/large-v3 필요(tiny는 한국어 degenerate). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
"""postprocess.rules / postprocess.llm (urllib monkeypatch)."""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
|
|
import pytest
|
|
|
|
from luke_scribe.postprocess import llm, rules
|
|
|
|
|
|
def test_rules_normalize():
|
|
assert rules.normalize("구글 Embedding Gemma 소개") == "구글 EmbeddingGemma 소개"
|
|
assert rules.normalize("그대로") == "그대로"
|
|
|
|
|
|
def test_llm_not_configured():
|
|
with pytest.raises(llm.LLMNotConfigured):
|
|
llm.correct("x", base_url=None, api_key=None)
|
|
|
|
|
|
class _FakeResp:
|
|
def __init__(self, payload: dict) -> None:
|
|
self._p = payload
|
|
|
|
def read(self) -> bytes:
|
|
return json.dumps(self._p).encode()
|
|
|
|
def __enter__(self):
|
|
return self
|
|
|
|
def __exit__(self, *_a):
|
|
return False
|
|
|
|
|
|
def test_llm_correct_monkeypatched(monkeypatch):
|
|
def fake_urlopen(_req, timeout=90): # noqa: ARG001
|
|
return _FakeResp({"choices": [{"message": {"content": "EmbeddingGemma 복원됨"}}]})
|
|
|
|
monkeypatch.setattr(llm.urllib.request, "urlopen", fake_urlopen)
|
|
out = llm.correct("인베딩 점마", base_url="http://x/v1", api_key="k", model="m")
|
|
assert out == "EmbeddingGemma 복원됨"
|