Spaces:
Runtime error
Runtime error
Update api_backend.py
Browse files- api_backend.py +10 -7
api_backend.py
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
|
|
| 1 |
from fastapi import FastAPI, UploadFile, Form
|
| 2 |
from fastapi.responses import JSONResponse
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
app = FastAPI(title="Omniscient Backend API")
|
| 8 |
|
| 9 |
-
# ─── Health Check ─────────────────────────────────────────────
|
| 10 |
@app.get("/health")
|
| 11 |
def health():
|
| 12 |
return JSONResponse({"ok": True, "message": "Omniscient backend alive"})
|
| 13 |
|
| 14 |
-
# ─── File Summarization ───────────────────────────────────────
|
| 15 |
@app.post("/summarize")
|
| 16 |
async def summarize(file: UploadFile):
|
| 17 |
try:
|
|
@@ -21,7 +26,6 @@ async def summarize(file: UploadFile):
|
|
| 21 |
except Exception as e:
|
| 22 |
return {"error": str(e)}
|
| 23 |
|
| 24 |
-
# ─── Log Normalization & Search ───────────────────────────────
|
| 25 |
@app.post("/analyze-log")
|
| 26 |
async def analyze_log(file: UploadFile, query: str = Form(None)):
|
| 27 |
try:
|
|
@@ -39,7 +43,6 @@ async def analyze_log(file: UploadFile, query: str = Form(None)):
|
|
| 39 |
except Exception as e:
|
| 40 |
return {"error": str(e)}
|
| 41 |
|
| 42 |
-
# ─── Script Documentation Generator ──────────────────────────
|
| 43 |
@app.post("/generate-doc")
|
| 44 |
async def gen_doc(file: UploadFile):
|
| 45 |
try:
|
|
|
|
| 1 |
+
import sys, os
|
| 2 |
from fastapi import FastAPI, UploadFile, Form
|
| 3 |
from fastapi.responses import JSONResponse
|
| 4 |
+
|
| 5 |
+
# Ensure omniscientframework/ is importable
|
| 6 |
+
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
| 7 |
+
if ROOT not in sys.path:
|
| 8 |
+
sys.path.insert(0, ROOT)
|
| 9 |
+
|
| 10 |
+
from omniscientframework.utils.summarizer import summarize_text
|
| 11 |
+
from omniscientframework.utils.file_utils import normalize_log_line, keyword_search
|
| 12 |
+
from omniscientframework.utils.docgen import generate_doc
|
| 13 |
|
| 14 |
app = FastAPI(title="Omniscient Backend API")
|
| 15 |
|
|
|
|
| 16 |
@app.get("/health")
|
| 17 |
def health():
|
| 18 |
return JSONResponse({"ok": True, "message": "Omniscient backend alive"})
|
| 19 |
|
|
|
|
| 20 |
@app.post("/summarize")
|
| 21 |
async def summarize(file: UploadFile):
|
| 22 |
try:
|
|
|
|
| 26 |
except Exception as e:
|
| 27 |
return {"error": str(e)}
|
| 28 |
|
|
|
|
| 29 |
@app.post("/analyze-log")
|
| 30 |
async def analyze_log(file: UploadFile, query: str = Form(None)):
|
| 31 |
try:
|
|
|
|
| 43 |
except Exception as e:
|
| 44 |
return {"error": str(e)}
|
| 45 |
|
|
|
|
| 46 |
@app.post("/generate-doc")
|
| 47 |
async def gen_doc(file: UploadFile):
|
| 48 |
try:
|