Remove EBNF Composer (#13163)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user