diff --git a/app/core/tools/external_function_tool.py b/app/core/tools/external_function_tool.py index 9dce4fb..d661696 100644 --- a/app/core/tools/external_function_tool.py +++ b/app/core/tools/external_function_tool.py @@ -35,3 +35,24 @@ def __init__(self, definition: dict) -> None: # 其它参数未使用到,暂时不做处理 self.openai_function = definition self.name = definition["function"]["name"] + + +def _validate_definition(self, definition: dict) -> bool: + """ + Validate the structure of the function definition. + Returns True if valid, False otherwise. + """ + if "type" not in definition or definition["type"] != "function": + return False + + if "function" not in definition: + return False + + if not isinstance(definition["function"], dict): + return False + + # Check if "name" exists + if "name" not in definition["function"]: + return False + + return True