Skip to content

Commit 724e887

Browse files
authored
refactor(api): add user Depends for list api (#766)
* refactor(rag): update rag params * refactor(api): add user Depends for list api
1 parent dd2d8cb commit 724e887

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

server/rag/router.py

+24-3
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,14 @@ async def reload_repo(
7575

7676

7777
@router.post("/knowledge/list", dependencies=[Depends(verify_rate_limit)])
78-
async def get_knowledge_list(params: PageParams[Knowledge]):
78+
async def get_knowledge_list(
79+
params: PageParams[Knowledge],
80+
user: Annotated[User | None, Depends(get_user)] = None,
81+
):
82+
if user is None:
83+
raise HTTPException(
84+
status_code=status.HTTP_401_UNAUTHORIZED, detail="Github Login needed"
85+
)
7986
try:
8087
api_client = APIClient(
8188
base_url=get_env_variable("WHISKER_API_URL"),
@@ -101,7 +108,14 @@ async def get_chunk_list(params: PageParams[Chunk]):
101108

102109

103110
@router.post("/task/list", dependencies=[Depends(verify_rate_limit)])
104-
async def get_rag_task(params: PageParams[Task]):
111+
async def get_rag_task(
112+
params: PageParams[Task],
113+
user: Annotated[User | None, Depends(get_user)] = None,
114+
):
115+
if user is None:
116+
raise HTTPException(
117+
status_code=status.HTTP_401_UNAUTHORIZED, detail="Github Login needed"
118+
)
105119
try:
106120
api_client = APIClient(
107121
base_url=get_env_variable("WHISKER_API_URL"),
@@ -114,7 +128,14 @@ async def get_rag_task(params: PageParams[Task]):
114128

115129

116130
@router.post("/task/restart", dependencies=[Depends(verify_rate_limit)])
117-
async def restart_rag_task(params: RestartTaskRequest):
131+
async def restart_rag_task(
132+
params: RestartTaskRequest,
133+
user: Annotated[User | None, Depends(get_user)] = None,
134+
):
135+
if user is None:
136+
raise HTTPException(
137+
status_code=status.HTTP_401_UNAUTHORIZED, detail="Github Login needed"
138+
)
118139
try:
119140
api_client = APIClient(
120141
base_url=get_env_variable("WHISKER_API_URL"),

0 commit comments

Comments
 (0)