This commit is contained in:
qixinbo
2026-03-15 01:29:36 +08:00
parent 4985c1eed3
commit 76724b2313
12 changed files with 1345 additions and 82 deletions
+11
View File
@@ -95,6 +95,17 @@ class LLMProvider(ABC):
"""Keep only provider-safe message keys and normalize assistant content."""
sanitized = []
for msg in messages:
if isinstance(msg, list):
for nested in msg:
if not isinstance(nested, dict):
continue
clean = {k: v for k, v in nested.items() if k in allowed_keys}
if clean.get("role") == "assistant" and "content" not in clean:
clean["content"] = None
sanitized.append(clean)
continue
if not isinstance(msg, dict):
continue
clean = {k: v for k, v in msg.items() if k in allowed_keys}
if clean.get("role") == "assistant" and "content" not in clean:
clean["content"] = None