Spaces:
Sleeping
Sleeping
Update core_functional.py
Browse files- core_functional.py +1 -74
core_functional.py
CHANGED
|
@@ -7,82 +7,9 @@ from toolbox import clear_line_break
|
|
| 7 |
|
| 8 |
def get_core_functions():
|
| 9 |
return {
|
| 10 |
-
"英语学术润色": {
|
| 11 |
-
# 前缀,会被加在你的输入之前。例如,用来描述你的要求,例如翻译、解释代码、润色等等
|
| 12 |
-
"Prefix": r"Below is a paragraph from an academic paper. Polish the writing to meet the academic style, " +
|
| 13 |
-
r"improve the spelling, grammar, clarity, concision and overall readability. When necessary, rewrite the whole sentence. " +
|
| 14 |
-
r"Firstly, you should provide the polished paragraph. "
|
| 15 |
-
r"Secondly, you should list all your modification and explain the reasons to do so in markdown table." + "\n\n",
|
| 16 |
-
# 后缀,会被加在你的输入之后。例如,配合前缀可以把你的输入内容用引号圈起来
|
| 17 |
-
"Suffix": r"",
|
| 18 |
-
# 按钮颜色 (默认 secondary)
|
| 19 |
-
"Color": r"secondary",
|
| 20 |
-
# 按钮是否可见 (默认 True,即可见)
|
| 21 |
-
"Visible": True,
|
| 22 |
-
# 是否在触发时清除历史 (默认 False,即不处理之前的对话历史)
|
| 23 |
-
"AutoClearHistory": False
|
| 24 |
-
},
|
| 25 |
-
"中文学术润色": {
|
| 26 |
-
"Prefix": r"作为一名中文学术论文写作改进助理,你的任务是改进所提供文本的拼写、语法、清晰、简洁和整体可读性," +
|
| 27 |
-
r"同时分解长句,减少重复,并提供改进建议。请只提供文本的更正版本,避免包括解释。请编辑以下文本" + "\n\n",
|
| 28 |
-
"Suffix": r"",
|
| 29 |
-
},
|
| 30 |
-
"查找语法错误": {
|
| 31 |
-
"Prefix": r"Help me ensure that the grammar and the spelling is correct. "
|
| 32 |
-
r"Do not try to polish the text, if no mistake is found, tell me that this paragraph is good. "
|
| 33 |
-
r"If you find grammar or spelling mistakes, please list mistakes you find in a two-column markdown table, "
|
| 34 |
-
r"put the original text the first column, "
|
| 35 |
-
r"put the corrected text in the second column and highlight the key words you fixed. "
|
| 36 |
-
r"Finally, please provide the proofreaded text.""\n\n"
|
| 37 |
-
r"Example:""\n"
|
| 38 |
-
r"Paragraph: How is you? Do you knows what is it?""\n"
|
| 39 |
-
r"| Original sentence | Corrected sentence |""\n"
|
| 40 |
-
r"| :--- | :--- |""\n"
|
| 41 |
-
r"| How **is** you? | How **are** you? |""\n"
|
| 42 |
-
r"| Do you **knows** what **is** **it**? | Do you **know** what **it** **is** ? |""\n\n"
|
| 43 |
-
r"Below is a paragraph from an academic paper. "
|
| 44 |
-
r"You need to report all grammar and spelling mistakes as the example before."
|
| 45 |
-
+ "\n\n",
|
| 46 |
-
"Suffix": r"",
|
| 47 |
-
"PreProcess": clear_line_break, # 预处理:清除换行符
|
| 48 |
-
},
|
| 49 |
-
"中译英": {
|
| 50 |
-
"Prefix": r"Please translate following sentence to English:" + "\n\n",
|
| 51 |
-
"Suffix": r"",
|
| 52 |
-
},
|
| 53 |
-
"学术中英互译": {
|
| 54 |
-
"Prefix": r"I want you to act as a scientific English-Chinese translator, " +
|
| 55 |
-
r"I will provide you with some paragraphs in one language " +
|
| 56 |
-
r"and your task is to accurately and academically translate the paragraphs only into the other language. " +
|
| 57 |
-
r"Do not repeat the original provided paragraphs after translation. " +
|
| 58 |
-
r"You should use artificial intelligence tools, " +
|
| 59 |
-
r"such as natural language processing, and rhetorical knowledge " +
|
| 60 |
-
r"and experience about effective writing techniques to reply. " +
|
| 61 |
-
r"I'll give you my paragraphs as follows, tell me what language it is written in, and then translate:" + "\n\n",
|
| 62 |
-
"Suffix": "",
|
| 63 |
-
"Color": "secondary",
|
| 64 |
-
},
|
| 65 |
-
"英译中": {
|
| 66 |
-
"Prefix": r"翻译成地道的中文:" + "\n\n",
|
| 67 |
-
"Suffix": r"",
|
| 68 |
-
"Visible": False,
|
| 69 |
-
},
|
| 70 |
-
"找图片": {
|
| 71 |
-
"Prefix": r"我需要你找一张网络图片。使用Unsplash API(https://source.unsplash.com/960x640/?<英语关键词>)获取图片URL," +
|
| 72 |
-
r"然后请使用Markdown格式封装,并且不要有反斜线,不要用代码块。现在,请按以下描述给我发送图片:" + "\n\n",
|
| 73 |
-
"Suffix": r"",
|
| 74 |
-
"Visible": False,
|
| 75 |
-
},
|
| 76 |
"解释代码": {
|
| 77 |
"Prefix": r"请解释以下代码:" + "\n```\n",
|
| 78 |
"Suffix": "\n```\n",
|
| 79 |
-
},
|
| 80 |
-
"参考文献转Bib": {
|
| 81 |
-
"Prefix": r"Here are some bibliography items, please transform them into bibtex style." +
|
| 82 |
-
r"Note that, reference styles maybe more than one kind, you should transform each item correctly." +
|
| 83 |
-
r"Items need to be transformed:",
|
| 84 |
-
"Visible": False,
|
| 85 |
-
"Suffix": r"",
|
| 86 |
}
|
| 87 |
}
|
| 88 |
|
|
@@ -102,4 +29,4 @@ def handle_core_functionality(additional_fn, inputs, history, chatbot):
|
|
| 102 |
inputs = core_functional[additional_fn]["Prefix"] + inputs + core_functional[additional_fn]["Suffix"]
|
| 103 |
if core_functional[additional_fn].get("AutoClearHistory", False):
|
| 104 |
history = []
|
| 105 |
-
return inputs, history
|
|
|
|
| 7 |
|
| 8 |
def get_core_functions():
|
| 9 |
return {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
"解释代码": {
|
| 11 |
"Prefix": r"请解释以下代码:" + "\n```\n",
|
| 12 |
"Suffix": "\n```\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
}
|
| 14 |
}
|
| 15 |
|
|
|
|
| 29 |
inputs = core_functional[additional_fn]["Prefix"] + inputs + core_functional[additional_fn]["Suffix"]
|
| 30 |
if core_functional[additional_fn].get("AutoClearHistory", False):
|
| 31 |
history = []
|
| 32 |
+
return inputs, history
|