[model] Apertus Tool/Function and Reasoning parser (#25100)
This commit is contained in:
@@ -1463,13 +1463,24 @@ async def separate_reasoning_request(obj: SeparateReasoningReqInput, request: Re
|
||||
parser = ReasoningParser(model_type=obj.reasoning_parser, request=request)
|
||||
|
||||
# 2) Call the non-stream parsing method (non-stream)
|
||||
reasoning_text, normal_text = parser.parse_non_stream(obj.text)
|
||||
if getattr(obj, "return_blocks", False):
|
||||
blocks = parser.parse_non_stream_blocks(obj.text)
|
||||
reasoning_blocks = [b["text"] for b in blocks if b["type"] == "reasoning"]
|
||||
text_blocks = [b["text"] for b in blocks if b["type"] == "text"]
|
||||
reasoning_text = "".join(reasoning_blocks)
|
||||
normal_text = "".join(text_blocks)
|
||||
else:
|
||||
reasoning_text, normal_text = parser.parse_non_stream(obj.text)
|
||||
|
||||
# 3) Organize the response content
|
||||
response_data = {
|
||||
"reasoning_text": reasoning_text,
|
||||
"text": normal_text,
|
||||
}
|
||||
if getattr(obj, "return_blocks", False):
|
||||
response_data["reasoning_blocks"] = reasoning_blocks
|
||||
response_data["text_blocks"] = text_blocks
|
||||
response_data["blocks"] = blocks
|
||||
|
||||
return ORJSONResponse(content=response_data, status_code=200)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user