diff --git a/metagpt/provider/zhipuai/async_sse_client.py b/metagpt/provider/zhipuai/async_sse_client.py index 054865652..116d82f71 100644 --- a/metagpt/provider/zhipuai/async_sse_client.py +++ b/metagpt/provider/zhipuai/async_sse_client.py @@ -17,7 +17,7 @@ async def stream(self) -> dict: 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 diff --git a/metagpt/provider/zhipuai/zhipu_model_api.py b/metagpt/provider/zhipuai/zhipu_model_api.py index a7d49623a..bff5889eb 100644 --- a/metagpt/provider/zhipuai/zhipu_model_api.py +++ b/metagpt/provider/zhipuai/zhipu_model_api.py @@ -40,7 +40,7 @@ async def acreate(self, **kwargs) -> dict: """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( diff --git a/metagpt/utils/token_counter.py b/metagpt/utils/token_counter.py index 3bff53e34..1bc6b597d 100644 --- a/metagpt/utils/token_counter.py +++ b/metagpt/utils/token_counter.py @@ -52,6 +52,8 @@ "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}, diff --git a/requirements.txt b/requirements.txt index 36cf4350e..288d50636 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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