Upload main.py with huggingface_hub
Browse files
main.py
CHANGED
|
@@ -1,13 +1,20 @@
|
|
| 1 |
-
from fastapi import FastAPI
|
| 2 |
-
from explain_error import explain_error
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from explain_error import explain_error
|
| 3 |
+
from langchain_rag import get_rag_chain
|
| 4 |
+
|
| 5 |
+
app = FastAPI()
|
| 6 |
+
|
| 7 |
+
@app.get("/")
|
| 8 |
+
def home():
|
| 9 |
+
return {"message": "Jenkins Error Explainer API running"}
|
| 10 |
+
|
| 11 |
+
@app.post("/explain")
|
| 12 |
+
def explain(payload: dict):
|
| 13 |
+
log = payload["log_text"]
|
| 14 |
+
return explain_error(log)
|
| 15 |
+
|
| 16 |
+
@app.post("/explain-rag")
|
| 17 |
+
def explain_with_rag(payload: dict):
|
| 18 |
+
log = payload["log_text"]
|
| 19 |
+
rag_chain = get_rag_chain()
|
| 20 |
+
return rag_chain.explain_error(log)
|