Skip to content

Commit 2335760

Browse files
committed
fix tool_parser
1 parent 23dafb7 commit 2335760

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

gpt_server/model_handler/tool_parser.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from lmdeploy.serve.openai.tool_parser import ToolParser, ToolParserManager
2020
from lmdeploy.serve.openai.tool_parser.utils import extract_intermediate_diff
21+
from lmdeploy.serve.openai.tool_parser import ToolParser
2122

2223

2324
class ToolCall(BaseModel):
@@ -230,9 +231,7 @@ def extract_tool_calls(
230231
tool_calls=tool_calls,
231232
content=text if len(text) > 0 else "",
232233
)
233-
elif (
234-
self.tool_start_token not in text and self.tool_end_token in text
235-
) or tools:
234+
elif self.tool_start_token not in text and self.tool_end_token in text:
236235
# 如果 tool_start_token 不在 text 但是 tool_end_token 在text
237236
logger.debug("tool_parse tool_start_token 不在 text")
238237
pattern = r"\{[^{}]*\{[^{}]*\}[^{}]*\}|{[^{}]*}"
@@ -266,7 +265,7 @@ def extract_tool_calls(
266265
)
267266

268267

269-
def tool_parser(full_text: str, tool_parser, tools, ret):
268+
def tool_parser(full_text: str, tool_parser: ToolParser, tools, ret):
270269
tool_call_info = tool_parser.extract_tool_calls(full_text, tools)
271270
tools_called = tool_call_info.tools_called
272271
text, tool_calls = tool_call_info.content, tool_call_info.tool_calls

0 commit comments

Comments
 (0)