mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-05 14:55:18 +02:00
Merge pull request #498 from better629/feat_chatglm
fix zhipuapi's key to init openai api_key when using openai sdk
This commit is contained in:
commit
b17846401e
2 changed files with 3 additions and 1 deletions
|
|
@ -24,7 +24,7 @@ def LLM() -> "BaseGPTAPI":
|
|||
llm = Claude()
|
||||
elif CONFIG.spark_api_key:
|
||||
llm = SparkAPI()
|
||||
elif CONFIG.zhipuai_api_key and CONFIG.zhipuai_api_key != "YOUR_API_KEY":
|
||||
elif CONFIG.zhipuai_api_key:
|
||||
llm = ZhiPuAIGPTAPI()
|
||||
else:
|
||||
raise RuntimeError("You should config a LLM configuration first")
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ from tenacity import (
|
|||
)
|
||||
from requests import ConnectionError
|
||||
|
||||
import openai
|
||||
import zhipuai
|
||||
|
||||
from metagpt.config import CONFIG
|
||||
|
|
@ -46,6 +47,7 @@ class ZhiPuAIGPTAPI(BaseGPTAPI):
|
|||
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.
|
||||
|
||||
def _const_kwargs(self, messages: list[dict]) -> dict:
|
||||
kwargs = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue