[misc] fix constants (#9008)

This commit is contained in:
Yaowei Zheng
2025-08-23 23:04:30 +08:00
committed by GitHub
parent 3e1b1e7060
commit b017757491
6 changed files with 40 additions and 16 deletions

View File

@@ -98,7 +98,7 @@ class FunctionFormatter(StringFormatter):
def apply(self, **kwargs) -> SLOTS:
content: str = kwargs.pop("content")
thought_words, thought = kwargs.pop("thought_words", None), None
if thought_words and len(thought_words)== 2:
if thought_words and len(thought_words) == 2:
regex = re.compile(rf"{re.escape(thought_words[0])}(.*?){re.escape(thought_words[1])}", re.DOTALL)
thought = re.search(regex, content)

View File

@@ -1855,19 +1855,17 @@ register_template(
)
#copied from seed_coder
# copied from seed_coder
register_template(
name="seed_oss",
format_user=StringFormatter(
slots=[{"bos_token"}, "user\n{{content}}", {"eos_token"}, {"bos_token"}, "assistant\n"]
),
format_system=StringFormatter(slots=[{"bos_token"}, "system\n{{content}}", {"eos_token"}]),
format_function=FunctionFormatter(
slots=[{"bos_token"}, "\n{{content}}", {"eos_token"}], tool_format="seed_oss"
),
format_function=FunctionFormatter(slots=[{"bos_token"}, "\n{{content}}", {"eos_token"}], tool_format="seed_oss"),
format_tools=ToolFormatter(tool_format="seed_oss"),
template_class=ReasoningTemplate,
thought_words=("<seed:think>", "</seed:think>")
thought_words=("<seed:think>", "</seed:think>"),
)

View File

@@ -355,6 +355,7 @@ class GLM4MOEToolUtils(QwenToolUtils):
return "\n".join(function_texts)
class SeedToolUtils(ToolUtils):
r"""Seed tool using template."""
@@ -387,8 +388,7 @@ class SeedToolUtils(ToolUtils):
def tool_extractor(content: str) -> Union[str, list["FunctionCall"]]:
results = []
regex = re.compile(
r"<seed:tool_call>\s*<function=\s*([^\s<]+)\s*(.*?)\s*</function>\s*</seed:tool_call>",
re.DOTALL
r"<seed:tool_call>\s*<function=\s*([^\s<]+)\s*(.*?)\s*</function>\s*</seed:tool_call>", re.DOTALL
)
for func_name, params_block in re.findall(regex, content):
args_dict = {}
@@ -405,6 +405,7 @@ class SeedToolUtils(ToolUtils):
return results
TOOLS = {
"default": DefaultToolUtils(),
"glm4": GLM4ToolUtils(),