mikeee commited on
Commit
0c250f4
·
verified ·
1 Parent(s): 10ec6c2

Create patch.py

Browse files
Files changed (1) hide show
  1. patch.py +11 -0
patch.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ import sys
3
+ from pathlib import Path
4
+
5
+ # patch open-text-embeddings server/app.py: {"device": device} => {"device": device, "trust_remote_code": True}
6
+ filepath = [elm for elm in Path(sys.exec_prefix).rglob("app.py") if elm.as_posix().endswith("server/app.py")][0]
7
+
8
+ patched_app_py = re.sub(r'\{"device": device\}', '{"device": device, "trust_remote_code": True}', filepath.read_text())
9
+
10
+ # write back
11
+ filepath.write_text(patched_app_py)