[feat] Add SGLANG_TOOL_STRICT_LEVEL for tool-call behavior control (#12423)
Signed-off-by: Xinyuan Tong <xinyuantong.cs@gmail.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import os
|
||||
import subprocess
|
||||
import warnings
|
||||
from contextlib import ExitStack, contextmanager
|
||||
from enum import IntEnum
|
||||
from typing import Any
|
||||
|
||||
|
||||
@@ -105,6 +106,20 @@ class EnvFloat(EnvField):
|
||||
raise ValueError(f'"{value}" is not a valid float value')
|
||||
|
||||
|
||||
class ToolStrictLevel(IntEnum):
|
||||
"""
|
||||
Defines the strictness levels for tool call parsing and validation.
|
||||
|
||||
OFF: No strict validation
|
||||
FUNCTION: Enables structural tag constraints for all tools
|
||||
PARAMETER: Enforces strict parameter validation for all tools
|
||||
"""
|
||||
|
||||
OFF = 0
|
||||
FUNCTION = 1
|
||||
PARAMETER = 2
|
||||
|
||||
|
||||
class Envs:
|
||||
# fmt: off
|
||||
|
||||
@@ -259,6 +274,9 @@ class Envs:
|
||||
# Sparse Embeddings
|
||||
SGLANG_EMBEDDINGS_SPARSE_HEAD = EnvStr(None)
|
||||
|
||||
# Tool-Call behavior
|
||||
SGLANG_TOOL_STRICT_LEVEL = EnvInt(ToolStrictLevel.OFF)
|
||||
|
||||
# fmt: on
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user