Clean up empty content fix (revert #4935) (#5539)

This commit is contained in:
Engel Nyst 2024-12-12 03:48:06 +01:00 committed by GitHub
parent 7e4c1c733b
commit 425ccb0fbb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 2 additions and 10 deletions

View File

@ -105,14 +105,6 @@ class Message(BaseModel):
message_dict: dict = {'content': content, 'role': self.role}
# pop content if it's empty
if not content or (
len(content) == 1
and content[0]['type'] == 'text'
and content[0]['text'] == ''
):
message_dict.pop('content')
if role_tool_with_prompt_caching:
message_dict['cache_control'] = {'type': 'ephemeral'}

View File

@ -16,7 +16,7 @@ class DebugMixin:
debug_message = MESSAGE_SEPARATOR.join(
self._format_message_content(msg)
for msg in messages
if msg.get('content', None)
if msg['content'] is not None
)
if debug_message:

View File

@ -321,7 +321,7 @@ def convert_fncall_messages_to_non_fncall_messages(
first_user_message_encountered = False
for message in messages:
role = message['role']
content = message.get('content', '')
content = message['content']
# 1. SYSTEM MESSAGES
# append system prompt suffix to content