mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-04 12:39:32 +00:00
community[patch]: Update root_validators ChatModels: ChatBaichuan, QianfanChatEndpoint, MiniMaxChat, ChatSparkLLM, ChatZhipuAI (#22853)
This PR updates root validators for: - ChatModels: ChatBaichuan, QianfanChatEndpoint, MiniMaxChat, ChatSparkLLM, ChatZhipuAI Issues #22819 --------- Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
This commit is contained in:
@@ -166,7 +166,7 @@ class MiniMaxChat(BaseChatModel):
|
||||
)
|
||||
minimax_group_id: Optional[str] = Field(default=None, alias="group_id")
|
||||
"""[DEPRECATED, keeping it for for backward compatibility] Group Id"""
|
||||
minimax_api_key: Optional[SecretStr] = Field(default=None, alias="api_key")
|
||||
minimax_api_key: SecretStr = Field(alias="api_key")
|
||||
"""Minimax API Key"""
|
||||
streaming: bool = False
|
||||
"""Whether to stream the results or not."""
|
||||
@@ -176,14 +176,18 @@ class MiniMaxChat(BaseChatModel):
|
||||
|
||||
allow_population_by_field_name = True
|
||||
|
||||
@root_validator(allow_reuse=True)
|
||||
@root_validator(pre=True, allow_reuse=True)
|
||||
def validate_environment(cls, values: Dict) -> Dict:
|
||||
"""Validate that api key and python package exists in environment."""
|
||||
values["minimax_api_key"] = convert_to_secret_str(
|
||||
get_from_dict_or_env(values, "minimax_api_key", "MINIMAX_API_KEY")
|
||||
get_from_dict_or_env(
|
||||
values,
|
||||
["minimax_api_key", "api_key"],
|
||||
"MINIMAX_API_KEY",
|
||||
)
|
||||
)
|
||||
values["minimax_group_id"] = get_from_dict_or_env(
|
||||
values, "minimax_group_id", "MINIMAX_GROUP_ID"
|
||||
values, ["minimax_group_id", "group_id"], "MINIMAX_GROUP_ID"
|
||||
)
|
||||
# Get custom api url from environment.
|
||||
values["minimax_api_host"] = get_from_dict_or_env(
|
||||
|
Reference in New Issue
Block a user