agent / patches /api /api_docs.py
GraziePrego's picture
Fix patches/api/api_docs.py and start script resiliency
56438ff verified
Raw
History Blame Contribute Delete
897 Bytes
import os
import threading
from typing import Any
from flask import Flask
class ApiDocs:
def __init__(self, webapp: Flask, lock: threading.RLock) -> None:
self.webapp = webapp
self.lock = lock
async def process(self, data: dict[str, Any], request: Any) -> dict[str, Any]:
endpoints = []
for rule in self.webapp.url_map.iter_rules():
if rule.rule.startswith("/api/"):
methods = ",".join(m for m in rule.methods if m not in ["OPTIONS", "HEAD"])
endpoints.append({
"path": rule.rule,
"methods": methods,
"endpoint": rule.endpoint
})
return {
"title": "Agent-Zero API Documentation",
"version": "1.0.0",
"hf_space": os.getenv("HF_SPACE") == "true",
"endpoints": endpoints
}