Merge pull request #596 from orange-crow/update-Message-instance

Message(msg) -> Message(content=msg)
This commit is contained in:
geekan 2023-12-21 15:13:31 +08:00 committed by GitHub
commit 4bf1844022
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -303,7 +303,7 @@ class OpenAIGPTAPI(BaseGPTAPI, RateLimiter):
def _process_message(self, messages: Union[str, Message, list[dict], list[Message], list[str]]) -> list[dict]:
"""convert messages to list[dict]."""
if isinstance(messages, list):
messages = [Message(msg) if isinstance(msg, str) else msg for msg in messages]
messages = [Message(content=msg) if isinstance(msg, str) else msg for msg in messages]
return [msg if isinstance(msg, dict) else msg.to_dict() for msg in messages]
if isinstance(messages, Message):