6e92841352
Harden DeepSeek JSON parsing with retry, pre-sanitize Lyria prompts, and instrumental fallback. Add pure HTML Winamp skin at /winamp with playlist export support. Co-authored-by: Cursor <cursoragent@cursor.com>
26 lines
652 B
Python
26 lines
652 B
Python
import json
|
|
|
|
import pytest
|
|
|
|
from ozan_radio.dj import parse_llm_json
|
|
|
|
|
|
def test_parse_llm_json_plain():
|
|
data = parse_llm_json('{"title": "Test", "lyria_prompt": "one line"}')
|
|
assert data["title"] == "Test"
|
|
|
|
|
|
def test_parse_llm_json_fenced():
|
|
raw = '```json\n{"title": "Fenced"}\n```'
|
|
assert parse_llm_json(raw)["title"] == "Fenced"
|
|
|
|
|
|
def test_parse_llm_json_wrapped_text():
|
|
raw = 'Here is the plan:\n{"title": "Wrapped", "mood": "calm"}\nThanks.'
|
|
assert parse_llm_json(raw)["title"] == "Wrapped"
|
|
|
|
|
|
def test_parse_llm_json_invalid_raises():
|
|
with pytest.raises(json.JSONDecodeError):
|
|
parse_llm_json("not json at all")
|