tiny edit
#28
by ismailhakki37 - opened
250 unmodified lines25125225325425525425625725825926026126226326461 unmodified lines32632732832232933033133233333433533633733833934034134242 unmodified lines385386387371372388389390391392393394395396397398399400401402403250 unmodified lines try: chatbot_instance = chat_manager.get_chatbot(args, args.model_path if args else "PULSE-ECG/PULSE-7B", tokenizer, model, image_processor, context_len) try: if hasattr(chatbot_instance, 'conv_mode') and chatbot_instance.conv_mode and LLAVA_AVAILABLE: chatbot_instance.conversation = conv_templates[chatbot_instance.conv_mode].copy() chatbot_instance.conversation = conv_templates[chatbot_instance.conv_mode].copy() else: # Use default conversation template chatbot_instance.conversation = chatbot_instance.conversation.__class__() except Exception as e: print(f"[DEBUG] Failed to reset conversation in clear_history: {e}") return {"status": "success", "message": "Conversation history cleared"} except Exception as e: return {"error": f"Failed to clear history: {str(e)}"}61 unmodified lines print(f"[DEBUG] Image processing error: {str(e)}") return {"error": f"Image processing failed: {str(e)}"} # Prepare conversation # Prepare conversation - reset for each request to avoid history issues try: if hasattr(our_chatbot, 'conv_mode') and our_chatbot.conv_mode and LLAVA_AVAILABLE: our_chatbot.conversation = conv_templates[our_chatbot.conv_mode].copy() else: # Use default conversation template our_chatbot.conversation = our_chatbot.conversation.__class__() except Exception as e: print(f"[DEBUG] Failed to reset conversation: {e}") # Continue with existing conversation inp = DEFAULT_IMAGE_TOKEN + "\n" + message_text our_chatbot.conversation.append_message(our_chatbot.conversation.roles[0], inp) our_chatbot.conversation.append_message(our_chatbot.conversation.roles[1], None)42 unmodified lines print(f"[DEBUG] Conversation messages length: {len(our_chatbot.conversation.messages)}") if len(our_chatbot.conversation.messages) > 0: print(f"[DEBUG] Last message length: {len(our_chatbot.conversation.messages[-1])}") our_chatbot.conversation.messages[-1][-1] = response last_message = our_chatbot.conversation.messages[-1] print(f"[DEBUG] Last message: {last_message}") if isinstance(last_message, list) and len(last_message) > 1: our_chatbot.conversation.messages[-1][-1] = response print(f"[DEBUG] Response added to conversation") else: print(f"[DEBUG] Last message format unexpected: {last_message}") # Add response as new message if format is wrong our_chatbot.conversation.append_message(our_chatbot.conversation.roles[1], response) else: print("[DEBUG] No conversation messages found") # Add response as new message our_chatbot.conversation.append_message(our_chatbot.conversation.roles[1], response) print(f"[DEBUG] Generated response length: {len(response)}") except Exception as e:handler.py+30-4