Merge pull request #4314 from pipecat-ai/mb/prudent-system-instruction-logging
Log system instruction once at composition time, not on every LLM call
This commit is contained in:
1
changelog/4314.changed.md
Normal file
1
changelog/4314.changed.md
Normal file
@@ -0,0 +1 @@
|
||||
- Reduced debug log noise for LLM services. The system instruction is now logged once when composed (e.g. when turn completion is enabled) instead of on every LLM call. Per-call logs now show only the conversation messages, consistent across Google, Anthropic, AWS, and OpenAI services.
|
||||
@@ -345,9 +345,7 @@ class AnthropicLLMService(LLMService):
|
||||
|
||||
adapter = self.get_llm_adapter()
|
||||
messages_for_logging = adapter.get_messages_for_logging(context)
|
||||
logger.debug(
|
||||
f"{self}: Generating chat from context [{params_from_context['system']}] | {messages_for_logging}"
|
||||
)
|
||||
logger.debug(f"{self}: Generating chat from context {messages_for_logging}")
|
||||
|
||||
await self.start_ttfb_metrics()
|
||||
|
||||
|
||||
@@ -475,9 +475,7 @@ class AWSBedrockLLMService(LLMService):
|
||||
# Log request params with messages redacted for logging
|
||||
adapter = self.get_llm_adapter()
|
||||
messages_for_logging = adapter.get_messages_for_logging(context)
|
||||
logger.debug(
|
||||
f"{self}: Generating chat from context [{system}] | {messages_for_logging}"
|
||||
)
|
||||
logger.debug(f"{self}: Generating chat from context {messages_for_logging}")
|
||||
|
||||
async with self._aws_session.client(
|
||||
service_name="bedrock-runtime", **self._aws_params
|
||||
|
||||
@@ -392,7 +392,7 @@ class GoogleLLMService(LLMService):
|
||||
)
|
||||
|
||||
logger.debug(
|
||||
f"{self}: Generating chat from context [{params['system_instruction']}] | {adapter.get_messages_for_logging(context)}"
|
||||
f"{self}: Generating chat from context {adapter.get_messages_for_logging(context)}"
|
||||
)
|
||||
|
||||
messages = params["messages"]
|
||||
|
||||
@@ -347,6 +347,7 @@ class LLMService(UserTurnCompletionLLMServiceMixin, AIService):
|
||||
parts.append(ASYNC_TOOL_CANCELLATION_INSTRUCTIONS)
|
||||
composed = "\n\n".join(p for p in parts if p)
|
||||
self._settings.system_instruction = composed or None
|
||||
logger.debug(f"{self}: System instruction composed: {self._settings.system_instruction}")
|
||||
|
||||
async def _update_settings(self, delta: LLMSettings) -> dict[str, Any]:
|
||||
"""Apply a settings delta, handling turn-completion fields.
|
||||
|
||||
Reference in New Issue
Block a user