Spaces:
Runtime error
Runtime error
update
Browse files- team_frame/base_agent.py +10 -11
team_frame/base_agent.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
| 1 |
from google.adk.agents import Agent
|
| 2 |
-
from google.adk.agents.invocation_context import InvocationContext
|
| 3 |
from google.adk.tools import google_search
|
| 4 |
from supabase import create_client, Client
|
| 5 |
|
| 6 |
import logging # 导入 logging 模块
|
| 7 |
-
import os,json
|
| 8 |
|
| 9 |
# 配置日志
|
| 10 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(name)s - %(message)s')
|
|
@@ -12,7 +11,7 @@ logger = logging.getLogger(__name__)
|
|
| 12 |
|
| 13 |
class BaseAgent(Agent):
|
| 14 |
def __init__(self, team_name:str, agent_id: str):
|
| 15 |
-
logger.info("
|
| 16 |
|
| 17 |
# 从环境变量加载 Supabase URL 和 Key
|
| 18 |
url: str = os.environ.get("SUPABASE_URL")
|
|
@@ -29,7 +28,7 @@ class BaseAgent(Agent):
|
|
| 29 |
tools=[google_search],
|
| 30 |
description="一个执行基本通用命令的基础助手"
|
| 31 |
)
|
| 32 |
-
logger.info("
|
| 33 |
return # Exit __init__ if using default config
|
| 34 |
|
| 35 |
logger.info("Supabase URL and Key loaded from environment variables.")
|
|
@@ -69,11 +68,11 @@ class BaseAgent(Agent):
|
|
| 69 |
description="一个执行基本通用命令的基础助手"
|
| 70 |
)
|
| 71 |
return # Exit __init__ if using default config
|
| 72 |
-
print('\n\n\n\ndata',data)
|
| 73 |
-
print('**************************')
|
| 74 |
-
print('data[0]',data[0])
|
| 75 |
-
print('data[1]',data[1])
|
| 76 |
-
print('data[1][0]',data[1][0])
|
| 77 |
|
| 78 |
config = data[1][0] # 假设查询结果是列表中的第一个字典
|
| 79 |
logger.info("Agent configuration data fetched from Supabase. config: ",)
|
|
@@ -96,7 +95,7 @@ class BaseAgent(Agent):
|
|
| 96 |
logger.warning("Using default tool: google_search")
|
| 97 |
|
| 98 |
# 使用从数据库获取的配置初始化 Base_Agent 实例自身
|
| 99 |
-
print('\n\n\n\nconfig: ',config)
|
| 100 |
super().__init__(
|
| 101 |
name=config.get("name", "基础助手"),
|
| 102 |
model=config.get("model", "gemini-2.0-flash-exp"),
|
|
@@ -118,4 +117,4 @@ class BaseAgent(Agent):
|
|
| 118 |
description="一个执行基本通用命令的基础助手"
|
| 119 |
)
|
| 120 |
|
| 121 |
-
logger.info("
|
|
|
|
| 1 |
from google.adk.agents import Agent
|
|
|
|
| 2 |
from google.adk.tools import google_search
|
| 3 |
from supabase import create_client, Client
|
| 4 |
|
| 5 |
import logging # 导入 logging 模块
|
| 6 |
+
import os, json
|
| 7 |
|
| 8 |
# 配置日志
|
| 9 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(name)s - %(message)s')
|
|
|
|
| 11 |
|
| 12 |
class BaseAgent(Agent):
|
| 13 |
def __init__(self, team_name:str, agent_id: str):
|
| 14 |
+
logger.info("BaseAgent __init__ started.")
|
| 15 |
|
| 16 |
# 从环境变量加载 Supabase URL 和 Key
|
| 17 |
url: str = os.environ.get("SUPABASE_URL")
|
|
|
|
| 28 |
tools=[google_search],
|
| 29 |
description="一个执行基本通用命令的基础助手"
|
| 30 |
)
|
| 31 |
+
logger.info("BaseAgent initialized with default configuration.")
|
| 32 |
return # Exit __init__ if using default config
|
| 33 |
|
| 34 |
logger.info("Supabase URL and Key loaded from environment variables.")
|
|
|
|
| 68 |
description="一个执行基本通用命令的基础助手"
|
| 69 |
)
|
| 70 |
return # Exit __init__ if using default config
|
| 71 |
+
# print('\n\n\n\ndata',data)
|
| 72 |
+
# print('**************************')
|
| 73 |
+
# print('data[0]',data[0])
|
| 74 |
+
# print('data[1]',data[1])
|
| 75 |
+
# print('data[1][0]',data[1][0])
|
| 76 |
|
| 77 |
config = data[1][0] # 假设查询结果是列表中的第一个字典
|
| 78 |
logger.info("Agent configuration data fetched from Supabase. config: ",)
|
|
|
|
| 95 |
logger.warning("Using default tool: google_search")
|
| 96 |
|
| 97 |
# 使用从数据库获取的配置初始化 Base_Agent 实例自身
|
| 98 |
+
# print('\n\n\n\nconfig: ',config)
|
| 99 |
super().__init__(
|
| 100 |
name=config.get("name", "基础助手"),
|
| 101 |
model=config.get("model", "gemini-2.0-flash-exp"),
|
|
|
|
| 117 |
description="一个执行基本通用命令的基础助手"
|
| 118 |
)
|
| 119 |
|
| 120 |
+
logger.info("BaseAgent __init__ finished.")
|