initial commit

This commit is contained in:
2026-05-30 23:29:44 -07:00
commit 431ffdff06
48 changed files with 4221 additions and 0 deletions
+64
View File
@@ -0,0 +1,64 @@
from evanescere.schemas import ClipCandidate
from evanescere.services.llm import dedupe_and_rank_candidates, parse_clip_response
def test_parse_clip_response():
candidates = parse_clip_response(
"""
{
"clips": [
{
"start_sec": 10,
"end_sec": 60,
"title_zh": "标题",
"summary_zh": "摘要",
"reason": "有趣",
"score": 0.9,
"tags": ["反应"],
"subtitle_priority": "high"
}
]
}
"""
)
assert candidates[0].title_zh == "标题"
def test_dedupe_and_rank_candidates_filters_short_and_overlapping():
candidates = [
ClipCandidate(
start_sec=0,
end_sec=20,
title_zh="too short",
summary_zh="",
reason="",
score=1,
),
ClipCandidate(
start_sec=0,
end_sec=60,
title_zh="best",
summary_zh="",
reason="",
score=0.9,
),
ClipCandidate(
start_sec=10,
end_sec=65,
title_zh="overlap",
summary_zh="",
reason="",
score=0.8,
),
ClipCandidate(
start_sec=120,
end_sec=180,
title_zh="second",
summary_zh="",
reason="",
score=0.7,
),
]
ranked = dedupe_and_rank_candidates(candidates)
assert [candidate.title_zh for candidate in ranked] == ["best", "second"]