@@ -747,80 +747,3 @@ def answer(
747747 """
748748 logger .info (f"Answering question (sync): { question [:100 ]} ..." )
749749 return asyncio .run (self .answer_async (question , session_id ))
750-
751-
752- class KnowledgeAgentManager :
753- """Manages KnowledgeGroundedAgent lifecycle with lazy initialization.
754-
755- This class provides convenient lifecycle management for the knowledge agent,
756- with lazy initialization and state tracking.
757-
758- Parameters
759- ----------
760- config : Configs, optional
761- Configuration object for client setup. If not provided, creates default.
762-
763- Examples
764- --------
765- >>> manager = KnowledgeAgentManager()
766- >>> agent = manager.agent
767- >>> response = await agent.answer_async("What is quantum computing?")
768- >>> print(response.text)
769- >>> manager.close()
770- """
771-
772- def __init__ (
773- self ,
774- config : Configs | None = None ,
775- enable_caching : bool = True ,
776- enable_planning : bool = True ,
777- enable_compaction : bool = True ,
778- ) -> None :
779- """Initialize the client manager.
780-
781- Parameters
782- ----------
783- config : Configs, optional
784- Configuration object. If not provided, creates default config.
785- enable_caching : bool, default True
786- Whether to enable context caching.
787- enable_planning : bool, default True
788- Whether to enable built-in planning (Gemini thinking mode).
789- enable_compaction : bool, default True
790- Whether to enable context compaction.
791- """
792- self ._config = config
793- self ._enable_caching = enable_caching
794- self ._enable_planning = enable_planning
795- self ._enable_compaction = enable_compaction
796- self ._agent : KnowledgeGroundedAgent | None = None
797- self ._initialized = False
798-
799- @property
800- def config (self ) -> Configs :
801- """Get or create the config instance."""
802- if self ._config is None :
803- self ._config = Configs () # type: ignore[call-arg]
804- return self ._config
805-
806- @property
807- def agent (self ) -> KnowledgeGroundedAgent :
808- """Get or create the knowledge-grounded agent."""
809- if self ._agent is None :
810- self ._agent = KnowledgeGroundedAgent (
811- config = self .config ,
812- enable_caching = self ._enable_caching ,
813- enable_planning = self ._enable_planning ,
814- enable_compaction = self ._enable_compaction ,
815- )
816- self ._initialized = True
817- return self ._agent
818-
819- def close (self ) -> None :
820- """Close all initialized clients and reset state."""
821- self ._agent = None
822- self ._initialized = False
823-
824- def is_initialized (self ) -> bool :
825- """Check if any clients have been initialized."""
826- return self ._initialized
0 commit comments