1- from fastapi import APIRouter , HTTPException
1+ from fastapi import APIRouter , status
22
3- # from fastapi import status
43from askui .chat .api .assistants .dependencies import AssistantServiceDep
5- from askui .chat .api .assistants .models import Assistant
6- from askui .chat .api .assistants .service import (
7- AssistantService , # AssistantModifyRequest, CreateAssistantRequest,
4+ from askui .chat .api .assistants .models import (
5+ Assistant ,
6+ AssistantCreateParams ,
7+ AssistantModifyParams ,
88)
9- from askui .chat .api .models import ListQueryDep
9+ from askui .chat .api .assistants .service import AssistantService
10+ from askui .chat .api .models import AssistantId , ListQueryDep
1011from askui .utils .api_utils import ListQuery , ListResponse
1112
1213router = APIRouter (prefix = "/assistants" , tags = ["assistants" ])
@@ -17,51 +18,37 @@ def list_assistants(
1718 query : ListQuery = ListQueryDep ,
1819 assistant_service : AssistantService = AssistantServiceDep ,
1920) -> ListResponse [Assistant ]:
20- """List all assistants."""
2121 return assistant_service .list_ (query = query )
2222
2323
24- # @router.post("", status_code=status.HTTP_201_CREATED)
25- # def create_assistant(
26- # request: CreateAssistantRequest,
27- # assistant_service: AssistantService = AssistantServiceDep,
28- # ) -> Assistant:
29- # """Create a new assistant."""
30- # return assistant_service.create(request)
24+ @router .post ("" , status_code = status .HTTP_201_CREATED )
25+ def create_assistant (
26+ params : AssistantCreateParams ,
27+ assistant_service : AssistantService = AssistantServiceDep ,
28+ ) -> Assistant :
29+ return assistant_service .create (params )
3130
3231
3332@router .get ("/{assistant_id}" )
3433def retrieve_assistant (
35- assistant_id : str ,
34+ assistant_id : AssistantId ,
3635 assistant_service : AssistantService = AssistantServiceDep ,
3736) -> Assistant :
38- """Get an assistant by ID."""
39- try :
40- return assistant_service .retrieve (assistant_id )
41- except FileNotFoundError as e :
42- raise HTTPException (status_code = 404 , detail = str (e )) from e
37+ return assistant_service .retrieve (assistant_id )
4338
4439
45- # @router.post("/{assistant_id}")
46- # def modify_assistant(
47- # assistant_id: str,
48- # request: AssistantModifyRequest,
49- # assistant_service: AssistantService = AssistantServiceDep,
50- # ) -> Assistant:
51- # """Update an assistant."""
52- # try:
53- # return assistant_service.modify(assistant_id, request)
54- # except FileNotFoundError as e:
55- # raise HTTPException(status_code=404, detail=str(e)) from e
40+ @router .post ("/{assistant_id}" )
41+ def modify_assistant (
42+ assistant_id : AssistantId ,
43+ params : AssistantModifyParams ,
44+ assistant_service : AssistantService = AssistantServiceDep ,
45+ ) -> Assistant :
46+ return assistant_service .modify (assistant_id , params )
5647
5748
58- # @router.delete("/{assistant_id}", status_code=status.HTTP_204_NO_CONTENT)
59- # def delete_assistant(
60- # assistant_id: str,
61- # assistant_service: AssistantService = AssistantServiceDep,
62- # ) -> None:
63- # """Delete an assistant."""
64- # try:
65- # assistant_service.delete(assistant_id)
66- # except FileNotFoundError as e:
67- # raise HTTPException(status_code=404, detail=str(e)) from e
49+ @router .delete ("/{assistant_id}" , status_code = status .HTTP_204_NO_CONTENT )
50+ def delete_assistant (
51+ assistant_id : AssistantId ,
52+ assistant_service : AssistantService = AssistantServiceDep ,
53+ ) -> None :
54+ assistant_service .delete (assistant_id )
0 commit comments