Upload free_ask_internet.py
Browse files- free_ask_internet.py +16 -23
free_ask_internet.py
CHANGED
@@ -121,7 +121,8 @@ def gen_prompt(question, content_list, lang="zh-CN", context_length_limit=11000,
|
|
121 |
}
|
122 |
if len(ref_content) > 0:
|
123 |
prompts = '''
|
124 |
-
You are a large language AI assistant. 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 symbol.
|
|
|
125 |
|
126 |
IMPORTANT INSTRUCTIONS FOR CITATIONS:
|
127 |
1. Use ONLY the exact reference symbols provided (like ¹, ², ³) to cite sources
|
@@ -130,9 +131,8 @@ def gen_prompt(question, content_list, lang="zh-CN", context_length_limit=11000,
|
|
130 |
4. Each citation should correspond to exactly one source
|
131 |
5. Do not use citation symbols that weren't defined in the context
|
132 |
|
133 |
-
|
134 |
-
|
135 |
-
Here are the set of contexts:
|
136 |
''' + "\n\n" + "```"
|
137 |
|
138 |
# 使用 Unicode 上标数字作为引用标记
|
@@ -275,22 +275,15 @@ def ask_internet(query:str, model:str, debug=False):
|
|
275 |
else:
|
276 |
yield response_content
|
277 |
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
site_name = subdomain + "." + domain if subdomain else domain
|
291 |
-
|
292 |
-
# 使用上标数字作为引用编号
|
293 |
-
num = str(i + 1)
|
294 |
-
sup_num = ''.join(superscript_digits.get(c, c) for c in num)
|
295 |
-
|
296 |
-
yield f"{sup_num} [{site_name}]({url})\n"
|
|
|
121 |
}
|
122 |
if len(ref_content) > 0:
|
123 |
prompts = '''
|
124 |
+
You are a large language AI assistant. 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 symbol. 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 |
IMPORTANT INSTRUCTIONS FOR CITATIONS:
|
128 |
1. Use ONLY the exact reference symbols provided (like ¹, ², ³) to cite sources
|
|
|
131 |
4. Each citation should correspond to exactly one source
|
132 |
5. Do not use citation symbols that weren't defined in the context
|
133 |
|
134 |
+
Please cite the contexts with the reference numbers, in the format (like ¹, ², ³) . If a sentence comes from multiple contexts, please list all applicable citations, like(¹ ²). Other than code and specific names and citations, your answer must be written in the same language as the question.
|
135 |
+
Here are the set of contexts:
|
|
|
136 |
''' + "\n\n" + "```"
|
137 |
|
138 |
# 使用 Unicode 上标数字作为引用标记
|
|
|
275 |
else:
|
276 |
yield response_content
|
277 |
|
278 |
+
yield "\n\n"
|
279 |
+
# 是否返回参考资料
|
280 |
+
if True:
|
281 |
+
yield "---"
|
282 |
+
yield "\nSearxng"
|
283 |
+
yield "参考资料:\n"
|
284 |
+
count = 1
|
285 |
+
for url_content in content_list:
|
286 |
+
url = url_content.get('url')
|
287 |
+
yield "*[{}. {}]({})*".format(str(count),url,url )
|
288 |
+
yield "\n"
|
289 |
+
count += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|