mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-05 16:48:03 +08:00
fix reasoning parsers plugin (#4104)
Some checks failed
CE Compile Job / ce_job_pre_check (push) Has been cancelled
CE Compile Job / print_ce_job_pre_check_outputs (push) Has been cancelled
CE Compile Job / FD-Clone-Linux (push) Has been cancelled
CE Compile Job / Show Code Archive Output (push) Has been cancelled
CE Compile Job / BUILD_SM8090 (push) Has been cancelled
CE Compile Job / BUILD_SM8689 (push) Has been cancelled
CE Compile Job / CE_UPLOAD (push) Has been cancelled
Some checks failed
CE Compile Job / ce_job_pre_check (push) Has been cancelled
CE Compile Job / print_ce_job_pre_check_outputs (push) Has been cancelled
CE Compile Job / FD-Clone-Linux (push) Has been cancelled
CE Compile Job / Show Code Archive Output (push) Has been cancelled
CE Compile Job / BUILD_SM8090 (push) Has been cancelled
CE Compile Job / BUILD_SM8689 (push) Has been cancelled
CE Compile Job / CE_UPLOAD (push) Has been cancelled
This commit is contained in:
@@ -71,17 +71,9 @@ class InputPreprocessor:
|
|||||||
"""
|
"""
|
||||||
reasoning_parser_obj = None
|
reasoning_parser_obj = None
|
||||||
tool_parser_obj = None
|
tool_parser_obj = None
|
||||||
try:
|
|
||||||
from fastdeploy.plugins.reasoning_parser import (
|
|
||||||
load_reasoning_parser_plugins,
|
|
||||||
)
|
|
||||||
|
|
||||||
custom_reasoning_parser = load_reasoning_parser_plugins()
|
if self.reasoning_parser:
|
||||||
if self.reasoning_parser == "custom_reasoning_parser":
|
reasoning_parser_obj = ReasoningParserManager.get_reasoning_parser(self.reasoning_parser)
|
||||||
reasoning_parser_obj = custom_reasoning_parser
|
|
||||||
except:
|
|
||||||
if self.reasoning_parser:
|
|
||||||
reasoning_parser_obj = ReasoningParserManager.get_reasoning_parser(self.reasoning_parser)
|
|
||||||
if self.tool_parser:
|
if self.tool_parser:
|
||||||
tool_parser_obj = ToolParserManager.get_tool_parser(self.tool_parser)
|
tool_parser_obj = ToolParserManager.get_tool_parser(self.tool_parser)
|
||||||
|
|
||||||
|
@@ -23,5 +23,5 @@ PLUGINS_GROUP = "fastdeploy.input_processor_plugins"
|
|||||||
def load_input_processor_plugins():
|
def load_input_processor_plugins():
|
||||||
"""load_input_processor_plugins"""
|
"""load_input_processor_plugins"""
|
||||||
plugins = load_plugins_by_group(group=PLUGINS_GROUP)
|
plugins = load_plugins_by_group(group=PLUGINS_GROUP)
|
||||||
assert len(plugins) <= 1, "Most one plugin is allowed to be loaded."
|
assert len(plugins) == 1, "Only one plugin is allowed to be loaded."
|
||||||
return next(iter(plugins.values()))()
|
return next(iter(plugins.values()))()
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from fastdeploy.plugins.utils import load_plugins_by_group, plugins_loaded
|
from fastdeploy.plugins.utils import load_plugins_by_group
|
||||||
|
|
||||||
# use for modle runner
|
# use for modle runner
|
||||||
PLUGINS_GROUP = "fastdeploy.model_runner_plugins"
|
PLUGINS_GROUP = "fastdeploy.model_runner_plugins"
|
||||||
@@ -22,11 +22,6 @@ PLUGINS_GROUP = "fastdeploy.model_runner_plugins"
|
|||||||
|
|
||||||
def load_model_runner_plugins():
|
def load_model_runner_plugins():
|
||||||
"""load_model_runner_plugins"""
|
"""load_model_runner_plugins"""
|
||||||
global plugins_loaded
|
|
||||||
if plugins_loaded:
|
|
||||||
return
|
|
||||||
plugins_loaded = True
|
|
||||||
|
|
||||||
plugins = load_plugins_by_group(group=PLUGINS_GROUP)
|
plugins = load_plugins_by_group(group=PLUGINS_GROUP)
|
||||||
assert len(plugins) <= 1, "Most one plugin is allowed to be loaded."
|
assert len(plugins) == 1, "Only one plugin is allowed to be loaded."
|
||||||
return next(iter(plugins.values()))()
|
return next(iter(plugins.values()))()
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from fastdeploy.plugins.utils import load_plugins_by_group
|
from fastdeploy.plugins.utils import load_plugins_by_group, plugins_loaded
|
||||||
|
|
||||||
# make sure one process only loads plugins once
|
# make sure one process only loads plugins once
|
||||||
PLUGINS_GROUP = "fastdeploy.reasoning_parser_plugins"
|
PLUGINS_GROUP = "fastdeploy.reasoning_parser_plugins"
|
||||||
@@ -22,6 +22,12 @@ PLUGINS_GROUP = "fastdeploy.reasoning_parser_plugins"
|
|||||||
|
|
||||||
def load_reasoning_parser_plugins():
|
def load_reasoning_parser_plugins():
|
||||||
"""load_reasoning_parser_plugins"""
|
"""load_reasoning_parser_plugins"""
|
||||||
|
global plugins_loaded
|
||||||
|
if plugins_loaded:
|
||||||
|
return
|
||||||
|
plugins_loaded = True
|
||||||
|
|
||||||
plugins = load_plugins_by_group(group=PLUGINS_GROUP)
|
plugins = load_plugins_by_group(group=PLUGINS_GROUP)
|
||||||
assert len(plugins) <= 1, "Most one plugin is allowed to be loaded."
|
# general plugins, we only need to execute the loaded functions
|
||||||
return next(iter(plugins.values()))()
|
for func in plugins.values():
|
||||||
|
func()
|
||||||
|
@@ -14,6 +14,8 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from fastdeploy.plugins import load_reasoning_parser_plugins
|
||||||
|
|
||||||
from .abs_reasoning_parsers import ReasoningParser, ReasoningParserManager
|
from .abs_reasoning_parsers import ReasoningParser, ReasoningParserManager
|
||||||
from .ernie_vl_reasoning_parsers import ErnieVLReasoningParser
|
from .ernie_vl_reasoning_parsers import ErnieVLReasoningParser
|
||||||
from .ernie_x1_reasoning_parsers import ErnieX1ReasoningParser
|
from .ernie_x1_reasoning_parsers import ErnieX1ReasoningParser
|
||||||
@@ -26,3 +28,5 @@ __all__ = [
|
|||||||
"Qwen3ReasoningParser",
|
"Qwen3ReasoningParser",
|
||||||
"ErnieX1ReasoningParser",
|
"ErnieX1ReasoningParser",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
load_reasoning_parser_plugins()
|
||||||
|
@@ -1,14 +1,5 @@
|
|||||||
|
"""
|
||||||
# Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
|
# Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
|
||||||
#
|
|
||||||
#
|
|
||||||
from collections.abc import Sequence
|
|
||||||
from typing import Tuple, Union
|
|
||||||
|
|
||||||
from fastdeploy.entrypoints.openai.protocol import ChatCompletionRequest, DeltaMessage
|
|
||||||
from fastdeploy.reasoning import ReasoningParser, ReasoningParserManager
|
|
||||||
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"
|
# Licensed under the Apache License, Version 2.0 (the "License"
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
# You may obtain a copy of the License at
|
# You may obtain a copy of the License at
|
||||||
@@ -20,6 +11,13 @@ from fastdeploy.reasoning import ReasoningParser, ReasoningParserManager
|
|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from collections.abc import Sequence
|
||||||
|
from typing import Tuple, Union
|
||||||
|
|
||||||
|
from fastdeploy.entrypoints.openai.protocol import ChatCompletionRequest, DeltaMessage
|
||||||
|
from fastdeploy.reasoning import ReasoningParser, ReasoningParserManager
|
||||||
|
|
||||||
|
|
||||||
@ReasoningParserManager.register_module("ernie_x1")
|
@ReasoningParserManager.register_module("ernie_x1")
|
||||||
|
Reference in New Issue
Block a user