Skip to content

Commit 6206484

Browse files
committed
优化qwen 工具解析
1 parent afb48b6 commit 6206484

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

gpt_server/model_handler/tool_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def extract_tool_calls(
253253
tools,
254254
) -> ExtractedToolCallInformation:
255255
text = model_output
256-
if self.tool_start_token in text:
256+
if self.tool_start_token in text and self.tool_end_token in text:
257257
logger.debug("tool_parse tool_start_token 在 text")
258258
# get tool_call in text
259259
match_result_list = re.findall(self.pattern, text, re.DOTALL)
@@ -279,7 +279,7 @@ def extract_tool_calls(
279279
tool_calls=tool_calls,
280280
content=text if len(text) > 0 else "",
281281
)
282-
elif self.tool_start_token not in text and self.tool_end_token in text:
282+
elif self.tool_start_token in text or self.tool_end_token in text:
283283
# 如果 tool_start_token 不在 text 但是 tool_end_token 在text
284284
logger.debug("tool_parse tool_start_token 不在 text")
285285
pattern = r"\{[^{}]*\{[^{}]*\}[^{}]*\}|{[^{}]*}"

0 commit comments

Comments
 (0)