diff --git a/adapter/chatgpt/api.py b/adapter/chatgpt/api.py index dae02995..8f18f625 100644 --- a/adapter/chatgpt/api.py +++ b/adapter/chatgpt/api.py @@ -249,7 +249,8 @@ async def request_with_stream(self, session_id: str = None, messages: list = Non if 'choices' in event and len(event['choices']) > 0 and 'delta' in event['choices'][0]: delta = event['choices'][0]['delta'] if 'role' in delta: - response_role = delta['role'] + if delta['role'] is not None: + response_role = delta['role'] if 'content' in delta: event_text = delta['content'] if event_text is not None: