Merge pull request #209 from jr-shen/dev-1
(1)修改语法检查的prompt,确保输出格式统一。 之前使用时经常发现输出没有把修改的部分加粗,或者在表格中把整段文字输出了,影响阅读。因此在之前的prompt基础上增加了一个example,确保输出格式统一。 (2)表格内增加了边框线,使行/列之间的分隔更清楚。 使用时发现没有边框的表格在里面文字较多时难以区分。因此增加表格内边框线。
This commit is contained in:
commit
364810983a
@ -21,12 +21,20 @@ def get_functionals():
|
|||||||
"Suffix": r"",
|
"Suffix": r"",
|
||||||
},
|
},
|
||||||
"查找语法错误": {
|
"查找语法错误": {
|
||||||
"Prefix": r"Below is a paragraph from an academic paper. " +
|
"Prefix": r"Can you help me ensure that the grammar and the spelling is correct? " +
|
||||||
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"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"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 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"",
|
"Suffix": r"",
|
||||||
"PreProcess": clear_line_break, # 预处理:清除换行符
|
"PreProcess": clear_line_break, # 预处理:清除换行符
|
||||||
},
|
},
|
||||||
|
14
main.py
14
main.py
@ -36,8 +36,20 @@ gr.Chatbot.postprocess = format_io
|
|||||||
from theme import adjust_theme
|
from theme import adjust_theme
|
||||||
set_theme = 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 = []
|
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)
|
gr.HTML(title_html)
|
||||||
with gr.Row().style(equal_height=True):
|
with gr.Row().style(equal_height=True):
|
||||||
with gr.Column(scale=2):
|
with gr.Column(scale=2):
|
||||||
|
@ -157,11 +157,12 @@ def markdown_convertion(txt):
|
|||||||
"""
|
"""
|
||||||
将Markdown格式的文本转换为HTML格式。如果包含数学公式,则先将公式转换为HTML格式。
|
将Markdown格式的文本转换为HTML格式。如果包含数学公式,则先将公式转换为HTML格式。
|
||||||
"""
|
"""
|
||||||
|
pre = '<div class="markdown-body">'
|
||||||
|
suf = '</div>'
|
||||||
if ('$' in txt) and ('```' not in txt):
|
if ('$' in txt) and ('```' not in txt):
|
||||||
return markdown.markdown(txt,extensions=['fenced_code','tables']) + '<br><br>' + \
|
return pre + markdown.markdown(txt,extensions=['fenced_code','tables']) + '<br><br>' + markdown.markdown(convert_math(txt, splitParagraphs=False),extensions=['fenced_code','tables']) + suf
|
||||||
markdown.markdown(convert_math(txt, splitParagraphs=False),extensions=['fenced_code','tables'])
|
|
||||||
else:
|
else:
|
||||||
return markdown.markdown(txt,extensions=['fenced_code','tables'])
|
return pre + markdown.markdown(txt,extensions=['fenced_code','tables']) + suf
|
||||||
|
|
||||||
|
|
||||||
def format_io(self, y):
|
def format_io(self, y):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user