
    Ti	                     4   d dl mZmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
  ed      Zej                  d      d	efd
       Zej                  d      defd       Zej                  d      d	efd       Zej                  d      dede
eef   fd       Zy)    )	APIRouterRequest)handle_chat)handle_magic)get_stream_task)Dictz/api)prefixz/chatrequestc                 p   K   | j                          d{   }t        |       d{    ddiS 7 7 
w)a  
    Endpoint to handle chat requests.

    Receives a JSON payload from the client, passes it to the chat handler,
    and returns a success status.

    Request body:
        JSON object containing chat data.

    Response:
        {"status": "done"}
    Nstatusdone)jsonr   r
   datas     M/home/jay/workspace/tools/ai-image-gen/jaaz-app/server/routers/chat_router.pychatr   
   s8      D
d
f     6264	66z/cancel/{session_id}
session_idc                 t   K   t        |       }|r$|j                         s|j                          ddiS ddiS w)a  
    Endpoint to cancel an ongoing stream task for a given session_id.

    If the task exists and is not yet completed, it will be cancelled.

    Path parameter:
        session_id (str): The ID of the session whose task should be cancelled.

    Response:
        {"status": "cancelled"} if the task was cancelled.
        {"status": "not_found_or_done"} if no such task exists or it is already done.
    r   	cancellednot_found_or_doner   r   cancelr   tasks     r   cancel_chatr      =      :&DDIIK+&&)**   68z/magicc                 p   K   | j                          d{   }t        |       d{    ddiS 7 7 
w)a  
    Endpoint to handle magic generation requests.

    Receives a JSON payload from the client, passes it to the magic handler,
    and returns a success status.

    Request body:
        JSON object containing magic generation data.

    Response:
        {"status": "done"}
    Nr   r   )r   r   r   s     r   magicr    0   s8      D
t
f  r   z/magic/cancel/{session_id}returnc                 t   K   t        |       }|r$|j                         s|j                          ddiS ddiS w)a  
    Endpoint to cancel an ongoing magic generation task for a given session_id.

    If the task exists and is not yet completed, it will be cancelled.

    Path parameter:
        session_id (str): The ID of the session whose task should be cancelled.

    Response:
        {"status": "cancelled"} if the task was cancelled.
        {"status": "not_found_or_done"} if no such task exists or it is already done.
    r   r   r   r   r   s     r   cancel_magicr#   B   r   r   N)fastapir   r   services.chat_servicer   services.magic_servicer   services.stream_servicer   typingr   routerpostr   strr   r    r#        r   <module>r.      s    & - / 3 	&	!W  " #$+# + %+& X  " )*+3 +4S> + ++r-   