fix: Use inspect.cleandoc on function docstrings in generate_function_declaration.

This creates proper indent of the doc.

PiperOrigin-RevId: 766285907
This commit is contained in:
Google Team Member 2025-06-02 11:56:48 -07:00 committed by Copybara-Service
parent 11b504c808
commit f7cb66620b

View File

@ -46,14 +46,14 @@ class FunctionTool(BaseTool):
# Get documentation (prioritize direct __doc__ if available)
if hasattr(func, '__doc__') and func.__doc__:
doc = func.__doc__
doc = inspect.cleandoc(func.__doc__)
elif (
hasattr(func, '__call__')
and hasattr(func.__call__, '__doc__')
and func.__call__.__doc__
):
# For callable objects, try to get docstring from __call__ method
doc = func.__call__.__doc__
doc = inspect.cleandoc(func.__call__.__doc__)
super().__init__(name=name, description=doc)
self.func = func