from .supabase_cli import get_supabase_client from supabase import Client from google.adk.agents import Agent def load_agent_config(db_item): # print('\nload_agent_config...') # print('\n\n\n\n\n***************************\ndb_item',db_item) agent_config={ "name": db_item['name'], "model": db_item['model'], "instruction": db_item['instruction'], "tools": db_item['tools'], "sub_agents": db_item['sub_agents'], "description": db_item['description'] } tools_config=[] if db_item['tools']: agent_config['tools'] = db_item['tools'] tools_config = list(set(tools_config + db_item['tools'])) return { 'agent_config': agent_config, 'tools_config': tools_config} def creat_agent() -> Agent: pass def load_team_config(): a_team_config = { "agents":[], "root_agent": None, "tools":[] } print("Loading team_config from database...") supabase: Client = get_supabase_client() if not supabase: return {} try: response = supabase.from_("team_get_weather").select("*").order("sort_id").execute() for item in response.data: if item['is_root']: _agent_config = load_agent_config(item) print('_agent_config',_agent_config) a_team_config['root_agent'] = _agent_config['agent_config'] a_team_config['tools'] = list(set(a_team_config['tools'] + _agent_config['tools_config'])) else: _agent_config = load_agent_config(item) a_team_config['agents'].append(_agent_config['agent_config']) a_team_config['tools'] = list(set(a_team_config['tools'] + _agent_config['tools_config'])) # print('\n\na_team_config',a_team_config) except Exception as e: print(f"Error loading API keys from database: {e}") a_team_config = {} # Clear cache on error return a_team_config """ a_team_config { 'agents': [ { 'name': 'farewell_agent', 'model': 'gemini-2.5-flash-preview-04-17', 'instruction': "You are the Farewell Agent. Your ONLY task is to provide a polite goodbye message.\nIf not about goodbye, just transfer to weather_time_agent.\nDo not perform any other actions.\nBefore you answer, you should say your name: 'I am farewell_agent'", 'tools': None, 'sub_agents': None, 'description': 'Handles simple farewells and goodbyes' }, { 'name': 'greeting_agent', 'model': 'gemini-2.5-flash-preview-04-17', 'instruction': "You are the Greeting Agent. Your ONLY task is to provide a friendly greeting to the user. \nDo not engage in any other conversation or tasks.\nBefore you answer, you should say your name: 'I am greeting_agent'", 'tools': None, 'sub_agents': None, 'description': 'Handles simple greetings and hellos' } ], 'root_agent': { 'name': 'weather_time_agent', 'model': 'gemini-2.5-flash-preview-04-17', ' instruction': "You are a helpful agent who can answer user questions about the time and weather in a city.\nBefore you answer, you should say your name: 'I am weather_time_agent'", 'tools': [ 'get_weather', 'get_current_time' ], 'sub_agents': [ 'greeting_agent', 'farewell_agent' ], 'description': 'Agent to answer questions about the time and weather in a city.' }, 'tools': [ 'get_weather', 'get_current_time' ] } """