fixbug: #1565 zhipuai model exception

This commit is contained in:
莘权 马 2024-11-04 17:11:34 +08:00
parent 99c1f95303
commit f1565e2cca
4 changed files with 5 additions and 3 deletions

View file

@ -17,7 +17,7 @@ class AsyncSSEClient(object):
f"Request failed, msg: {self._event_source.decode('utf-8')}, please ref to `https://open.bigmodel.cn/dev/api#error-code-v3`"
)
async for chunk in self._event_source:
line = chunk.decode("utf-8")
line = chunk.data.decode("utf-8")
if line.startswith(":") or not line:
return

View file

@ -40,7 +40,7 @@ class ZhiPuModelAPI(ZhipuAI):
"""async invoke different from raw method `async_invoke` which get the final result by task_id"""
headers = self._default_headers
resp = await self.arequest(stream=False, method="post", headers=headers, kwargs=kwargs)
resp = resp.decode("utf-8")
resp = resp.data.decode("utf-8")
resp = json.loads(resp)
if "error" in resp:
raise RuntimeError(

View file

@ -52,6 +52,8 @@ TOKEN_COSTS = {
"text-embedding-ada-002": {"prompt": 0.0004, "completion": 0.0},
"glm-3-turbo": {"prompt": 0.0007, "completion": 0.0007}, # 128k version, prompt + completion tokens=0.005¥/k-tokens
"glm-4": {"prompt": 0.014, "completion": 0.014}, # 128k version, prompt + completion tokens=0.1¥/k-tokens
"glm-4-flash": {"prompt": 0, "completion": 0},
"glm-4-plus": {"prompt": 0.007, "completion": 0.007},
"gemini-1.5-flash": {"prompt": 0.000075, "completion": 0.0003},
"gemini-1.5-pro": {"prompt": 0.0035, "completion": 0.0105},
"gemini-1.0-pro": {"prompt": 0.0005, "completion": 0.0015},

View file

@ -52,7 +52,7 @@ httplib2~=0.22.0
websocket-client~=1.8.0
aiofiles==23.2.1
gitpython==3.1.40
zhipuai==2.0.1
zhipuai~=2.1.5
rich==13.6.0
nbclient==0.9.0
nbformat==5.9.2