File size: 1,042 Bytes
ca39b28 37e7757 ca39b28 37e7757 ca39b28 37e7757 ca39b28 37e7757 ca39b28 37e7757 ca39b28 37e7757 ca39b28 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
from fastapi import FastAPI, Body
app = FastAPI(title="Python_ai")
@app.get("/health")
def health():
return {"ok": True}
@app.post("/code_help")
def code_help(payload: dict = Body(...)):
# Trivial fixer: rename "reslt" -> "result" if present
viewport = payload.get("telemetry", {}).get("viewport", {})
text = viewport.get("text", "")
if "reslt" in text and "result" not in text:
patch = text.replace("reslt", "result")
return {
"mode": "patch",
"patch": f"--- a/main.py\n+++ b/main.py\n@@ -1 +1 @@\n-{text}\n\n+{patch}\n\n",
"full_text": "",
"explanation": "Fixed misspelling 'reslt' -> 'result'.",
"confidence": 0.95,
"need": {"function": False, "xrefs": [], "page_ids": []},
}
# Default no-op
return {
"mode": "patch",
"patch": "",
"full_text": "",
"explanation": "No obvious fix.",
"confidence": 0.5,
"need": {"function": False, "xrefs": [], "page_ids": []},
} |