File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 49
49
make compile
50
50
51
51
make html
52
+ python3 wrap_run_llm.py
52
53
cd _build/html
53
54
54
55
git clone https://[email protected] /sgl-project/sgl-project.github.io.git ../sgl-project.github.io --depth 1
Original file line number Diff line number Diff line change
1
+ import os
2
+ import re
3
+
4
+
5
+ def insert_runllm_widget (html_content ):
6
+ # RunLLM Widget script to be inserted
7
+ widget_script = """
8
+ <!-- RunLLM Widget Script -->
9
+ <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>
10
+ """
11
+
12
+ # Find the closing body tag and insert the widget script before it
13
+ return re .sub (r"</body>" , f"{ widget_script } \n </body>" , html_content )
14
+
15
+
16
+ def main ():
17
+ # Get the build directory path
18
+ build_dir = os .path .join (
19
+ os .path .dirname (os .path .abspath (__file__ )), "_build" , "html"
20
+ )
21
+ index_file = os .path .join (build_dir , "index.html" )
22
+
23
+ # Process only index.html
24
+ if os .path .exists (index_file ):
25
+ # Read the HTML file
26
+ with open (index_file , "r" , encoding = "utf-8" ) as f :
27
+ content = f .read ()
28
+
29
+ # Insert the RunLLM widget
30
+ modified_content = insert_runllm_widget (content )
31
+
32
+ # Write back the modified content
33
+ with open (index_file , "w" , encoding = "utf-8" ) as f :
34
+ f .write (modified_content )
35
+ else :
36
+ print (f"Index file not found: { index_file } " )
37
+
38
+
39
+ if __name__ == "__main__" :
40
+ main ()
You can’t perform that action at this time.
0 commit comments