MCPcopy
hub / github.com/AstrBotDevs/AstrBot / _send_chat

Function _send_chat

astrbot/dashboard/api/chat.py:83–107  ·  view source on GitHub ↗
(
    *,
    request: Request,
    username: str,
    service: ChatService,
    payload: dict[str, Any] | None = None,
)

Source from the content-addressed store, hash-verified

81
82
83async def _send_chat(
84 *,
85 request: Request,
86 username: str,
87 service: ChatService,
88 payload: dict[str, Any] | None = None,
89):
90 post_data = payload if payload is not None else await _json_or_none(request)
91 if post_data is None:
92 return JSONResponse(error("Missing JSON body"))
93
94 try:
95 stream = await service.build_chat_stream(username, post_data)
96 except ChatServiceError as exc:
97 return JSONResponse(error(str(exc)))
98
99 return StreamingResponse(
100 stream,
101 media_type="text/event-stream",
102 headers={
103 "Cache-Control": "no-cache",
104 "Transfer-Encoding": "chunked",
105 "Connection": "keep-alive",
106 },
107 )
108
109
110@router.get("/chat/sessions/new")

Callers 5

regenerate_chat_messageFunction · 0.85
send_chat_thread_messageFunction · 0.85
dashboard_send_chatFunction · 0.85

Calls 3

errorFunction · 0.90
_json_or_noneFunction · 0.85
build_chat_streamMethod · 0.80

Tested by

no test coverage detected