normalize
#37
by ismailhakki37 - opened
95 unmodified lines96979899100101455 unmodified lines55755855956056156295 unmodified linescontext_len = Noneargs = Nonedef get_conv_log_filename():t = datetime.datetime.now()name = os.path.join(LOGDIR, f"{t.year}-{t.month:02d}-{t.day:02d}-user_conv.json")455 unmodified linespayload.get("prompt") orpayload.get("istem") or "")# Extract image with multiple possible keysimage_input = (payload.get("image") orpayload.get("image_url") or95 unmodified lines96979899100101102103104105106107108455 unmodified lines56456556656756856957057157257357457557657757857958058158295 unmodified linescontext_len = Noneargs = None# Configuration for consistent responsesPROMPT_NORMALIZATION = True # Set to False to disable prompt normalizationDEFAULT_ECG_PROMPT = "What are the main features and diagnosis in this ECG image? Provide a comprehensive clinical analysis"# Note: When PROMPT_NORMALIZATION is True, all ECG diagnosis requests will be# standardized to ensure consistent response lengths and content across different clients.def get_conv_log_filename():t = datetime.datetime.now()name = os.path.join(LOGDIR, f"{t.year}-{t.month:02d}-{t.day:02d}-user_conv.json")455 unmodified linespayload.get("prompt") orpayload.get("istem") or "")# Normalize prompt to ensure consistent responses# This helps maintain consistency across different clientsif PROMPT_NORMALIZATION and "ecg" in message_text.lower() and "diagnosis" in message_text.lower():# Standardize ECG analysis prompts for consistencyif "comprehensive" in message_text.lower():message_text = DEFAULT_ECG_PROMPTelif "concise" in message_text.lower():message_text = "What are the main features and diagnosis in this ECG image? Provide a concise, clinical answer."else:# Default to comprehensive analysis for consistencymessage_text = DEFAULT_ECG_PROMPTprint(f"[DEBUG] Normalized prompt to: {message_text}")# Extract image with multiple possible keysimage_input = (payload.get("image") orpayload.get("image_url") or
handler.py+20