fix: 修复频繁打断下生成器不会清理

This commit is contained in:
Sakura-RanChen
2026-04-22 11:24:43 +08:00
parent 8a156e99f4
commit 2a4dbdb69b
4 changed files with 131 additions and 117 deletions
@@ -39,13 +39,12 @@ class LLMProvider(LLMProviderBase):
}
# 发起 POST 请求
response = requests.post(self.api_url, json=payload, headers=headers)
with requests.post(self.api_url, json=payload, headers=headers) as response:
# 检查请求是否成功
response.raise_for_status()
# 检查请求是否成功
response.raise_for_status()
# 解析返回数据
data = response.json()
# 解析返回数据
data = response.json()
speech = (
data.get("response", {})
.get("speech", {})