From 797f48cbe9c8c8e66a0b38883de53ffd976f80f6 Mon Sep 17 00:00:00 2001 From: fern <126544928+fern-bot@users.noreply.github.com> Date: Tue, 20 Aug 2024 11:17:00 -0400 Subject: [PATCH] fix(custom code): update decorator to ignore missing arguments --- src/cohere/client.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cohere/client.py b/src/cohere/client.py index 14ef841f1..540f832ca 100644 --- a/src/cohere/client.py +++ b/src/cohere/client.py @@ -87,7 +87,9 @@ def fn(*args, **kwargs): # `deprecated_kwarg` is the name of the experimental parameter, which can be a dot-separated string for nested parameters def experimental_kwarg_decorator(func, deprecated_kwarg): # Recursive utility function to check if a kwarg is present in the kwargs. - def check_kwarg(deprecated_kwarg: str, kwargs: typing.Dict[str, typing.Any]) -> bool: + def check_kwarg(deprecated_kwarg: str, kwargs: typing.Optional[typing.Dict[str, typing.Any]]) -> bool: + if kwargs is None: + return False if "." in deprecated_kwarg: key, rest = deprecated_kwarg.split(".", 1) if key in kwargs: