MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / run_request

Function run_request

fastdeploy/entrypoints/openai/run_batch.py:294–329  ·  view source on GitHub ↗
(
    serving_engine_func: Callable,
    request: BatchRequestInput,
    tracker: BatchProgressTracker,
    semaphore: asyncio.Semaphore,
)

Source from the content-addressed store, hash-verified

292
293
294async def run_request(
295 serving_engine_func: Callable,
296 request: BatchRequestInput,
297 tracker: BatchProgressTracker,
298 semaphore: asyncio.Semaphore,
299) -> BatchRequestOutput:
300 async with semaphore:
301 try:
302 response = await serving_engine_func(request.body)
303
304 if isinstance(response, ChatCompletionResponse):
305 batch_output = BatchRequestOutput(
306 id=f"fastdeploy-{random_uuid()}",
307 custom_id=request.custom_id,
308 response=BatchResponseData(
309 status_code=200, body=response, request_id=f"fastdeploy-batch-{random_uuid()}"
310 ),
311 error=None,
312 )
313 elif isinstance(response, ErrorResponse):
314 batch_output = BatchRequestOutput(
315 id=f"fastdeploy-{random_uuid()}",
316 custom_id=request.custom_id,
317 response=BatchResponseData(status_code=400, request_id=f"fastdeploy-batch-{random_uuid()}"),
318 error=response,
319 )
320 else:
321 batch_output = make_error_request_output(request, error_msg="Request must not be sent in stream mode")
322
323 tracker.completed()
324 return batch_output
325
326 except Exception as e:
327 console_logger.error(f"Request {request.custom_id} processing failed: {str(e)}")
328 tracker.completed()
329 return make_error_request_output(request, error_msg=f"Request processing failed: {str(e)}")
330
331
332def determine_process_id() -> int:

Calls 6

BatchRequestOutputClass · 0.90
BatchResponseDataClass · 0.90
random_uuidFunction · 0.85
completedMethod · 0.80
errorMethod · 0.45