Skip to content

Commit 72da7fa

Browse files
yyyu-googlecopybara-github
authored andcommitted
chore: log warning if users don't use json schema for FunctionDeclaration.from_callable or FunctionDeclaration.from_callable_with_api_option. Fixes #3105
PiperOrigin-RevId: 1003304996
1 parent 4c1abcc commit 72da7fa

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎google/genai/types.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def __getattr__(name: str) -> Any:
166166
_response_code_execution_warning_logged = False
167167
_live_server_text_warning_logged = False
168168
_live_server_data_warning_logged = False
169+
_from_callable_with_api_option_warning_logged = False
169170

170171

171172
T = typing.TypeVar('T', bound='GenerateContentResponse')
@@ -4914,6 +4915,15 @@ def from_callable_with_api_option(
49144915
f'Unsupported api_option value: {api_option}. Supported api_option'
49154916
f' value is one of: {supported_api_options}.'
49164917
)
4918+
if (
4919+
not use_json_schema
4920+
and not _from_callable_with_api_option_warning_logged
4921+
):
4922+
logger.warning(
4923+
'use_json_schema is not True, which is not recommended. Parsing a'
4924+
' callable into JSON schema is preferred.'
4925+
)
4926+
_from_callable_with_api_option_warning_logged = True
49174927
from . import _automatic_function_calling_util
49184928

49194929
if use_json_schema:

0 commit comments

Comments
 (0)