MCPcopy Index your code
hub / github.com/AstrBotDevs/AstrBot / _open_api_chat_response

Function _open_api_chat_response

astrbot/dashboard/api/open_api.py:88–125  ·  view source on GitHub ↗
(
    post_data: dict[str, Any],
    auth: AuthContext,
    open_api_service: OpenApiService,
    chat_service: ChatService,
)

Source from the content-addressed store, hash-verified

86
87
88async def _open_api_chat_response(
89 post_data: dict[str, Any],
90 auth: AuthContext,
91 open_api_service: OpenApiService,
92 chat_service: ChatService,
93) -> StreamingResponse | JSONResponse:
94 if auth.via != "api_key":
95 return await _build_streaming_chat_response(
96 chat_service,
97 auth.username,
98 post_data,
99 )
100
101 try:
102 (
103 effective_username,
104 session_id,
105 config_id,
106 ) = await open_api_service.prepare_chat_send(
107 post_data,
108 _get_chat_config_list(open_api_service),
109 )
110 except OpenApiServiceError as exc:
111 return _open_api_error(str(exc))
112
113 config_err = await open_api_service.update_session_config_route(
114 username=effective_username,
115 session_id=session_id,
116 config_id=config_id,
117 )
118 if config_err:
119 return _open_api_error(config_err)
120
121 return await _build_streaming_chat_response(
122 chat_service,
123 effective_username,
124 post_data,
125 )
126
127
128async def _insert_webchat_user_message(

Callers 1

chatFunction · 0.85

Calls 5

_get_chat_config_listFunction · 0.85
_open_api_errorFunction · 0.85
prepare_chat_sendMethod · 0.80

Tested by

no test coverage detected