Skip to content

Agent Zero AI framework

supress warnings, test connectivity on start

frdelcc3f02e16372
diff --git a/preload.py b/preload.py
index c3110a837..8ba415fa7 100644
--- a/preload.py
+++ b/preload.py
@@ -45,7 +45,7 @@ async def preload():
]
await asyncio.gather(*tasks, return_exceptions=True)
- PrintStyle().print("Preload completed")
+ PrintStyle().print("Preload completed.")
except Exception as e:
PrintStyle().error(f"Error in preload: {e}")
diff --git a/python/helpers/faiss_monkey_patch.py b/python/helpers/faiss_monkey_patch.py
index 7eeaf0867..5704b84f3 100644
--- a/python/helpers/faiss_monkey_patch.py
+++ b/python/helpers/faiss_monkey_patch.py
@@ -33,4 +33,7 @@ sys.modules["numpy.distutils.cpuinfo"] = cpuinfo
np.distutils = dist # type: ignore
# -------------------------------------------------------------------
-import faiss
\ No newline at end of file
+import warnings
+with warnings.catch_warnings():
+ warnings.simplefilter("ignore", DeprecationWarning)
+ import faiss
\ No newline at end of file
diff --git a/run_ui.py b/run_ui.py
index 93b259c62..5ddeb91fe 100644
--- a/run_ui.py
+++ b/run_ui.py
@@ -8,6 +8,8 @@ from functools import wraps
import threading
import asyncio
+import urllib.request
+import urllib.error
import uvicorn
from flask import Flask, request, Response, session, redirect, url_for, render_template_string
from werkzeug.wrappers.response import Response as BaseResponse
@@ -517,12 +519,26 @@ def run():
process.set_server(_UvicornServerWrapper(server))
PrintStyle().debug(f"Starting server at http://{host}:{port} ...")
+ threading.Thread(target=wait_for_health, args=(host, port), daemon=True).start()
try:
server.run()
finally:
_run_flush("server_exit")
+def wait_for_health(host: str, port: int):
+ url = f"http://{host}:{port}/health"
+ while True:
+ try:
+ with urllib.request.urlopen(url, timeout=2) as resp:
+ if resp.status == 200:
+ PrintStyle().print("Agent Zero is running.")
+ return
+ except Exception:
+ pass
+ time.sleep(1)
+
+
def init_a0():
# initialize contexts and MCP
init_chats = initialize.initialize_chats()