Remove EBNF Composer (#13163)

This commit is contained in:
Tejesh Anand
2025-11-12 17:55:30 -08:00
committed by GitHub
parent 6d21392b0e
commit e42df37df0
18 changed files with 6 additions and 1081 deletions

View File

@@ -195,41 +195,3 @@ class FunctionCallParser:
elif tool_choice == "required" or isinstance(tool_choice, ToolChoice):
json_schema = get_json_schema_constraint(self.tools, tool_choice)
return ("json_schema", json_schema)
def get_ebnf(
self, tool_choice: Union[ToolChoice, Literal["required"]]
) -> Optional[str]:
"""
Get the EBNF grammar for the specified tool choice.
Args:
tool_choice: The tool choice specification
Returns:
EBNF grammar string, or None if no valid tools found
Note:
If a specific function is requested but not found in available tools,
logs a warning and falls back to using all available tools for backward compatibility.
"""
filtered_tools = []
if isinstance(tool_choice, ToolChoice):
fn_name = tool_choice.function.name
filtered_tools = [t for t in self.tools if t.function.name == fn_name]
# Check if the requested function exists in available tools
if not filtered_tools:
available_functions = [t.function.name for t in self.tools]
logger.warning(
f"Function '{fn_name}' not found in available tools. "
f"Available functions: {available_functions}. "
f"Skipping tool choice."
)
# TODO: Return a 400 error instead of warning when adapter supports proper error handling
# For now, fall back to return None
return None
else:
filtered_tools = self.tools
return self.detector.build_ebnf(filtered_tools)