mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 16:44:13 +08:00
note
This commit is contained in:
parent
262021406e
commit
e789be80cc
@ -82,6 +82,7 @@ class gptcommon(basetrans):
|
|||||||
message = ""
|
message = ""
|
||||||
if not response.headers["Content-Type"].startswith("text/event-stream"):
|
if not response.headers["Content-Type"].startswith("text/event-stream"):
|
||||||
# application/json
|
# application/json
|
||||||
|
# text/html
|
||||||
raise Exception(response.text)
|
raise Exception(response.text)
|
||||||
for chunk in response.iter_lines():
|
for chunk in response.iter_lines():
|
||||||
response_data = chunk.decode("utf-8").strip()
|
response_data = chunk.decode("utf-8").strip()
|
||||||
|
@ -189,7 +189,8 @@ class TS(basetrans):
|
|||||||
)
|
)
|
||||||
except requests.RequestException:
|
except requests.RequestException:
|
||||||
raise ValueError(f"连接到Sakura API超时:{self.api_url}")
|
raise ValueError(f"连接到Sakura API超时:{self.api_url}")
|
||||||
|
if not output.headers["Content-Type"].startswith("text/event-stream"):
|
||||||
|
raise Exception(output.text)
|
||||||
for o in output.iter_lines():
|
for o in output.iter_lines():
|
||||||
try:
|
try:
|
||||||
res = o.decode("utf-8").strip()[6:] # .replace("data: ", "")
|
res = o.decode("utf-8").strip()[6:] # .replace("data: ", "")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user