fix(azure): sanitize messages and handle temperature

This commit is contained in:
Re-bin
2026-03-07 03:57:57 +00:00
parent 7c074e4684
commit 576ad12ef1
4 changed files with 89 additions and 17 deletions

View File

@@ -87,6 +87,20 @@ class LLMProvider(ABC):
result.append(msg)
return result
@staticmethod
def _sanitize_request_messages(
messages: list[dict[str, Any]],
allowed_keys: frozenset[str],
) -> list[dict[str, Any]]:
"""Keep only provider-safe message keys and normalize assistant content."""
sanitized = []
for msg in messages:
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
sanitized.append(clean)
return sanitized
@abstractmethod
async def chat(
self,