fix(utils): handle missing funcschema parameter docs (#2186)

This commit is contained in:
huanghuoguoguo
2026-05-16 11:20:32 +08:00
committed by GitHub
parent b251fc4b89
commit 0a669c7016
2 changed files with 16 additions and 1 deletions

View File

@@ -83,7 +83,7 @@ def get_func_schema(function: typing.Callable) -> dict:
parameters['properties'][param.name] = {
'type': param_type,
'description': args_doc[param.name],
'description': args_doc.get(param.name, ''),
}
# add schema for array

View File

@@ -0,0 +1,15 @@
from langbot.pkg.utils.funcschema import get_func_schema
def test_get_func_schema_uses_empty_description_for_undocumented_parameter():
def sample_function(documented: str, undocumented: int):
"""Sample function.
Args:
documented(str): documented parameter description
"""
schema = get_func_schema(sample_function)
assert schema['parameters']['properties']['documented']['description'] == 'documented parameter description'
assert schema['parameters']['properties']['undocumented']['description'] == ''