community[patch]: Update minimax.py (#14384)

MiniMaxChat class _generate method shoud return a ChatResult object not
str

Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
ethynic 2024-03-30 07:57:06 +08:00 committed by GitHub
parent f5d4ce840f
commit e9caa22d47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,7 +12,7 @@ from langchain_core.messages import (
BaseMessage,
HumanMessage,
)
from langchain_core.outputs import ChatResult
from langchain_core.outputs import ChatGeneration, ChatResult
from langchain_community.llms.minimax import MinimaxCommon
from langchain_community.llms.utils import enforce_stop_tokens
@ -81,7 +81,8 @@ class MiniMaxChat(MinimaxCommon, BaseChatModel):
text = self._client.post(payload)
# This is required since the stop are not enforced by the model parameters
return text if stop is None else enforce_stop_tokens(text, stop)
text = text if stop is None else enforce_stop_tokens(text, stop)
return ChatResult(generations=[ChatGeneration(message=AIMessage(text))])
async def _agenerate(
self,