During training, when creating the training/validation examples, the parse_available_tools method does not consider all the defined tools. Currently, only the last tool is being added to the available_tools list.
Expected Behavior
All tools should be added to the available tools list.
Additional Context
Method:
def _parse_available_tools(tools: List[Dict[str, Any]]) -> List[Tool]:
available_tools = []
for tool in tools:
if "name" in tool:
tool = {"type": "function", "function": tool}
if "function" not in tool:
raise FunctionFormatError(
"A tool dict does not have a 'function' key.", str(tool)
)
func_data = tool["function"]
for key in ["name", "description", "parameters"]:
if key not in func_data:
raise FunctionFormatError(
f"A function dict does not have a {key} key.", str(func_data)
)
if not isinstance(func_data["parameters"], dict):
raise FunctionFormatError(
f"A function 'parameters' key has to be of type dict, but is {type(func_data['parameters'])}. If the function has no parameters pass an empty dict ", str(func_data)
)
description = func_data["description"]
function = Function(
name=func_data["name"],
description=description,
parameters=func_data["parameters"],
)
available_tools.append(Tool(function=function))
return available_tools
The line available_tools.append(Tool(function=function)) is where the issue is. I think it should be inside the for loop.
Python Version
Pip Freeze
Reproduction Steps
During training, when creating the training/validation examples, the parse_available_tools method does not consider all the defined tools. Currently, only the last tool is being added to the available_tools list.
Expected Behavior
All tools should be added to the available tools list.
Additional Context
Method:
The line
available_tools.append(Tool(function=function))
is where the issue is. I think it should be inside the for loop.Suggested Solutions
I've already created a PR to fix this bug.
PR: https://github.com/mistralai/mistral-finetune/pull/76