Merge pull request #1164 from xxf1996/patch-1

Update `zhipuai_api.py` for custom `max_tokens` and `temperature` con…
This commit is contained in:
Alexander Wu 2024-04-08 20:33:56 +08:00 committed by GitHub
commit 7a297b85df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -43,7 +43,9 @@ class ZhiPuAILLM(BaseLLM):
self.llm = ZhiPuModelAPI(api_key=self.api_key)
def _const_kwargs(self, messages: list[dict], stream: bool = False) -> dict:
kwargs = {"model": self.model, "messages": messages, "stream": stream, "temperature": 0.3}
max_tokens = self.config.max_token if self.config.max_token > 0 else 1024
temperature = self.config.temperature if self.config.temperature > 0.0 else 0.3
kwargs = {"model": self.model, "max_tokens": max_tokens, "messages": messages, "stream": stream, "temperature": temperature}
return kwargs
def completion(self, messages: list[dict], timeout=USE_CONFIG_TIMEOUT) -> dict: