Spaces:
Sleeping
Sleeping
Create patch.py
Browse files
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)
|