mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
fix(llm): bedrock throw errors if content contains empty string (#4935)
This commit is contained in:
parent
b54724ac3f
commit
910b283ac2
@ -98,6 +98,13 @@ class Message(BaseModel):
|
||||
content.extend(d)
|
||||
|
||||
ret: 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'] == ''
|
||||
):
|
||||
ret.pop('content')
|
||||
|
||||
if role_tool_with_prompt_caching:
|
||||
ret['cache_control'] = {'type': 'ephemeral'}
|
||||
|
||||
@ -14,7 +14,9 @@ class DebugMixin:
|
||||
|
||||
messages = messages if isinstance(messages, list) else [messages]
|
||||
debug_message = MESSAGE_SEPARATOR.join(
|
||||
self._format_message_content(msg) for msg in messages if msg['content']
|
||||
self._format_message_content(msg)
|
||||
for msg in messages
|
||||
if msg.get('content', None)
|
||||
)
|
||||
|
||||
if debug_message:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user