3 Star 7 Fork 6

Gitee 极速下载/sglang

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/sgl-project/sglang
克隆/下载
wrap_run_llm.py 1.52 KB
一键复制 编辑 原始数据 按行查看 历史
renxin 提交于 2025-04-04 12:20 +08:00 . Feature/revise docs ci (#5056)
import os
import re
def insert_runllm_widget(html_content):
# RunLLM Widget script to be inserted
widget_script = """
<!-- RunLLM Widget Script -->
<script type="module" id="runllm-widget-script" src="https://widget.runllm.com" crossorigin="true" version="stable" runllm-keyboard-shortcut="Mod+j" runllm-name="SGLang Chatbot" runllm-position="BOTTOM_RIGHT" runllm-assistant-id="629" async></script>
"""
# Find the closing body tag and insert the widget script before it
return re.sub(r"</body>", f"{widget_script}\n</body>", html_content)
def process_html_files(build_dir):
for root, dirs, files in os.walk(build_dir):
for file in files:
if file.endswith(".html"):
file_path = os.path.join(root, file)
# Read the HTML file
with open(file_path, "r", encoding="utf-8") as f:
content = f.read()
# Insert the RunLLM widget
modified_content = insert_runllm_widget(content)
# Write back the modified content
with open(file_path, "w", encoding="utf-8") as f:
f.write(modified_content)
def main():
# Get the build directory path
build_dir = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "_build", "html"
)
# Process all HTML files
if os.path.exists(build_dir):
process_html_files(build_dir)
else:
print(f"Build directory not found: {build_dir}")
if __name__ == "__main__":
main()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/mirrors/sglang.git
git@gitee.com:mirrors/sglang.git
mirrors
sglang
sglang
main

搜索帮助