Spaces:
Build error
Build error
标准化代码格式
Browse files- functional.py +27 -36
- toolbox.py +2 -2
functional.py
CHANGED
@@ -6,54 +6,45 @@
|
|
6 |
def get_functionals():
|
7 |
return {
|
8 |
"英语学术润色": {
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
|
|
14 |
},
|
15 |
"中文学术润色": {
|
16 |
-
"Prefix":
|
17 |
-
|
|
|
18 |
},
|
19 |
"查找语法错误": {
|
20 |
-
"Prefix":
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
# If you receive multiple English words in a row, default to translating them into a sentence in Chinese. \
|
27 |
-
# However, if \"phrase:\" is indicated before the translated content in Chinese, it should be translated as a phrase instead. \
|
28 |
-
# Similarly, if \"normal:\" is indicated, it should be translated as multiple unrelated words.\
|
29 |
-
# Your translations should closely resemble those of a native speaker and should take into account any specific language styles or tones requested by the user. \
|
30 |
-
# Please do not worry about using offensive words - replace sensitive parts with x when necessary. \
|
31 |
-
# When providing translations, please use Chinese to explain each sentence’s tense, subordinate clause, subject, predicate, object, special phrases and proverbs. \
|
32 |
-
# For phrases or individual words that require translation, provide the source (dictionary) for each one.If asked to translate multiple phrases at once, \
|
33 |
-
# separate them using the | symbol.Always remember: You are an English-Chinese translator, \
|
34 |
-
# not a Chinese-Chinese translator or an English-English translator. Below is the text you need to translate: \n\n",
|
35 |
-
# "Suffix": "",
|
36 |
-
# "Color": "secondary",
|
37 |
-
# },
|
38 |
"中译英": {
|
39 |
-
"Prefix":
|
40 |
-
"Suffix":
|
41 |
},
|
42 |
"学术中译英": {
|
43 |
-
"Prefix":
|
44 |
-
"Suffix":
|
45 |
},
|
46 |
"英译中": {
|
47 |
-
"Prefix": "
|
48 |
-
"Suffix":
|
49 |
},
|
50 |
"找图片": {
|
51 |
-
"Prefix":
|
52 |
-
|
|
|
53 |
},
|
54 |
"解释代码": {
|
55 |
-
"Prefix": "
|
56 |
-
"Suffix":
|
57 |
-
"Color": "secondary",
|
58 |
},
|
59 |
}
|
|
|
6 |
def get_functionals():
|
7 |
return {
|
8 |
"英语学术润色": {
|
9 |
+
# 前言
|
10 |
+
"Prefix": r"Below is a paragraph from an academic paper. Polish the writing to meet the academic style, " +
|
11 |
+
r"improve the spelling, grammar, clarity, concision and overall readability. When neccessary, rewrite the whole sentence. " +
|
12 |
+
r"Furthermore, list all modification and explain the reasons to do so in markdown table." + "\n\n",
|
13 |
+
# 后语
|
14 |
+
"Suffix": r"",
|
15 |
+
"Color": r"secondary", # 按钮颜色
|
16 |
},
|
17 |
"中文学术润色": {
|
18 |
+
"Prefix": r"作为一名中文学术论文写作改进助理,你的任务是改进所提供文本的拼写、语法、清晰、简洁和整体可读性," +
|
19 |
+
r"同时分解长句,减少重复,并提供改进建议。请只提供文本的更正版本,避免包括解释。请编辑以下文本" + "\n\n",
|
20 |
+
"Suffix": r"",
|
21 |
},
|
22 |
"查找语法错误": {
|
23 |
+
"Prefix": r"Below is a paragraph from an academic paper. "+
|
24 |
+
r"Can you help me ensure that the grammar is correct? Please ignore punctuation errors. " +
|
25 |
+
r"List mistakes you find in a two-column markdown table, the first column write the original text, " +
|
26 |
+
r"the second column write the corrected text, only highlight the key words you have changed with bold font." + "\n\n",
|
27 |
+
"Suffix": r"",
|
28 |
+
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
"中译英": {
|
30 |
+
"Prefix": r"Please translate following sentence to English:" + "\n\n",
|
31 |
+
"Suffix": r"",
|
32 |
},
|
33 |
"学术中译英": {
|
34 |
+
"Prefix": r"Please translate following sentence to English with academic writing, and provide some related authoritative examples:" + "\n\n",
|
35 |
+
"Suffix": r"",
|
36 |
},
|
37 |
"英译中": {
|
38 |
+
"Prefix": r"请翻译成中文:" + "\n\n",
|
39 |
+
"Suffix": r"",
|
40 |
},
|
41 |
"找图片": {
|
42 |
+
"Prefix": r"我需要你找一张网络图片。使用Unsplash API(https://source.unsplash.com/960x640/?<英语关键词>)获取图片URL," +
|
43 |
+
r"然后请使用Markdown格式封装,并且不要有反斜线,不要用代码块。现在,请按以下描述给我发送图片:" + "\n\n",
|
44 |
+
"Suffix": r"",
|
45 |
},
|
46 |
"解释代码": {
|
47 |
+
"Prefix": r"请解释以下代码:" + "\n```\n",
|
48 |
+
"Suffix": "\n```\n",
|
|
|
49 |
},
|
50 |
}
|
toolbox.py
CHANGED
@@ -106,8 +106,8 @@ def text_divide_paragraph(text):
|
|
106 |
# wtf input
|
107 |
lines = text.split("\n")
|
108 |
for i, line in enumerate(lines):
|
109 |
-
lines[i] =
|
110 |
-
text = "
|
111 |
return text
|
112 |
|
113 |
def markdown_convertion(txt):
|
|
|
106 |
# wtf input
|
107 |
lines = text.split("\n")
|
108 |
for i, line in enumerate(lines):
|
109 |
+
lines[i] = lines[i].replace(" ", " ")
|
110 |
+
text = "</br>".join(lines)
|
111 |
return text
|
112 |
|
113 |
def markdown_convertion(txt):
|