File size: 2,524 Bytes
c7426d8
 
 
 
 
 
f06d4d5
c7426d8
 
 
 
 
 
 
 
 
 
 
 
 
 
e3a12d5
 
 
 
 
 
 
 
 
 
 
 
 
c7426d8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1031c5b
c7426d8
 
 
1031c5b
c7426d8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
"""Module for defining the main routes of the API."""
from fastapi import APIRouter
from fastapi.responses import StreamingResponse
from schema import ReqData
from utils import generate

router = APIRouter(tags=["content"])

@router.post("/stream")
async def stream(query: ReqData):
    """
    Handles streaming of data based on the provided query.

    Args:
        query (ReqData): The request data containing the query parameters.

    Returns:
        StreamingResponse: A streaming response with generated data with type 'text/event-stream'.
    """
    return StreamingResponse(generate(query), media_type='text/event-stream')

# @router.post("/list")
# def chat(query: ReqData):
#     """
#     Handles the chat POST request.

#     Args:
#         query (ReqData): The request data containing the query parameters.

#     Returns:
#         str: The generated response from the chat function.
#     """
#     return generate(query)

# # @router.post("/followup")
# # def follow_up(req: ReqFollowUp):
# #     """
# #     Handles the follow-up POST request.

# #     Args:
# #         req (ReqFollowUp): The request object containing follow-up data.

# #     Returns:
# #         Response: The response from the follow-up processing function.
# #     """
# #     return followup(req)

# @router.post("/chat/history")
# def retrieve_history(chat_history: ChatHistory):
#     """
#     Endpoint to retrieve chat history.

#     This endpoint handles POST requests to the "/chat/history" URL. It accepts a
#     ChatHistory object as input and returns the chat history.

#     Args:
#         chat_history (ChatHistory): The chat history object containing the details
#         of the chat to be retrieved.

#     Returns:
#         The chat history retrieved by the retrieve_chat_history function.
#     """
#     return get_chat_history(chat_history)

# @router.post("/chat/session")
# def retrieve_session(chat_session: ChatSession):
#     """
#     Retrieve a chat session.

#     Args:
#         chat_session (ChatSession): The chat session to retrieve.

#     Returns:
#         ChatSession: The retrieved chat session.
#     """
#     return get_chat_session(chat_session)

# @router.post("/chat/history/clear")
# def clear_history(chat_history: ChatHistory):
#     """
#     Clears the chat history.

#     Args:
#         chat_history (ChatHistory): The chat history object to be cleared.

#     Returns:
#         The result of the clear_chat_history function.
#     """
#     return clear_chat(chat_history)