Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Community): Changing the BaseURL and Model for MiniMax #29299

Merged
merged 1 commit into from
Jan 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions libs/community/langchain_community/chat_models/minimax.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def _default_params(self) -> Dict[str, Any]:
}

_client: Any = None
model: str = "abab6.5-chat"
model: str = "abab6.5s-chat"
"""Model name to use."""
max_tokens: int = 256
"""Denotes the number of tokens to predict per generation."""
Expand All @@ -381,7 +381,7 @@ def _default_params(self) -> Dict[str, Any]:
model_kwargs: Dict[str, Any] = Field(default_factory=dict)
"""Holds any model parameters valid for `create` call not explicitly specified."""
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")
"""[DEPRECATED, keeping it for for backward compatibility] Group Id"""
Expand Down Expand Up @@ -511,7 +511,13 @@ def _generate(
with httpx.Client(headers=headers, timeout=60) as client:
response = client.post(self.minimax_api_host, json=payload)
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())

def _stream(
Expand Down
Loading