|
|
|
@ -57,12 +57,25 @@ class ErnieBotChat(BaseChatModel):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
ernie_client_id: Optional[str] = None
|
|
|
|
|
"""Baidu application client id"""
|
|
|
|
|
|
|
|
|
|
ernie_client_secret: Optional[str] = None
|
|
|
|
|
"""Baidu application client secret"""
|
|
|
|
|
|
|
|
|
|
access_token: Optional[str] = None
|
|
|
|
|
"""access token is generated by client id and client secret,
|
|
|
|
|
setting this value directly will cause an error"""
|
|
|
|
|
|
|
|
|
|
model_name: str = "ERNIE-Bot-turbo"
|
|
|
|
|
"""model name of ernie, default is `ERNIE-Bot-turbo`.
|
|
|
|
|
Currently supported `ERNIE-Bot-turbo`, `ERNIE-Bot`"""
|
|
|
|
|
|
|
|
|
|
request_timeout: Optional[int] = 60
|
|
|
|
|
"""request timeout for chat http requests"""
|
|
|
|
|
|
|
|
|
|
streaming: Optional[bool] = False
|
|
|
|
|
"""streaming mode. not supported yet."""
|
|
|
|
|
|
|
|
|
|
top_p: Optional[float] = 0.8
|
|
|
|
|
temperature: Optional[float] = 0.95
|
|
|
|
|
penalty_score: Optional[float] = 1
|
|
|
|
@ -93,6 +106,7 @@ class ErnieBotChat(BaseChatModel):
|
|
|
|
|
raise ValueError(f"Got unknown model_name {self.model_name}")
|
|
|
|
|
resp = requests.post(
|
|
|
|
|
url,
|
|
|
|
|
timeout=self.request_timeout,
|
|
|
|
|
headers={
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
},
|
|
|
|
@ -107,6 +121,7 @@ class ErnieBotChat(BaseChatModel):
|
|
|
|
|
base_url: str = "https://aip.baidubce.com/oauth/2.0/token"
|
|
|
|
|
resp = requests.post(
|
|
|
|
|
base_url,
|
|
|
|
|
timeout=10,
|
|
|
|
|
headers={
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
"Accept": "application/json",
|
|
|
|
|