diff --git a/google/genai/types.py b/google/genai/types.py index 86fd26fd1..70fdf9227 100644 --- a/google/genai/types.py +++ b/google/genai/types.py @@ -166,6 +166,7 @@ def __getattr__(name: str) -> Any: _response_code_execution_warning_logged = False _live_server_text_warning_logged = False _live_server_data_warning_logged = False +_from_callable_with_api_option_warning_logged = False T = typing.TypeVar('T', bound='GenerateContentResponse') @@ -4914,6 +4915,16 @@ def from_callable_with_api_option( f'Unsupported api_option value: {api_option}. Supported api_option' f' value is one of: {supported_api_options}.' ) + global _from_callable_with_api_option_warning_logged + if ( + not use_json_schema + and not _from_callable_with_api_option_warning_logged + ): + logger.warning( + 'use_json_schema is not True, which is not recommended. Parsing a' + ' callable into JSON schema is preferred.' + ) + _from_callable_with_api_option_warning_logged = True from . import _automatic_function_calling_util if use_json_schema: