mirror of
https://github.com/EvolutionAPI/adk-python.git
synced 2025-07-14 09:51:25 -06:00
Deprecate BuiltInCodeExecutionTool in favor of BuiltInCodeExecutor.
PiperOrigin-RevId: 758713057
This commit is contained in:
parent
b67182c50f
commit
22e4210b47
@ -15,16 +15,16 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from .base_code_executor import BaseCodeExecutor
|
from .base_code_executor import BaseCodeExecutor
|
||||||
|
from .built_incode_executor import BuiltInCodeExecutor
|
||||||
from .code_executor_context import CodeExecutorContext
|
from .code_executor_context import CodeExecutorContext
|
||||||
from .gemini_code_executor import GeminiCodeExecutor
|
|
||||||
from .unsafe_local_code_executor import UnsafeLocalCodeExecutor
|
from .unsafe_local_code_executor import UnsafeLocalCodeExecutor
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'BaseCodeExecutor',
|
'BaseCodeExecutor',
|
||||||
|
'BuiltInCodeExecutor',
|
||||||
'CodeExecutorContext',
|
'CodeExecutorContext',
|
||||||
'GeminiCodeExecutor',
|
|
||||||
'UnsafeLocalCodeExecutor',
|
'UnsafeLocalCodeExecutor',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -23,8 +23,12 @@ from .code_execution_utils import CodeExecutionInput
|
|||||||
from .code_execution_utils import CodeExecutionResult
|
from .code_execution_utils import CodeExecutionResult
|
||||||
|
|
||||||
|
|
||||||
class GeminiCodeExecutor(BaseCodeExecutor):
|
class BuiltInCodeExecutor(BaseCodeExecutor):
|
||||||
"""A code executor for Gemini 2.0+ models to exeute code."""
|
"""A code executor that uses the Model's built-in code executor.
|
||||||
|
|
||||||
|
Currently only supports Gemini 2.0+ models, but will be expanded to
|
||||||
|
other models.
|
||||||
|
"""
|
||||||
|
|
||||||
@override
|
@override
|
||||||
def execute_code(
|
def execute_code(
|
@ -30,12 +30,12 @@ from typing_extensions import override
|
|||||||
|
|
||||||
from ...agents.invocation_context import InvocationContext
|
from ...agents.invocation_context import InvocationContext
|
||||||
from ...code_executors.base_code_executor import BaseCodeExecutor
|
from ...code_executors.base_code_executor import BaseCodeExecutor
|
||||||
|
from ...code_executors.built_in_code_executor import BuiltInCodeExecutor
|
||||||
from ...code_executors.code_execution_utils import CodeExecutionInput
|
from ...code_executors.code_execution_utils import CodeExecutionInput
|
||||||
from ...code_executors.code_execution_utils import CodeExecutionResult
|
from ...code_executors.code_execution_utils import CodeExecutionResult
|
||||||
from ...code_executors.code_execution_utils import CodeExecutionUtils
|
from ...code_executors.code_execution_utils import CodeExecutionUtils
|
||||||
from ...code_executors.code_execution_utils import File
|
from ...code_executors.code_execution_utils import File
|
||||||
from ...code_executors.code_executor_context import CodeExecutorContext
|
from ...code_executors.code_executor_context import CodeExecutorContext
|
||||||
from ...code_executors.gemini_code_executor import GeminiCodeExecutor
|
|
||||||
from ...events.event import Event
|
from ...events.event import Event
|
||||||
from ...events.event_actions import EventActions
|
from ...events.event_actions import EventActions
|
||||||
from ...models.llm_response import LlmResponse
|
from ...models.llm_response import LlmResponse
|
||||||
@ -175,7 +175,7 @@ async def _run_pre_processor(
|
|||||||
if not code_executor or not isinstance(code_executor, BaseCodeExecutor):
|
if not code_executor or not isinstance(code_executor, BaseCodeExecutor):
|
||||||
return
|
return
|
||||||
|
|
||||||
if isinstance(code_executor, GeminiCodeExecutor):
|
if isinstance(code_executor, BuiltInCodeExecutor):
|
||||||
code_executor.process_llm_request(llm_request)
|
code_executor.process_llm_request(llm_request)
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ async def _run_post_processor(
|
|||||||
if not llm_response or not llm_response.content:
|
if not llm_response or not llm_response.content:
|
||||||
return
|
return
|
||||||
|
|
||||||
if isinstance(code_executor, GeminiCodeExecutor):
|
if isinstance(code_executor, BuiltInCodeExecutor):
|
||||||
return
|
return
|
||||||
|
|
||||||
code_executor_context = CodeExecutorContext(invocation_context.session.state)
|
code_executor_context = CodeExecutorContext(invocation_context.session.state)
|
||||||
|
@ -14,18 +14,26 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import logging
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
|
from deprecated import deprecated
|
||||||
from google.genai import types
|
from google.genai import types
|
||||||
from typing_extensions import override
|
from typing_extensions import override
|
||||||
|
|
||||||
from .base_tool import BaseTool
|
from .base_tool import BaseTool
|
||||||
from .tool_context import ToolContext
|
from .tool_context import ToolContext
|
||||||
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from ..models import LlmRequest
|
from ..models import LlmRequest
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@deprecated(
|
||||||
|
'No longer supported. Please use the new BuiltInCodeExecutor instead.'
|
||||||
|
)
|
||||||
class BuiltInCodeExecutionTool(BaseTool):
|
class BuiltInCodeExecutionTool(BaseTool):
|
||||||
"""A built-in code execution tool that is automatically invoked by Gemini 2 models.
|
"""A built-in code execution tool that is automatically invoked by Gemini 2 models.
|
||||||
|
|
||||||
@ -44,6 +52,10 @@ class BuiltInCodeExecutionTool(BaseTool):
|
|||||||
tool_context: ToolContext,
|
tool_context: ToolContext,
|
||||||
llm_request: LlmRequest,
|
llm_request: LlmRequest,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
logger.warning(
|
||||||
|
'BuiltInCodeExecutionTool is deprecated. Please use the new'
|
||||||
|
' BuiltInCodeExecutor instead.'
|
||||||
|
)
|
||||||
if llm_request.model and llm_request.model.startswith('gemini-2'):
|
if llm_request.model and llm_request.model.startswith('gemini-2'):
|
||||||
llm_request.config = llm_request.config or types.GenerateContentConfig()
|
llm_request.config = llm_request.config or types.GenerateContentConfig()
|
||||||
llm_request.config.tools = llm_request.config.tools or []
|
llm_request.config.tools = llm_request.config.tools or []
|
||||||
|
Loading…
Reference in New Issue
Block a user