diff --git a/.github/workflows/release-docs.yml b/.github/workflows/release-docs.yml index 1af140e5509..cb92a27fbdb 100644 --- a/.github/workflows/release-docs.yml +++ b/.github/workflows/release-docs.yml @@ -49,6 +49,7 @@ jobs: make compile make html + python3 wrap_run_llm.py cd _build/html git clone https://$GITHUB_TOKEN@github.com/sgl-project/sgl-project.github.io.git ../sgl-project.github.io --depth 1 diff --git a/docs/wrap_run_llm.py b/docs/wrap_run_llm.py new file mode 100644 index 00000000000..0d0fe8b250a --- /dev/null +++ b/docs/wrap_run_llm.py @@ -0,0 +1,40 @@ +import os +import re + + +def insert_runllm_widget(html_content): + # RunLLM Widget script to be inserted + widget_script = """ + + + """ + + # Find the closing body tag and insert the widget script before it + return re.sub(r"", f"{widget_script}\n", html_content) + + +def main(): + # Get the build directory path + build_dir = os.path.join( + os.path.dirname(os.path.abspath(__file__)), "_build", "html" + ) + index_file = os.path.join(build_dir, "index.html") + + # Process only index.html + if os.path.exists(index_file): + # Read the HTML file + with open(index_file, "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(index_file, "w", encoding="utf-8") as f: + f.write(modified_content) + else: + print(f"Index file not found: {index_file}") + + +if __name__ == "__main__": + main()