Skip to content

Commit 555a6c5

Browse files
authored
[benchmark] Refactor simple_tool_call by removing regex logic (#7995)
Removed regex logic for tool call extraction and related variable assignments.
1 parent 1862567 commit 555a6c5

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

benchmarks/backend_request_func.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,6 @@ async def async_request_eb_openai_chat_completions(
634634

635635
async def simple_tool_call(model_output, tool_url: str, timeout=60):
636636
"""调用工具函数"""
637-
import re
638637

639638
import httpx
640639

@@ -646,18 +645,20 @@ async def simple_tool_call(model_output, tool_url: str, timeout=60):
646645
args = tc.get("arguments", {})
647646
tool_id = tc.get("id")
648647
else:
649-
match = re.search(r"<tool_call>(.*?)</tool_call>", model_output.generated_text, re.S)
650-
if not match:
651-
return "", False, "", tool_id
652-
653-
block = match.group(1).strip()
654-
lines = block.splitlines()
655-
tool_name = lines[0].strip()
656-
657-
key = re.search(r"<arg_key>(.*?)</arg_key>", block)
658-
val = re.search(r"<arg_value>(.*?)</arg_value>", block)
659-
660-
args = {key.group(1): val.group(1)} if key and val else {}
648+
# 取消正则逻辑
649+
return "", False, "", tool_id
650+
# match = re.search(r"<tool_call>(.*?)</tool_call>", model_output.generated_text, re.S)
651+
# if not match:
652+
# return "", False, "", tool_id
653+
#
654+
# block = match.group(1).strip()
655+
# lines = block.splitlines()
656+
# tool_name = lines[0].strip()
657+
#
658+
# key = re.search(r"<arg_key>(.*?)</arg_key>", block)
659+
# val = re.search(r"<arg_value>(.*?)</arg_value>", block)
660+
#
661+
# args = {key.group(1): val.group(1)} if key and val else {}
661662

662663
if not tool_name:
663664
return "", False, "", tool_id

0 commit comments

Comments
 (0)