|
21 | 21 | from typing import AsyncGenerator |
22 | 22 | from typing import Awaitable |
23 | 23 | from typing import Callable |
24 | | -from typing import List |
25 | 24 | from typing import Literal |
26 | 25 | from typing import Optional |
27 | 26 | from typing import Type |
28 | 27 | from typing import Union |
29 | 28 |
|
30 | 29 | from google.genai import types |
31 | 30 | from pydantic import BaseModel |
32 | | -from pydantic import ConfigDict |
33 | 31 | from pydantic import Field |
34 | 32 | from pydantic import field_validator |
35 | 33 | from pydantic import model_validator |
|
54 | 52 | from ..tools.tool_context import ToolContext |
55 | 53 | from ..utils.feature_decorator import working_in_progress |
56 | 54 | from .base_agent import BaseAgent |
57 | | -from .base_agent_config import BaseAgentConfig |
58 | 55 | from .callback_context import CallbackContext |
59 | 56 | from .common_configs import CodeConfig |
60 | 57 | from .invocation_context import InvocationContext |
| 58 | +from .llm_agent_config import LlmAgentConfig |
61 | 59 | from .readonly_context import ReadonlyContext |
62 | 60 |
|
63 | 61 | logger = logging.getLogger('google_adk.' + __name__) |
@@ -603,115 +601,3 @@ def from_config( |
603 | 601 |
|
604 | 602 |
|
605 | 603 | Agent: TypeAlias = LlmAgent |
606 | | - |
607 | | - |
608 | | -class LlmAgentConfig(BaseAgentConfig): |
609 | | - """The config for the YAML schema of a LlmAgent.""" |
610 | | - |
611 | | - model_config = ConfigDict( |
612 | | - extra='forbid', |
613 | | - ) |
614 | | - |
615 | | - agent_class: Literal['LlmAgent', ''] = 'LlmAgent' |
616 | | - """The value is used to uniquely identify the LlmAgent class. If it is |
617 | | - empty, it is by default an LlmAgent.""" |
618 | | - |
619 | | - model: Optional[str] = None |
620 | | - """Optional. LlmAgent.model. If not set, the model will be inherited from |
621 | | - the ancestor.""" |
622 | | - |
623 | | - instruction: str |
624 | | - """Required. LlmAgent.instruction.""" |
625 | | - |
626 | | - disallow_transfer_to_parent: Optional[bool] = None |
627 | | - """Optional. LlmAgent.disallow_transfer_to_parent.""" |
628 | | - |
629 | | - disallow_transfer_to_peers: Optional[bool] = None |
630 | | - """Optional. LlmAgent.disallow_transfer_to_peers.""" |
631 | | - |
632 | | - input_schema: Optional[CodeConfig] = None |
633 | | - """Optional. LlmAgent.input_schema.""" |
634 | | - |
635 | | - output_schema: Optional[CodeConfig] = None |
636 | | - """Optional. LlmAgent.output_schema.""" |
637 | | - |
638 | | - output_key: Optional[str] = None |
639 | | - """Optional. LlmAgent.output_key.""" |
640 | | - |
641 | | - include_contents: Literal['default', 'none'] = 'default' |
642 | | - """Optional. LlmAgent.include_contents.""" |
643 | | - |
644 | | - tools: Optional[list[CodeConfig]] = None |
645 | | - """Optional. LlmAgent.tools. |
646 | | -
|
647 | | - Examples: |
648 | | -
|
649 | | - For ADK built-in tools in `google.adk.tools` package, they can be referenced |
650 | | - directly with the name: |
651 | | -
|
652 | | - ``` |
653 | | - tools: |
654 | | - - name: google_search |
655 | | - - name: load_memory |
656 | | - ``` |
657 | | -
|
658 | | - For user-defined tools, they can be referenced with fully qualified name: |
659 | | -
|
660 | | - ``` |
661 | | - tools: |
662 | | - - name: my_library.my_tools.my_tool |
663 | | - ``` |
664 | | -
|
665 | | - For tools that needs to be created via functions: |
666 | | -
|
667 | | - ``` |
668 | | - tools: |
669 | | - - name: my_library.my_tools.create_tool |
670 | | - args: |
671 | | - - name: param1 |
672 | | - value: value1 |
673 | | - - name: param2 |
674 | | - value: value2 |
675 | | - ``` |
676 | | -
|
677 | | - For more advanced tools, instead of specifying arguments in config, it's |
678 | | - recommended to define them in Python files and reference them. E.g., |
679 | | -
|
680 | | - ``` |
681 | | - # tools.py |
682 | | - my_mcp_toolset = MCPToolset( |
683 | | - connection_params=StdioServerParameters( |
684 | | - command="npx", |
685 | | - args=["-y", "@notionhq/notion-mcp-server"], |
686 | | - env={"OPENAPI_MCP_HEADERS": NOTION_HEADERS}, |
687 | | - ) |
688 | | - ) |
689 | | - ``` |
690 | | -
|
691 | | - Then, reference the toolset in config: |
692 | | -
|
693 | | - ``` |
694 | | - tools: |
695 | | - - name: tools.my_mcp_toolset |
696 | | - ``` |
697 | | - """ |
698 | | - |
699 | | - before_model_callbacks: Optional[List[CodeConfig]] = None |
700 | | - """Optional. LlmAgent.before_model_callbacks. |
701 | | -
|
702 | | - Example: |
703 | | -
|
704 | | - ``` |
705 | | - before_model_callbacks: |
706 | | - - name: my_library.callbacks.before_model_callback |
707 | | - ``` |
708 | | - """ |
709 | | - |
710 | | - after_model_callbacks: Optional[List[CodeConfig]] = None |
711 | | - """Optional. LlmAgent.after_model_callbacks.""" |
712 | | - |
713 | | - before_tool_callbacks: Optional[List[CodeConfig]] = None |
714 | | - """Optional. LlmAgent.before_tool_callbacks.""" |
715 | | - |
716 | | - after_tool_callbacks: Optional[List[CodeConfig]] = None |
717 | | - """Optional. LlmAgent.after_tool_callbacks.""" |
0 commit comments