From 026f184615f2f3db2a4c4633e5fb02c00be4683f Mon Sep 17 00:00:00 2001 From: Traian Rebedea Date: Tue, 5 Mar 2024 16:50:30 +0200 Subject: [PATCH] Fix #378 - missing prompt in verbose mode for chat models --- nemoguardrails/logging/callbacks.py | 34 ++++++++++++++++------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/nemoguardrails/logging/callbacks.py b/nemoguardrails/logging/callbacks.py index a92d8471b..52d79661f 100644 --- a/nemoguardrails/logging/callbacks.py +++ b/nemoguardrails/logging/callbacks.py @@ -87,21 +87,25 @@ async def on_chat_model_start( llm_call_info = LLMCallInfo() llm_call_info_var.set(llm_call_info) - prompt = "\n" + "\n".join( - [ - Styles.CYAN - + ( - "User" - if msg.type == "human" - else "Bot" - if msg.type == "ai" - else "System" - ) - + Styles.PROMPT - + "\n" - + msg.content - for msg in messages[0] + Styles.RESET_ALL - ] + prompt = ( + "\n" + + "\n".join( + [ + Styles.CYAN + + ( + "User" + if msg.type == "human" + else "Bot" + if msg.type == "ai" + else "System" + ) + + Styles.PROMPT + + "\n" + + msg.content + for msg in messages[0] + ] + ) + + Styles.RESET_ALL ) log.info("Invocation Params :: %s", kwargs.get("invocation_params", {}))