Upload free_ask_internet.py
Browse files- free_ask_internet.py +11 -19
free_ask_internet.py
CHANGED
@@ -116,19 +116,16 @@ def gen_prompt(question, content_list, lang="zh-CN", context_length_limit=11000,
|
|
116 |
answer_language = ' English '
|
117 |
# 定义 Unicode 上标数字映射
|
118 |
superscript_digits = {
|
119 |
-
'1': '¹', '2': '²', '3': '³', '4': '⁴', '5': '⁵',
|
120 |
-
'6': '⁶', '7': '⁷', '8': '⁸', '9': '⁹', '0': '⁰'
|
121 |
}
|
122 |
if len(ref_content) > 0:
|
123 |
prompts = '''
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
3. 如果一句话源自多个上下文,请列出所有相关的引用编号,例如:综合多个来源的内容 ² ³
|
130 |
-
4. 不要将引用集中在最后返回,而是在答案对应部分列出。除非是代码、特定的名称或引用编号,答案的语言应与问题相同
|
131 |
-
以下是上下文的内容集:
|
132 |
''' + "\n\n" + "```"
|
133 |
|
134 |
# 使用 Unicode 上标数字作为引用标记
|
@@ -142,13 +139,8 @@ def gen_prompt(question, content_list, lang="zh-CN", context_length_limit=11000,
|
|
142 |
prompts = prompts[0:limit_len]
|
143 |
prompts = prompts + '''
|
144 |
```
|
145 |
-
|
146 |
-
|
147 |
-
2. 如果回答很长,请尽量结构化、分段落总结
|
148 |
-
3. 严格使用符号引用(如 ¹、 ²)的格式在答案中对应部分引用上下文
|
149 |
-
4. 如果一句话源自多个上下文,请列出所有相关的引用编号(如 ² ³ )
|
150 |
-
5. 不要将引用集中在最后返回,而是在答案对应部分列出
|
151 |
-
下面是用户问题:
|
152 |
''' + question
|
153 |
else:
|
154 |
prompts = question
|
@@ -249,8 +241,8 @@ def ask_internet(query:str, model:str, debug=False):
|
|
249 |
if content_list:
|
250 |
# 定义 Unicode 上标数字映射
|
251 |
superscript_digits = {
|
252 |
-
'1': '¹', '2': '²', '3': '³', '4': '⁴', '5': '⁵',
|
253 |
-
'6': '⁶', '7': '⁷', '8': '⁸', '9': '⁹', '0': '⁰'
|
254 |
}
|
255 |
|
256 |
# 创建上标符号到URL的映射
|
|
|
116 |
answer_language = ' English '
|
117 |
# 定义 Unicode 上标数字映射
|
118 |
superscript_digits = {
|
119 |
+
'citation:1': '¹', 'citation:2': '²', 'citation:3': '³', 'citation:4': '⁴', 'citation:5': '⁵',
|
120 |
+
'citation:6': '⁶', 'citation:7': '⁷', 'citation:8': '⁸', 'citation:9': '⁹', 'citation:0': '⁰'
|
121 |
}
|
122 |
if len(ref_content) > 0:
|
123 |
prompts = '''
|
124 |
+
You are a large language AI assistant develop by nash_su. You are given a user question, and please write clean, concise and accurate answer to the question. You will be given a set of related contexts to the question, each starting with a reference number like [citation:x], where x is a number. Please use the context and cite the context at the end of each sentence if applicable.
|
125 |
+
Your answer must be correct, accurate and written by an expert using an unbiased and professional tone. Please limit to 1024 tokens. Do not give any information that is not related to the question, and do not repeat. Say "information is missing on" followed by the related topic, if the given context do not provide sufficient information.
|
126 |
+
|
127 |
+
Please cite the contexts with the reference numbers, in the format [citation:x]. If a sentence comes from multiple contexts, please list all applicable citations, like [citation:3][citation:5]. Other than code and specific names and citations, your answer must be written in the same language as the question.
|
128 |
+
Here are the set of contexts:
|
|
|
|
|
|
|
129 |
''' + "\n\n" + "```"
|
130 |
|
131 |
# 使用 Unicode 上标数字作为引用标记
|
|
|
139 |
prompts = prompts[0:limit_len]
|
140 |
prompts = prompts + '''
|
141 |
```
|
142 |
+
Above is the reference contexts. Remember, don't repeat the context word for word. Answer in ''' + answer_language + '''. If the response is lengthy, structure it in paragraphs and summarize where possible. Cite the context using the format [citation:x] where x is the reference number. If a sentence originates from multiple contexts, list all relevant citation numbers, like [citation:3][citation:5]. Don't cluster the citations at the end but include them in the answer where they correspond.
|
143 |
+
Remember, don't blindly repeat the contexts verbatim. And here is the user question:
|
|
|
|
|
|
|
|
|
|
|
144 |
''' + question
|
145 |
else:
|
146 |
prompts = question
|
|
|
241 |
if content_list:
|
242 |
# 定义 Unicode 上标数字映射
|
243 |
superscript_digits = {
|
244 |
+
'citation:1': '¹', 'citation:2': '²', 'citation:3': '³', 'citation:4': '⁴', 'citation:5': '⁵',
|
245 |
+
'citation:6': '⁶', 'citation:7': '⁷', 'citation:8': '⁸', 'citation:9': '⁹', 'citation:0': '⁰'
|
246 |
}
|
247 |
|
248 |
# 创建上标符号到URL的映射
|