Skip to content

Commit f0a9042

Browse files
authored
Merge pull request #1570 from iorisa/fixbug/issue/1565
fixbug: #1565 [Two problems ] AttributeError: 'OpenAIResponse' object has no attribute 'decode'
2 parents 99c1f95 + f1565e2 commit f0a9042

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

metagpt/provider/zhipuai/async_sse_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async def stream(self) -> dict:
1717
f"Request failed, msg: {self._event_source.decode('utf-8')}, please ref to `https://open.bigmodel.cn/dev/api#error-code-v3`"
1818
)
1919
async for chunk in self._event_source:
20-
line = chunk.decode("utf-8")
20+
line = chunk.data.decode("utf-8")
2121
if line.startswith(":") or not line:
2222
return
2323

metagpt/provider/zhipuai/zhipu_model_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ async def acreate(self, **kwargs) -> dict:
4040
"""async invoke different from raw method `async_invoke` which get the final result by task_id"""
4141
headers = self._default_headers
4242
resp = await self.arequest(stream=False, method="post", headers=headers, kwargs=kwargs)
43-
resp = resp.decode("utf-8")
43+
resp = resp.data.decode("utf-8")
4444
resp = json.loads(resp)
4545
if "error" in resp:
4646
raise RuntimeError(

metagpt/utils/token_counter.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
"text-embedding-ada-002": {"prompt": 0.0004, "completion": 0.0},
5353
"glm-3-turbo": {"prompt": 0.0007, "completion": 0.0007}, # 128k version, prompt + completion tokens=0.005¥/k-tokens
5454
"glm-4": {"prompt": 0.014, "completion": 0.014}, # 128k version, prompt + completion tokens=0.1¥/k-tokens
55+
"glm-4-flash": {"prompt": 0, "completion": 0},
56+
"glm-4-plus": {"prompt": 0.007, "completion": 0.007},
5557
"gemini-1.5-flash": {"prompt": 0.000075, "completion": 0.0003},
5658
"gemini-1.5-pro": {"prompt": 0.0035, "completion": 0.0105},
5759
"gemini-1.0-pro": {"prompt": 0.0005, "completion": 0.0015},

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ httplib2~=0.22.0
5252
websocket-client~=1.8.0
5353
aiofiles==23.2.1
5454
gitpython==3.1.40
55-
zhipuai==2.0.1
55+
zhipuai~=2.1.5
5656
rich==13.6.0
5757
nbclient==0.9.0
5858
nbformat==5.9.2

0 commit comments

Comments
 (0)