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

Method _process_guided_json

fastdeploy/engine/request.py:222–238  ·  view source on GitHub ↗
(cls, r: T)

Source from the content-addressed store, hash-verified

220
221 @classmethod
222 def _process_guided_json(cls, r: T):
223 guided_json_object = None
224 if hasattr(r, "response_format") and r.response_format is not None:
225 if r.response_format.type == "json_object":
226 guided_json_object = True
227 elif r.response_format.type == "json_schema":
228 json_schema = r.response_format.json_schema.json_schema
229 assert json_schema is not None, "response_format.json_schema can not be None"
230 if isinstance(json_schema, (BaseModel, type(BaseModel))):
231 r.guided_json = json_schema.model_json_schema()
232 else:
233 r.guided_json = json_schema
234 elif r.response_format.type == "structural_tag":
235 structural_tag = r.response_format
236 assert structural_tag is not None and isinstance(structural_tag, StructuralTagResponseFormat)
237 r.structural_tag = json.dumps(structural_tag.model_dump(by_alias=True))
238 return guided_json_object
239
240 @classmethod
241 def from_generic_request(

Callers 2

from_generic_requestMethod · 0.80

Calls 1

model_dumpMethod · 0.45

Tested by 1