As of litellm==1.40.15, default arguments are not supported within litellm.utils.function_to_dict. It would be great to support primitive defaults in this utility function.
For example, the below code will not properly include the default value:
import litellm
def foo(arg: int = 5) -> None:
"""
Stub.
Args:
arg: Something defaulted to 5.
"""
litellm.utils.function_to_dict(foo)
To show how a type union is done in JSON schema, we can refer to pydantic==2.7.4:
from pydantic import BaseModel
class Foo(BaseModel):
bar: int = 5
print(Foo.model_json_schema())
The Feature
As of
litellm==1.40.15
, default arguments are not supported withinlitellm.utils.function_to_dict
. It would be great to support primitive defaults in this utility function.For example, the below code will not properly include the default value:
To show how a type union is done in JSON schema, we can refer to
pydantic==2.7.4
:Will print (after prettifying):
Motivation, pitch
There are times when a function will contain a default argument.
Twitter / LinkedIn details
No response