mikeee's picture
Create patch.py
0c250f4 verified
raw
history blame
443 Bytes
import re
import sys
from pathlib import Path
# patch open-text-embeddings server/app.py: {"device": device} => {"device": device, "trust_remote_code": True}
filepath = [elm for elm in Path(sys.exec_prefix).rglob("app.py") if elm.as_posix().endswith("server/app.py")][0]
patched_app_py = re.sub(r'\{"device": device\}', '{"device": device, "trust_remote_code": True}', filepath.read_text())
# write back
filepath.write_text(patched_app_py)