fix: skip empty assistant messages in external provider requests
Some providers (Mistral) reject assistant messages with empty content. Filter them out when building the message list for external providers.
This commit is contained in:
parent
706eaeae36
commit
5c658ba5e3
1 changed files with 3 additions and 0 deletions
|
|
@ -887,6 +887,9 @@ def _build_external_messages(
|
|||
result = []
|
||||
for msg in messages:
|
||||
if isinstance(msg.content, str):
|
||||
# Skip assistant messages with empty content (some providers reject them)
|
||||
if msg.role == "assistant" and not msg.content.strip():
|
||||
continue
|
||||
result.append({"role": msg.role, "content": msg.content})
|
||||
elif isinstance(msg.content, list):
|
||||
if supports_vision:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue