Add docstrings to FunctionSchema, update CONTRIBUTING.md with docstrings guidance, ignore __init__ docstrings if a class is sufficiently documented
This commit is contained in:
@@ -8,16 +8,22 @@ from typing import Any, Dict, List
|
||||
|
||||
|
||||
class FunctionSchema:
|
||||
"""Standardized function schema representation for tool definition.
|
||||
|
||||
Provides a structured way to define function tools used with AI models like OpenAI.
|
||||
This schema defines the function's name, description, parameter properties, and
|
||||
required parameters, following specifications required by AI service providers.
|
||||
|
||||
Args:
|
||||
name: Name of the function to be called.
|
||||
description: Description of what the function does.
|
||||
properties: Dictionary defining parameter types, descriptions, and constraints.
|
||||
required: List of property names that are required parameters.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, name: str, description: str, properties: Dict[str, Any], required: List[str]
|
||||
) -> None:
|
||||
"""Standardized function schema representation.
|
||||
|
||||
:param name: Name of the function.
|
||||
:param description: Description of the function.
|
||||
:param properties: Dictionary defining properties types and descriptions.
|
||||
:param required: List of required parameters.
|
||||
"""
|
||||
self._name = name
|
||||
self._description = description
|
||||
self._properties = properties
|
||||
@@ -26,7 +32,8 @@ class FunctionSchema:
|
||||
def to_default_dict(self) -> Dict[str, Any]:
|
||||
"""Converts the function schema to a dictionary.
|
||||
|
||||
:return: Dictionary representation of the function schema.
|
||||
Returns:
|
||||
Dictionary representation of the function schema.
|
||||
"""
|
||||
return {
|
||||
"name": self._name,
|
||||
@@ -40,16 +47,36 @@ class FunctionSchema:
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
"""Get the function name.
|
||||
|
||||
Returns:
|
||||
The function name.
|
||||
"""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def description(self) -> str:
|
||||
"""Get the function description.
|
||||
|
||||
Returns:
|
||||
The function description.
|
||||
"""
|
||||
return self._description
|
||||
|
||||
@property
|
||||
def properties(self) -> Dict[str, Any]:
|
||||
"""Get the function properties.
|
||||
|
||||
Returns:
|
||||
Dictionary of parameter specifications.
|
||||
"""
|
||||
return self._properties
|
||||
|
||||
@property
|
||||
def required(self) -> List[str]:
|
||||
"""Get the required parameters.
|
||||
|
||||
Returns:
|
||||
List of required parameter names.
|
||||
"""
|
||||
return self._required
|
||||
|
||||
Reference in New Issue
Block a user