mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-08 20:41:52 +00:00
(Community): Changing the BaseURL and Model for MiniMax (#29299)
- **Description:** Changed the Base Default Model and Base URL to correct versions. Plus added a more explicit exception if user provides an invalid API Key - **Issue:** #29278
This commit is contained in:
parent
c20f7418c7
commit
b5fbebb3c8
@ -370,7 +370,7 @@ class MiniMaxChat(BaseChatModel):
|
|||||||
}
|
}
|
||||||
|
|
||||||
_client: Any = None
|
_client: Any = None
|
||||||
model: str = "abab6.5-chat"
|
model: str = "abab6.5s-chat"
|
||||||
"""Model name to use."""
|
"""Model name to use."""
|
||||||
max_tokens: int = 256
|
max_tokens: int = 256
|
||||||
"""Denotes the number of tokens to predict per generation."""
|
"""Denotes the number of tokens to predict per generation."""
|
||||||
@ -381,7 +381,7 @@ class MiniMaxChat(BaseChatModel):
|
|||||||
model_kwargs: Dict[str, Any] = Field(default_factory=dict)
|
model_kwargs: Dict[str, Any] = Field(default_factory=dict)
|
||||||
"""Holds any model parameters valid for `create` call not explicitly specified."""
|
"""Holds any model parameters valid for `create` call not explicitly specified."""
|
||||||
minimax_api_host: str = Field(
|
minimax_api_host: str = Field(
|
||||||
default="https://api.minimax.chat/v1/text/chatcompletion_v2", alias="base_url"
|
default="https://api.minimaxi.chat/v1/text/chatcompletion_v2", alias="base_url"
|
||||||
)
|
)
|
||||||
minimax_group_id: Optional[str] = Field(default=None, alias="group_id")
|
minimax_group_id: Optional[str] = Field(default=None, alias="group_id")
|
||||||
"""[DEPRECATED, keeping it for for backward compatibility] Group Id"""
|
"""[DEPRECATED, keeping it for for backward compatibility] Group Id"""
|
||||||
@ -511,7 +511,13 @@ class MiniMaxChat(BaseChatModel):
|
|||||||
with httpx.Client(headers=headers, timeout=60) as client:
|
with httpx.Client(headers=headers, timeout=60) as client:
|
||||||
response = client.post(self.minimax_api_host, json=payload)
|
response = client.post(self.minimax_api_host, json=payload)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
final_response = response.json()
|
||||||
|
if (
|
||||||
|
"base_resp" in final_response
|
||||||
|
and "status_msg" in final_response["base_resp"]
|
||||||
|
and final_response["base_resp"]["status_msg"] == "invalid api key"
|
||||||
|
):
|
||||||
|
raise Exception("Invalid API Key Provided")
|
||||||
return self._create_chat_result(response.json())
|
return self._create_chat_result(response.json())
|
||||||
|
|
||||||
def _stream(
|
def _stream(
|
||||||
|
Loading…
Reference in New Issue
Block a user