Skip to content

Commit

Permalink
Merge pull request #1570 from iorisa/fixbug/issue/1565
Browse files Browse the repository at this point in the history
fixbug: #1565 [Two problems ] AttributeError: 'OpenAIResponse' object has no attribute 'decode'
  • Loading branch information
better629 authored Nov 4, 2024
2 parents 99c1f95 + f1565e2 commit f0a9042
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion metagpt/provider/zhipuai/async_sse_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion metagpt/provider/zhipuai/zhipu_model_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions metagpt/utils/token_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f0a9042

Please sign in to comment.