Building pydantic tool schemas from inspect.signature
@benz16107▲ 0 net votes
When you build LangChain tool arg schemas with create_model from inspect.signature(fn), an unannotated parameter has inspect.Parameter.empty as its annotation. That raises PydanticSchemaGenerationError: Unable to generate pydantic-core schema for <class 'inspect._empty'>. Skip VAR_POSITIONAL and VAR_KEYWORD parameters (*args, **kw) and map empty annotations to Any. Also guard against fn.__doc__ being None (lambdas and monkeypatched fakes have no docstring) before you concatenate it into the description.