Spaces:
Paused
Paused
Merge pull request #209 from jr-shen/dev-1
Browse files(1)修改语法检查的prompt,确保输出格式统一。
之前使用时经常发现输出没有把修改的部分加粗,或者在表格中把整段文字输出了,影响阅读。因此在之前的prompt基础上增加了一个example,确保输出格式统一。
(2)表格内增加了边框线,使行/列之间的分隔更清楚。
使用时发现没有边框的表格在里面文字较多时难以区分。因此增加表格内边框线。
- functional.py +13 -5
- main.py +13 -1
- toolbox.py +4 -3
functional.py
CHANGED
@@ -21,12 +21,20 @@ def get_functionals():
|
|
21 |
"Suffix": r"",
|
22 |
},
|
23 |
"查找语法错误": {
|
24 |
-
"Prefix": r"
|
25 |
-
r"
|
26 |
-
r"
|
27 |
-
r"If you find grammar or spelling mistakes, please list mistakes you find in a two-column markdown table, " +
|
28 |
r"put the original text the first column, " +
|
29 |
-
r"put the corrected text in the second column and highlight the key words you fixed."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
"Suffix": r"",
|
31 |
"PreProcess": clear_line_break, # 预处理:清除换行符
|
32 |
},
|
|
|
21 |
"Suffix": r"",
|
22 |
},
|
23 |
"查找语法错误": {
|
24 |
+
"Prefix": r"Can you help me ensure that the grammar and the spelling is correct? " +
|
25 |
+
r"Do not try to polish the text, if no mistake is found, tell me that this paragraph is good." +
|
26 |
+
r"If you find grammar or spelling mistakes, please list mistakes you find in a two-column markdown table, " +
|
|
|
27 |
r"put the original text the first column, " +
|
28 |
+
r"put the corrected text in the second column and highlight the key words you fixed.""\n"
|
29 |
+
r"Example:""\n"
|
30 |
+
r"Paragraph: How is you? Do you knows what is it?""\n"
|
31 |
+
r"| Original sentence | Corrected sentence |""\n"
|
32 |
+
r"| :--- | :--- |""\n"
|
33 |
+
r"| How **is** you? | How **are** you? |""\n"
|
34 |
+
r"| Do you **knows** what **is** **it**? | Do you **know** what **it** **is** ? |""\n"
|
35 |
+
r"Below is a paragraph from an academic paper. "
|
36 |
+
r"You need to report all grammar and spelling mistakes as the example before."
|
37 |
+
+ "\n\n",
|
38 |
"Suffix": r"",
|
39 |
"PreProcess": clear_line_break, # 预处理:清除换行符
|
40 |
},
|
main.py
CHANGED
@@ -36,8 +36,20 @@ gr.Chatbot.postprocess = format_io
|
|
36 |
from theme import adjust_theme
|
37 |
set_theme = adjust_theme()
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
cancel_handles = []
|
40 |
-
with gr.Blocks(theme=set_theme, analytics_enabled=False) as demo:
|
41 |
gr.HTML(title_html)
|
42 |
with gr.Row().style(equal_height=True):
|
43 |
with gr.Column(scale=2):
|
|
|
36 |
from theme import adjust_theme
|
37 |
set_theme = adjust_theme()
|
38 |
|
39 |
+
CSS = """
|
40 |
+
.markdown-body table {
|
41 |
+
border: 1px solid #ddd;
|
42 |
+
border-collapse: collapse;
|
43 |
+
}
|
44 |
+
|
45 |
+
.markdown-body th, .markdown-body td {
|
46 |
+
border: 1px solid #ddd;
|
47 |
+
padding: 5px;
|
48 |
+
}
|
49 |
+
"""
|
50 |
+
|
51 |
cancel_handles = []
|
52 |
+
with gr.Blocks(theme=set_theme, analytics_enabled=False, css=CSS) as demo:
|
53 |
gr.HTML(title_html)
|
54 |
with gr.Row().style(equal_height=True):
|
55 |
with gr.Column(scale=2):
|
toolbox.py
CHANGED
@@ -157,11 +157,12 @@ def markdown_convertion(txt):
|
|
157 |
"""
|
158 |
将Markdown格式的文本转换为HTML格式。如果包含数学公式,则先将公式转换为HTML格式。
|
159 |
"""
|
|
|
|
|
160 |
if ('$' in txt) and ('```' not in txt):
|
161 |
-
return markdown.markdown(txt,extensions=['fenced_code','tables']) + '<br><br>' +
|
162 |
-
markdown.markdown(convert_math(txt, splitParagraphs=False),extensions=['fenced_code','tables'])
|
163 |
else:
|
164 |
-
return markdown.markdown(txt,extensions=['fenced_code','tables'])
|
165 |
|
166 |
|
167 |
def format_io(self, y):
|
|
|
157 |
"""
|
158 |
将Markdown格式的文本转换为HTML格式。如果包含数学公式,则先将公式转换为HTML格式。
|
159 |
"""
|
160 |
+
pre = '<div class="markdown-body">'
|
161 |
+
suf = '</div>'
|
162 |
if ('$' in txt) and ('```' not in txt):
|
163 |
+
return pre + markdown.markdown(txt,extensions=['fenced_code','tables']) + '<br><br>' + markdown.markdown(convert_math(txt, splitParagraphs=False),extensions=['fenced_code','tables']) + suf
|
|
|
164 |
else:
|
165 |
+
return pre + markdown.markdown(txt,extensions=['fenced_code','tables']) + suf
|
166 |
|
167 |
|
168 |
def format_io(self, y):
|