tiny edit
#28
by ismailhakki37 - opened
250 unmodified lines25125225325425525625761 unmodified lines31932032132232332432542 unmodified lines368369370371372373374375376377250 unmodified linestry:chatbot_instance = chat_manager.get_chatbot(args, args.model_path if args else "PULSE-ECG/PULSE-7B", tokenizer, model, image_processor, context_len)chatbot_instance.conversation = conv_templates[chatbot_instance.conv_mode].copy()return {"status": "success", "message": "Conversation history cleared"}except Exception as e:return {"error": f"Failed to clear history: {str(e)}"}61 unmodified linesprint(f"[DEBUG] Image processing error: {str(e)}")return {"error": f"Image processing failed: {str(e)}"}# Prepare conversationinp = DEFAULT_IMAGE_TOKEN + "\n" + message_textour_chatbot.conversation.append_message(our_chatbot.conversation.roles[0], inp)our_chatbot.conversation.append_message(our_chatbot.conversation.roles[1], None)42 unmodified linesprint(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] = responseelse:print("[DEBUG] No conversation messages found")print(f"[DEBUG] Generated response length: {len(response)}")except Exception as e:250 unmodified lines25125225325425525625725825926026126226326461 unmodified lines32632732832933033133233333433533633733833934034134242 unmodified lines385386387388389390391392393394395396397398399400401402403250 unmodified linestry: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()else:# Use default conversation templatechatbot_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 linesprint(f"[DEBUG] Image processing error: {str(e)}")return {"error": f"Image processing failed: {str(e)}"}# Prepare conversation - reset for each request to avoid history issuestry: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 templateour_chatbot.conversation = our_chatbot.conversation.__class__()except Exception as e:print(f"[DEBUG] Failed to reset conversation: {e}")# Continue with existing conversationinp = DEFAULT_IMAGE_TOKEN + "\n" + message_textour_chatbot.conversation.append_message(our_chatbot.conversation.roles[0], inp)our_chatbot.conversation.append_message(our_chatbot.conversation.roles[1], None)42 unmodified linesprint(f"[DEBUG] Conversation messages length: {len(our_chatbot.conversation.messages)}")if len(our_chatbot.conversation.messages) > 0: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] = responseprint(f"[DEBUG] Response added to conversation")else:print(f"[DEBUG] Last message format unexpected: {last_message}")# Add response as new message if format is wrongour_chatbot.conversation.append_message(our_chatbot.conversation.roles[1], response)else:print("[DEBUG] No conversation messages found")# Add response as new messageour_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