From 9c15c446a62b73dc99d78196788245c6c326ece3 Mon Sep 17 00:00:00 2001 From: Junru Shen Date: Fri, 31 Mar 2023 23:38:49 +0800 Subject: [PATCH 1/2] make grammar correction prompt more clear --- functional.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/functional.py b/functional.py index b1f7ae9..56d98fe 100644 --- a/functional.py +++ b/functional.py @@ -21,12 +21,20 @@ def get_functionals(): "Suffix": r"", }, "查找语法错误": { - "Prefix": r"Below is a paragraph from an academic paper. " + - r"Can you help me ensure that the grammar and the spelling is correct? " + - r"Do not try to polish the text, if no mistake is found, tell me that this paragraph is good." + - r"If you find grammar or spelling mistakes, please list mistakes you find in a two-column markdown table, " + + "Prefix": r"Can you help me ensure that the grammar and the spelling is correct? " + + r"Do not try to polish the text, if no mistake is found, tell me that this paragraph is good." + + r"If you find grammar or spelling mistakes, please list mistakes you find in a two-column markdown table, " + r"put the original text the first column, " + - r"put the corrected text in the second column and highlight the key words you fixed." + "\n\n", + r"put the corrected text in the second column and highlight the key words you fixed.""\n" + r"Example:""\n" + r"Paragraph: How is you? Do you knows what is it?""\n" + r"| Original sentence | Corrected sentence |""\n" + r"| :--- | :--- |""\n" + r"| How **is** you? | How **are** you? |""\n" + r"| Do you **knows** what **is** **it**? | Do you **know** what **it** **is** ? |""\n" + r"Below is a paragraph from an academic paper. " + r"You need to report all grammar and spelling mistakes as the example before." + + "\n\n", "Suffix": r"", "PreProcess": clear_line_break, # 预处理:清除换行符 }, From 6a2c7db7c1b67cfa40973635d5ae2fa4a7ec3ee3 Mon Sep 17 00:00:00 2001 From: Junru Shen Date: Fri, 31 Mar 2023 23:40:21 +0800 Subject: [PATCH 2/2] add markdown table border line to make text boundary more clear --- main.py | 14 +++++++++++++- toolbox.py | 7 ++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 3033e39..bdb4584 100644 --- a/main.py +++ b/main.py @@ -37,8 +37,20 @@ gr.Chatbot.postprocess = format_io from theme import adjust_theme set_theme = adjust_theme() +CSS = """ +.markdown-body table { + border: 1px solid #ddd; + border-collapse: collapse; +} + +.markdown-body th, .markdown-body td { + border: 1px solid #ddd; + padding: 5px; +} +""" + cancel_handles = [] -with gr.Blocks(theme=set_theme, analytics_enabled=False) as demo: +with gr.Blocks(theme=set_theme, analytics_enabled=False, css=CSS) as demo: gr.HTML(title_html) with gr.Row(): with gr.Column(scale=2): diff --git a/toolbox.py b/toolbox.py index b78a513..a7f4f9e 100644 --- a/toolbox.py +++ b/toolbox.py @@ -158,11 +158,12 @@ def markdown_convertion(txt): """ 将Markdown格式的文本转换为HTML格式。如果包含数学公式,则先将公式转换为HTML格式。 """ + pre = '
' + suf = '
' if ('$' in txt) and ('```' not in txt): - return markdown.markdown(txt,extensions=['fenced_code','tables']) + '

' + \ - markdown.markdown(convert_math(txt, splitParagraphs=False),extensions=['fenced_code','tables']) + return pre + markdown.markdown(txt,extensions=['fenced_code','tables']) + '

' + markdown.markdown(convert_math(txt, splitParagraphs=False),extensions=['fenced_code','tables']) + suf else: - return markdown.markdown(txt,extensions=['fenced_code','tables']) + return pre + markdown.markdown(txt,extensions=['fenced_code','tables']) + suf def format_io(self, y):