Spaces:
Runtime error
Runtime error
Elizabeth Thomas commited on
Commit ·
a44cc8f
1
Parent(s): a61f99d
Initial commit
Browse files- Dockerfile +11 -0
- __pycache__/main.cpython-310.pyc +0 -0
- main.py +34 -0
- requirements.txt +3 -0
Dockerfile
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.9
|
| 2 |
+
|
| 3 |
+
WORKDIR /code
|
| 4 |
+
|
| 5 |
+
COPY ./requirements.txt /code/requirements.txt
|
| 6 |
+
|
| 7 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 8 |
+
|
| 9 |
+
COPY . .
|
| 10 |
+
|
| 11 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
__pycache__/main.cpython-310.pyc
ADDED
|
Binary file (1.26 kB). View file
|
|
|
main.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import httpx
|
| 2 |
+
import ray
|
| 3 |
+
|
| 4 |
+
from fastapi import FastAPI, Request
|
| 5 |
+
from fastapi.responses import JSONResponse
|
| 6 |
+
|
| 7 |
+
app = FastAPI()
|
| 8 |
+
headers = {
|
| 9 |
+
"Content-Type": "application/json"
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
async def handle_webhook(request: Request):
|
| 13 |
+
data = await request.json()
|
| 14 |
+
if "pull_request" in data.keys() and (
|
| 15 |
+
data["action"] in ["opened", "reopened"]
|
| 16 |
+
): # use "synchronize" for tracking new commits
|
| 17 |
+
pr = data.get("pull_request")
|
| 18 |
+
|
| 19 |
+
# Greet the user and show instructions.
|
| 20 |
+
async with httpx.AsyncClient() as client:
|
| 21 |
+
await client.post(
|
| 22 |
+
f"{pr['issue_url']}/comments",
|
| 23 |
+
json={"body": "Hello from code review assistant"},
|
| 24 |
+
headers=headers,
|
| 25 |
+
)
|
| 26 |
+
return JSONResponse(content={}, status_code=200)
|
| 27 |
+
|
| 28 |
+
@app.get("/")
|
| 29 |
+
async def root():
|
| 30 |
+
return {"message": "Code review assistant reporting for duty!"}
|
| 31 |
+
|
| 32 |
+
@app.post("/webhook/")
|
| 33 |
+
async def handle_webhook_route(request: Request):
|
| 34 |
+
return await handle_webhook(request)
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi
|
| 2 |
+
uvicorn
|
| 3 |
+
httpx
|