auto-save 2026-05-14 11:58 (~4)
This commit is contained in:
17
api/main.py
17
api/main.py
@@ -1477,13 +1477,16 @@ def _translate_sync(segments: list[dict]) -> list[str]:
|
||||
'[{"i": 0, "zh": "..."}, ...]\n\n输入:\n'
|
||||
+ json.dumps(payload, ensure_ascii=False)
|
||||
)
|
||||
resp = llm().chat.completions.create(
|
||||
model=TRANSLATE_MODEL,
|
||||
messages=[{"role": "user", "content": prompt}],
|
||||
response_format={"type": "json_object"},
|
||||
temperature=0.2,
|
||||
)
|
||||
content = resp.choices[0].message.content or "[]"
|
||||
try:
|
||||
resp = llm().chat.completions.create(
|
||||
model=TRANSLATE_MODEL,
|
||||
messages=[{"role": "user", "content": prompt}],
|
||||
response_format={"type": "json_object"},
|
||||
temperature=0.2,
|
||||
)
|
||||
content = resp.choices[0].message.content or "[]"
|
||||
except Exception:
|
||||
return ["" for _ in segments]
|
||||
try:
|
||||
data = json.loads(content)
|
||||
if isinstance(data, dict):
|
||||
|
||||
Reference in New Issue
Block a user