Fix: warn on system_instruction conflict even with single system message
When the only message in context was a system message, _extract_initial_system_or_developer would convert it to "user" (to prevent empty history) without warning about the conflict with system_instruction. Now warns inline before converting, with a message explaining both the conflict and the user-role conversion.
This commit is contained in:
@@ -188,6 +188,15 @@ class BaseLLMAdapter(ABC, Generic[TLLMInvocationParams]):
|
||||
|
||||
# Would extracting empty the list? Convert to "user" instead.
|
||||
if len(messages) == 1:
|
||||
if role == "system" and system_instruction:
|
||||
if not self._warned_system_instruction:
|
||||
self._warned_system_instruction = True
|
||||
logger.warning(
|
||||
"Both system_instruction and a system message in context are set."
|
||||
" Using system_instruction. The system message in context is being"
|
||||
" converted to a user message to avoid sending an empty conversation"
|
||||
" history."
|
||||
)
|
||||
messages[0]["role"] = "user"
|
||||
return None, None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user