Skip to content

Commit

Permalink
fix(model): Fix zhipu client no api_key error
Browse files Browse the repository at this point in the history
  • Loading branch information
fangyinc committed Jun 4, 2024
1 parent f761f9c commit 14b8012
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions dbgpt/model/proxy/llms/zhipu.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from concurrent.futures import Executor
from typing import Iterator, Optional

Expand Down Expand Up @@ -37,6 +38,7 @@ def __init__(
self,
model: Optional[str] = None,
api_key: Optional[str] = None,
api_base: Optional[str] = None,
model_alias: Optional[str] = "zhipu_proxyllm",
context_length: Optional[int] = 8192,
executor: Optional[Executor] = None,
Expand All @@ -61,9 +63,12 @@ def __init__(
) from exc
if not model:
model = CHATGLM_DEFAULT_MODEL
self.api_key = api_key
if not api_key:
# Compatible with DB-GPT's config
api_key = os.getenv("ZHIPU_PROXY_API_KEY")

self._model = model
self.client = ZhipuAI(api_key=api_key) if api_key else None
self.client = ZhipuAI(api_key=api_key, base_url=api_base)

super().__init__(
model_names=[model, model_alias],
Expand Down

0 comments on commit 14b8012

Please sign in to comment.