Update handle regeneration
Browse files90 unmodified lines91929394959697989910010110210310410510616 unmodified lines12312412512612712812913013113213313413513613713813914014114272 unmodified lines21521621721821922022122222322490 unmodified linesdef handle_text_input(history, task_history, text):"""Handle text input from the user."""# Überprüfen, ob das Eingabefeld leer istif not text:# Wenn das Eingabefeld leer ist, senden Sie eine vordefinierte Anfragetext = "Describe the image for me..."# Aktualisieren Sie das Chat- und Task-Verlauf mit der vordefinierten Anfragehistory = history + [(format_text(text), None)]task_history = task_history + [(text, None)]# Rufen Sie get_chat_response auf, um eine Antwort zu generierenreturn get_chat_response(history, task_history)task_text = textif len(text) >= 2 and text[-1] in PUNCTUATION and text[-2] not in PUNCTUATION:task_text = text[:-1]16 unmodified linestask_history.clear()return []def handle_regeneration(chatbot, task_history, input_field):"""Handle the regeneration of the last response."""print("Regenerate clicked")print("Before:", task_history, chatbot)if not task_history:return chatbot# Überprüfen, ob das Eingabefeld leer istif not input_field.value:# Wenn das Eingabefeld leer ist, senden Sie eine vordefinierte Anfragepredefined_query = "Describe this image for me..."# Aktualisieren Sie das Eingabefeld mit der vordefinierten Anfrageinput_field.update(value=predefined_query)# Führen Sie die normale Texteingabebehandlung durchhandle_text_input(chatbot, task_history, predefined_query)else:item = task_history[-1]72 unmodified linesgr.Markdown("### Key Features:\n- **Strong Performance**: Surpasses existing LVLMs on multiple English benchmarks including Zero-shot Captioning and VQA.\n- **Multi-lingual Support**: Supports English, Chinese, and multi-lingual conversation.\n- **High Resolution**: Utilizes 448*448 resolution for fine-grained recognition and understanding.")submit_btn.click(handle_text_input, [chatbot, task_history, query], [chatbot, task_history]).then(get_chat_response, [chatbot, task_history], [chatbot], show_progress=True)submit_btn.click(clear_input, [], [query])clear_btn.click(clear_history, [task_history], [chatbot], show_progress=True)90 unmodified lines91929394959616 unmodified lines11311411511611711811912012112212312412512612712812972 unmodified lines20220320420520620720820990 unmodified linesdef handle_text_input(history, task_history, text):"""Handle text input from the user."""task_text = textif len(text) >= 2 and text[-1] in PUNCTUATION and text[-2] not in PUNCTUATION:task_text = text[:-1]16 unmodified linestask_history.clear()return []def handle_regeneration(chatbot, task_history):"""Handle the regeneration of the last response."""print("Regenerate clicked")print("Before:", task_history, chatbot)input_field = chatbot[-1] if chatbot else Noneif not input_field or not isinstance(input_field, tuple) or len(input_field) != 2:return chatbotif not input_field.value:predefined_query = "Describe this image for me..."input_field.update(value=predefined_query)handle_text_input(chatbot, task_history, predefined_query)else:item = task_history[-1]72 unmodified linesgr.Markdown("### Key Features:\n- **Strong Performance**: Surpasses existing LVLMs on multiple English benchmarks including Zero-shot Captioning and VQA.\n- **Multi-lingual Support**: Supports English, Chinese, and multi-lingual conversation.\n- **High Resolution**: Utilizes 448*448 resolution for fine-grained recognition and understanding.")submit_btn.click(handle_text_input, [chatbot, task_history, query], [chatbot, task_history]).then(get_chat_response, [chatbot, task_history], [chatbot], show_progress=True)submit_btn.click(clear_input, [], [query])clear_btn.click(clear_history, [task_history], [chatbot], show_progress=True)
app.py+5-20