Spaces:
Sleeping
Sleeping
Keldos
commited on
Commit
·
56baa88
1
Parent(s):
acab1c6
refactor: 改为新标签页中打开引用网页
Browse files- modules/base_model.py +3 -2
- modules/utils.py +11 -11
modules/base_model.py
CHANGED
@@ -245,10 +245,11 @@ class BaseLLMModel:
|
|
245 |
domain_name = urllib3.util.parse_url(result["href"]).host
|
246 |
reference_results.append([result["body"], result["href"]])
|
247 |
display_append.append(
|
248 |
-
f"{idx+1}. [{domain_name}]({result['href']})\n"
|
|
|
249 |
)
|
250 |
reference_results = add_source_numbers(reference_results)
|
251 |
-
display_append = "
|
252 |
real_inputs = (
|
253 |
replace_today(WEBSEARCH_PTOMPT_TEMPLATE)
|
254 |
.replace("{query}", real_inputs)
|
|
|
245 |
domain_name = urllib3.util.parse_url(result["href"]).host
|
246 |
reference_results.append([result["body"], result["href"]])
|
247 |
display_append.append(
|
248 |
+
# f"{idx+1}. [{domain_name}]({result['href']})\n"
|
249 |
+
f"<li><a href=\"{result['href']}\" target=\"_blank\">{domain_name}</a></li>\n"
|
250 |
)
|
251 |
reference_results = add_source_numbers(reference_results)
|
252 |
+
display_append = "<ol>\n\n" + "".join(display_append) + "</ol>"
|
253 |
real_inputs = (
|
254 |
replace_today(WEBSEARCH_PTOMPT_TEMPLATE)
|
255 |
.replace("{query}", real_inputs)
|
modules/utils.py
CHANGED
@@ -451,11 +451,11 @@ Error code: {result.returncode}""")
|
|
451 |
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, env=os.environ if custom_env is None else custom_env)
|
452 |
if result.returncode != 0:
|
453 |
message = f"""{errdesc or 'Error running command'}.
|
454 |
-
Command: {command}
|
455 |
-
Error code: {result.returncode}
|
456 |
-
stdout: {result.stdout.decode(encoding="utf8", errors="ignore") if len(result.stdout)>0 else '<empty>'}
|
457 |
-
stderr: {result.stderr.decode(encoding="utf8", errors="ignore") if len(result.stderr)>0 else '<empty>'}
|
458 |
-
"""
|
459 |
raise RuntimeError(message)
|
460 |
return result.stdout.decode(encoding="utf8", errors="ignore")
|
461 |
|
@@ -472,12 +472,12 @@ def versions_html():
|
|
472 |
else:
|
473 |
commit_info = "unknown \U0001F615"
|
474 |
return f"""
|
475 |
-
Python: <span title="{sys.version}">{python_version}</span>
|
476 |
-
|
477 |
-
Gradio: {gr.__version__}
|
478 |
-
|
479 |
-
Commit: {commit_info}
|
480 |
-
"""
|
481 |
|
482 |
def add_source_numbers(lst, source_name = "Source", use_source = True):
|
483 |
if use_source:
|
|
|
451 |
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, env=os.environ if custom_env is None else custom_env)
|
452 |
if result.returncode != 0:
|
453 |
message = f"""{errdesc or 'Error running command'}.
|
454 |
+
Command: {command}
|
455 |
+
Error code: {result.returncode}
|
456 |
+
stdout: {result.stdout.decode(encoding="utf8", errors="ignore") if len(result.stdout)>0 else '<empty>'}
|
457 |
+
stderr: {result.stderr.decode(encoding="utf8", errors="ignore") if len(result.stderr)>0 else '<empty>'}
|
458 |
+
"""
|
459 |
raise RuntimeError(message)
|
460 |
return result.stdout.decode(encoding="utf8", errors="ignore")
|
461 |
|
|
|
472 |
else:
|
473 |
commit_info = "unknown \U0001F615"
|
474 |
return f"""
|
475 |
+
Python: <span title="{sys.version}">{python_version}</span>
|
476 |
+
•
|
477 |
+
Gradio: {gr.__version__}
|
478 |
+
•
|
479 |
+
Commit: {commit_info}
|
480 |
+
"""
|
481 |
|
482 |
def add_source_numbers(lst, source_name = "Source", use_source = True):
|
483 |
if use_source:
|