Update zhipuai_api.py for custom max_tokens and temperature config.

This commit is contained in:
XueFeng 2024-04-08 16:54:00 +08:00 committed by GitHub
parent a9590854b5
commit 1ff50e85c2
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: