Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,6 @@ import logging
|
|
| 3 |
import os
|
| 4 |
import multiprocessing
|
| 5 |
|
| 6 |
-
# Configure logging
|
| 7 |
logging.basicConfig(level=logging.INFO)
|
| 8 |
logger = logging.getLogger(__name__)
|
| 9 |
|
|
@@ -81,10 +80,20 @@ if __name__ == "__main__":
|
|
| 81 |
multiprocessing.set_start_method("spawn", force=True)
|
| 82 |
|
| 83 |
from txagent import TxAgent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
from importlib.resources import files
|
| 85 |
-
from patched_tooluniverse import PatchedToolUniverse
|
| 86 |
|
| 87 |
-
logger.info("🔥 Initializing patched TxAgent with
|
| 88 |
|
| 89 |
tool_files = {
|
| 90 |
"opentarget": str(files('tooluniverse.data').joinpath('opentarget_tools.json')),
|
|
@@ -110,8 +119,7 @@ if __name__ == "__main__":
|
|
| 110 |
seed=42,
|
| 111 |
enable_checker=True,
|
| 112 |
enable_chat=False,
|
| 113 |
-
additional_default_tools=["DirectResponse", "RequireClarification"]
|
| 114 |
-
tooluniverse_class=PatchedToolUniverse # ✅ Custom patch!
|
| 115 |
)
|
| 116 |
|
| 117 |
if not os.path.exists(TOOL_CACHE_PATH):
|
|
@@ -120,4 +128,4 @@ if __name__ == "__main__":
|
|
| 120 |
with open(TOOL_CACHE_PATH, "w") as f:
|
| 121 |
f.write("done")
|
| 122 |
else:
|
| 123 |
-
tx_app.init_model(skip_tool_embedding=True)
|
|
|
|
| 3 |
import os
|
| 4 |
import multiprocessing
|
| 5 |
|
|
|
|
| 6 |
logging.basicConfig(level=logging.INFO)
|
| 7 |
logger = logging.getLogger(__name__)
|
| 8 |
|
|
|
|
| 80 |
multiprocessing.set_start_method("spawn", force=True)
|
| 81 |
|
| 82 |
from txagent import TxAgent
|
| 83 |
+
import tooluniverse.universe as universe_mod
|
| 84 |
+
|
| 85 |
+
# === Patch ToolUniverse.infer_tool_embeddings to prevent exit ===
|
| 86 |
+
original_infer = universe_mod.ToolUniverse.infer_tool_embeddings
|
| 87 |
+
|
| 88 |
+
def patched_infer(self, *args, **kwargs):
|
| 89 |
+
original_infer(self, *args, **kwargs)
|
| 90 |
+
print("✅ Patched: Skipping forced exit() after embedding.")
|
| 91 |
+
|
| 92 |
+
universe_mod.ToolUniverse.infer_tool_embeddings = patched_infer
|
| 93 |
+
|
| 94 |
from importlib.resources import files
|
|
|
|
| 95 |
|
| 96 |
+
logger.info("🔥 Initializing patched TxAgent with embedding skip (manual patch)")
|
| 97 |
|
| 98 |
tool_files = {
|
| 99 |
"opentarget": str(files('tooluniverse.data').joinpath('opentarget_tools.json')),
|
|
|
|
| 119 |
seed=42,
|
| 120 |
enable_checker=True,
|
| 121 |
enable_chat=False,
|
| 122 |
+
additional_default_tools=["DirectResponse", "RequireClarification"]
|
|
|
|
| 123 |
)
|
| 124 |
|
| 125 |
if not os.path.exists(TOOL_CACHE_PATH):
|
|
|
|
| 128 |
with open(TOOL_CACHE_PATH, "w") as f:
|
| 129 |
f.write("done")
|
| 130 |
else:
|
| 131 |
+
tx_app.init_model(skip_tool_embedding=True)
|