mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-05-10 20:29:42 +00:00
BIG PYTHON REFACTOR
Python scripts moved out of python/ folder to root to be unified with plugins + frontend extension around api calls
This commit is contained in:
parent
f94b7d742c
commit
d02dda3667
326 changed files with 1096 additions and 862 deletions
|
|
@ -1,38 +0,0 @@
|
|||
from python.helpers.api import ApiHandler, Request, Response
|
||||
from python.helpers import dotenv, runtime
|
||||
from python.helpers.tunnel_manager import TunnelManager
|
||||
import requests
|
||||
|
||||
|
||||
class TunnelProxy(ApiHandler):
|
||||
async def process(self, input: dict, request: Request) -> dict | Response:
|
||||
return await process(input)
|
||||
|
||||
async def process(input: dict) -> dict | Response:
|
||||
# Get configuration from environment
|
||||
tunnel_api_port = (
|
||||
runtime.get_arg("tunnel_api_port")
|
||||
or int(dotenv.get_dotenv_value("TUNNEL_API_PORT", 0))
|
||||
or 55520
|
||||
)
|
||||
|
||||
# first verify the service is running:
|
||||
service_ok = False
|
||||
try:
|
||||
response = requests.post(f"http://localhost:{tunnel_api_port}/", json={"action": "health"})
|
||||
if response.status_code == 200:
|
||||
service_ok = True
|
||||
except Exception as e:
|
||||
service_ok = False
|
||||
|
||||
# forward this request to the tunnel service if OK
|
||||
if service_ok:
|
||||
try:
|
||||
response = requests.post(f"http://localhost:{tunnel_api_port}/", json=input)
|
||||
return response.json()
|
||||
except Exception as e:
|
||||
return {"error": str(e)}
|
||||
else:
|
||||
# forward to API handler directly
|
||||
from python.api.tunnel import process as local_process
|
||||
return await local_process(input)
|
||||
Loading…
Add table
Add a link
Reference in a new issue