|
@@ -27,7 +27,7 @@ from agent.llm import create_openrouter_llm_call
|
|
|
from agent.utils import setup_logging
|
|
from agent.utils import setup_logging
|
|
|
|
|
|
|
|
# 导入配置(使用绝对路径导入)
|
|
# 导入配置(使用绝对路径导入)
|
|
|
-from examples.auto_put_ad.config import RUN_CONFIG, SKILLS_DIR, TRACE_STORE_PATH, LOG_LEVEL, LOG_FILE
|
|
|
|
|
|
|
+from examples.auto_put_ad.config import MAIN_CONFIG, SKILLS_DIR, TRACE_STORE_PATH, LOG_LEVEL, LOG_FILE
|
|
|
|
|
|
|
|
# 导入自定义工具(触发 @tool 注册)
|
|
# 导入自定义工具(触发 @tool 注册)
|
|
|
from examples.auto_put_ad.tools.ad_api import (
|
|
from examples.auto_put_ad.tools.ad_api import (
|
|
@@ -39,7 +39,12 @@ from examples.auto_put_ad.tools.audience_tools import (
|
|
|
audience_build_targeting, audience_recommend_targeting,
|
|
audience_build_targeting, audience_recommend_targeting,
|
|
|
)
|
|
)
|
|
|
from examples.auto_put_ad.tools.budget_calc import (
|
|
from examples.auto_put_ad.tools.budget_calc import (
|
|
|
- account_evaluate, bid_adjustment_execute, budget_calculate_from_data,
|
|
|
|
|
|
|
+ get_ad_performance, get_account_summary,
|
|
|
|
|
+ compute_budget_thresholds, classify_ads, compute_bid_adjustment,
|
|
|
|
|
+ bid_adjustment_execute,
|
|
|
|
|
+)
|
|
|
|
|
+from examples.auto_put_ad.tools.strategy_config import (
|
|
|
|
|
+ load_strategy_config, update_strategy_config, get_config_history,
|
|
|
)
|
|
)
|
|
|
from examples.auto_put_ad.tools.data_query import (
|
|
from examples.auto_put_ad.tools.data_query import (
|
|
|
data_aggregate, data_query, get_ad_current_status,
|
|
data_aggregate, data_query, get_ad_current_status,
|
|
@@ -53,21 +58,22 @@ async def init_project_env(messages=None):
|
|
|
"""供 api_server 可视化调用:返回 (runner, messages, config)"""
|
|
"""供 api_server 可视化调用:返回 (runner, messages, config)"""
|
|
|
base_dir = Path(__file__).parent
|
|
base_dir = Path(__file__).parent
|
|
|
|
|
|
|
|
- # 读取 system prompt
|
|
|
|
|
- task_prompt_path = base_dir / "task.prompt"
|
|
|
|
|
|
|
+ # 读取 main.prompt
|
|
|
|
|
+ main_prompt_path = base_dir / "prompts" / "main.prompt"
|
|
|
system_prompt = ""
|
|
system_prompt = ""
|
|
|
- if task_prompt_path.exists():
|
|
|
|
|
- system_prompt = task_prompt_path.read_text(encoding="utf-8")
|
|
|
|
|
|
|
+ if main_prompt_path.exists():
|
|
|
|
|
+ system_prompt = main_prompt_path.read_text(encoding="utf-8")
|
|
|
|
|
|
|
|
store = FileSystemTraceStore(base_path=TRACE_STORE_PATH)
|
|
store = FileSystemTraceStore(base_path=TRACE_STORE_PATH)
|
|
|
runner = AgentRunner(
|
|
runner = AgentRunner(
|
|
|
trace_store=store,
|
|
trace_store=store,
|
|
|
- llm_call=create_openrouter_llm_call(model=RUN_CONFIG.model),
|
|
|
|
|
|
|
+ llm_call=create_openrouter_llm_call(model=MAIN_CONFIG.model),
|
|
|
skills_dir=SKILLS_DIR if Path(SKILLS_DIR).exists() else None,
|
|
skills_dir=SKILLS_DIR if Path(SKILLS_DIR).exists() else None,
|
|
|
|
|
+ presets_path=base_dir / "presets.json", # 启用多 Agent 预设
|
|
|
logger_name="agents.auto_put_ad",
|
|
logger_name="agents.auto_put_ad",
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- config = RUN_CONFIG
|
|
|
|
|
|
|
+ config = MAIN_CONFIG
|
|
|
if system_prompt:
|
|
if system_prompt:
|
|
|
config.system_prompt = system_prompt
|
|
config.system_prompt = system_prompt
|
|
|
|
|
|
|
@@ -85,23 +91,24 @@ async def main():
|
|
|
# 初始化日志
|
|
# 初始化日志
|
|
|
setup_logging(level=LOG_LEVEL, file=LOG_FILE)
|
|
setup_logging(level=LOG_LEVEL, file=LOG_FILE)
|
|
|
|
|
|
|
|
- # 读取 system prompt
|
|
|
|
|
- task_prompt_path = base_dir / "task.prompt"
|
|
|
|
|
|
|
+ # 读取 main.prompt
|
|
|
|
|
+ main_prompt_path = base_dir / "prompts" / "main.prompt"
|
|
|
system_prompt = ""
|
|
system_prompt = ""
|
|
|
- if task_prompt_path.exists():
|
|
|
|
|
- system_prompt = task_prompt_path.read_text(encoding="utf-8")
|
|
|
|
|
|
|
+ if main_prompt_path.exists():
|
|
|
|
|
+ system_prompt = main_prompt_path.read_text(encoding="utf-8")
|
|
|
|
|
|
|
|
- # 创建 Runner
|
|
|
|
|
|
|
+ # 创建 Runner(启用多 Agent)
|
|
|
store = FileSystemTraceStore(base_path=TRACE_STORE_PATH)
|
|
store = FileSystemTraceStore(base_path=TRACE_STORE_PATH)
|
|
|
runner = AgentRunner(
|
|
runner = AgentRunner(
|
|
|
trace_store=store,
|
|
trace_store=store,
|
|
|
- llm_call=create_openrouter_llm_call(model=RUN_CONFIG.model),
|
|
|
|
|
|
|
+ llm_call=create_openrouter_llm_call(model=MAIN_CONFIG.model),
|
|
|
skills_dir=SKILLS_DIR if Path(SKILLS_DIR).exists() else None,
|
|
skills_dir=SKILLS_DIR if Path(SKILLS_DIR).exists() else None,
|
|
|
|
|
+ presets_path=base_dir / "presets.json", # 启用多 Agent 预设
|
|
|
logger_name="agents.auto_put_ad",
|
|
logger_name="agents.auto_put_ad",
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
# 如果有 system_prompt,注入到 config
|
|
# 如果有 system_prompt,注入到 config
|
|
|
- config = RUN_CONFIG
|
|
|
|
|
|
|
+ config = MAIN_CONFIG
|
|
|
if system_prompt:
|
|
if system_prompt:
|
|
|
config.system_prompt = system_prompt
|
|
config.system_prompt = system_prompt
|
|
|
|
|
|