Skip to content

Commit 136bda3

Browse files
authored
adds option to add external information sources like model callbacks (#6)
1 parent a84c439 commit 136bda3

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

app.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,31 @@ async def post_import(request: Request, project_id: str):
7575
return responses.JSONResponse(status_code=status.HTTP_200_OK, content=resp.json())
7676

7777

78+
@app.post("/project/{project_id}/associations")
79+
async def post_associations(request: Request, project_id: str):
80+
try:
81+
user_id = get_user_id_from_request(request)
82+
except KeyError:
83+
return responses.JSONResponse(
84+
status_code=status.HTTP_401_UNAUTHORIZED,
85+
content={"error_code": ErrorCodes.UNRECOGNIZED_USER},
86+
)
87+
request_body = await request.json()
88+
url = f"{BASE_URI}/project/{project_id}/associations"
89+
resp = requests.post(
90+
url,
91+
json={
92+
"user_id": user_id,
93+
"associations": request_body["associations"],
94+
"indices": request_body["indices"],
95+
"name": request_body["name"],
96+
"label_task_name": request_body["label_task_name"],
97+
"source_type": request_body["source_type"],
98+
},
99+
)
100+
return responses.JSONResponse(status_code=status.HTTP_200_OK, content=resp.json())
101+
102+
78103
@app.get("/project/{project_id}")
79104
def get_details(request: Request, project_id: str):
80105
try:

0 commit comments

Comments
 (0)