| 7 | |
| 8 | |
| 9 | async def initialize_request_context( |
| 10 | req_id: str, request: ChatCompletionRequest |
| 11 | ) -> RequestContext: |
| 12 | from api_utils.server_state import state |
| 13 | |
| 14 | set_request_id(req_id) |
| 15 | state.logger.debug( |
| 16 | f"[Request] Parameters: Model={request.model}, Stream={request.stream}" |
| 17 | ) |
| 18 | |
| 19 | context: RequestContext = cast( |
| 20 | RequestContext, |
| 21 | { |
| 22 | "logger": state.logger, |
| 23 | "page": state.page_instance, |
| 24 | "is_page_ready": state.is_page_ready, |
| 25 | "parsed_model_list": state.parsed_model_list, |
| 26 | "current_ai_studio_model_id": state.current_ai_studio_model_id, |
| 27 | "model_switching_lock": state.model_switching_lock, |
| 28 | "page_params_cache": state.page_params_cache, |
| 29 | "params_cache_lock": state.params_cache_lock, |
| 30 | "is_streaming": request.stream, |
| 31 | "model_actually_switched": False, |
| 32 | "requested_model": request.model, |
| 33 | "model_id_to_use": None, |
| 34 | "needs_model_switching": False, |
| 35 | }, |
| 36 | ) |
| 37 | |
| 38 | return context |