MCPcopy Create free account
hub / github.com/modelscope/modelscope / inference

Function inference

modelscope/server/api/routers/model_router.py:13–37  ·  view source on GitHub ↗

Inference general interface. For image, video, audio etc binary data, need encoded with base64. Args: request (Request): The request object. request_info (ModelScopeRequest): The post body. Returns: ApiResponse: For binary field, encoded with base64

(
    request: Request,
    body: BaseModel = Body(examples=[{
        'usage': 'copy body from describe'
    }]))

Source from the content-addressed store, hash-verified

11
12@router.post('/call')
13async def inference(
14 request: Request,
15 body: BaseModel = Body(examples=[{
16 'usage': 'copy body from describe'
17 }])): # noqa E125
18 """Inference general interface.
19
20 For image, video, audio etc binary data, need encoded with base64.
21
22 Args:
23 request (Request): The request object.
24 request_info (ModelScopeRequest): The post body.
25
26 Returns:
27 ApiResponse: For binary field, encoded with base64
28 """
29 pipeline_service = request.app.state.pipeline
30 pipeline_info = request.app.state.pipeline_info
31 request_json = await request.json()
32 result = call_pipeline_with_json(pipeline_info, pipeline_service,
33 request_json)
34 # convert output to json, if binary field, we need encoded.
35 output = pipeline_output_to_service_base64_output(
36 pipeline_info['task_name'], result)
37 return output
38
39
40@router.get('/describe')

Callers 1

Calls 3

call_pipeline_with_jsonFunction · 0.90
BodyClass · 0.50

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…