Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions metagpt/provider/zhipuai_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def __init_zhipuai(self, config: CONFIG):
assert config.zhipuai_api_key
zhipuai.api_key = config.zhipuai_api_key
openai.api_key = zhipuai.api_key # due to use openai sdk, set the api_key but it will't be used.
if config.openai_proxy:
openai.proxy = config.openai_proxy

def _const_kwargs(self, messages: list[dict]) -> dict:
kwargs = {"model": self.model, "prompt": messages, "temperature": 0.3}
Expand Down
7 changes: 7 additions & 0 deletions tests/metagpt/provider/test_zhipuai_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,10 @@ async def test_zhipuai_acompletion(mocker):

assert resp["code"] == 200
assert "chatglm-turbo" in resp["data"]["choices"][0]["content"]

def test_zhipuai_proxy(mocker):
import openai
from metagpt.config import CONFIG
CONFIG.openai_proxy = 'http://127.0.0.1:8080'
_ = ZhiPuAIGPTAPI()
assert openai.proxy == CONFIG.openai_proxy