Procházet zdrojové kódy

修改脚本名称

xueyiming před 3 dny
rodič
revize
ef5e721824

+ 1 - 1
examples/demand/agent_tools.py

@@ -1,5 +1,5 @@
 from agent.tools import ToolResult, tool
-from examples.demand.topic_build_pattern_tools import _log_tool_input, _log_tool_output
+from examples.demand.demand_pattern_tools import _log_tool_input, _log_tool_output
 
 
 @tool(

+ 0 - 0
examples/demand/topic_build_agent_context.py → examples/demand/demand_agent_context.py


+ 2 - 2
examples/demand/demand_build_agent_tools.py

@@ -3,8 +3,8 @@ from pathlib import Path
 from typing import Any, Dict, List, Optional
 
 from agent import tool
-from examples.demand.topic_build_agent_context import TopicBuildAgentContext
-from examples.demand.topic_build_pattern_tools import _log_tool_output, _log_tool_input
+from examples.demand.demand_agent_context import TopicBuildAgentContext
+from examples.demand.demand_pattern_tools import _log_tool_output, _log_tool_input
 
 def _get_result_base_dir() -> Path:
     """输出到“当前工作目录/result/”下。"""

+ 4 - 6
examples/demand/topic_build_pattern_tools.py → examples/demand/demand_pattern_tools.py

@@ -23,7 +23,7 @@ import json
 from typing import Any
 
 from agent import tool
-from examples.demand.topic_build_agent_context import TopicBuildAgentContext
+from examples.demand.demand_agent_context import TopicBuildAgentContext
 from log_capture import log
 import pattern_service
 
@@ -74,9 +74,6 @@ def get_category_tree(source_type: str = None) -> str:
 
     return _log_tool_output("get_category_tree", result)
 
-if __name__ == '__main__':
-    TopicBuildAgentContext.set_execution_id(17)
-    print(get_category_tree('实质'))
 
 # ============================================================================
 # 项集查询
@@ -490,5 +487,6 @@ def get_element_co_occurrences(element_names: list, top_n: int = 30,
 
 
 if __name__ == '__main__':
-    TopicBuildAgentContext.set_execution_id(3)
-    get_category_co_occurrences(category_ids=[81])
+    TopicBuildAgentContext.set_execution_id(1)
+    print(get_category_tree('实质'))
+

+ 0 - 1
examples/demand/piaoquan_prepare.py

@@ -7,7 +7,6 @@ from examples.demand.db_manager import DatabaseManager
 from examples.demand.models import TopicPatternElement, TopicPatternExecution
 from examples.demand.pattern_builds.pattern_service import run_mining
 
-from examples.demand.run import get_execution_id_by_merge_level2
 
 db = DatabaseManager()
 

+ 14 - 13
examples/demand/run.py

@@ -18,7 +18,7 @@ from examples.demand.config import LOG_LEVEL, ENABLED_TOOLS
 from examples.demand.db_manager import DatabaseManager
 from examples.demand.models import TopicPatternExecution
 from examples.demand.piaoquan_prepare import prepare, piaoquan_prepare
-from examples.demand.topic_build_agent_context import TopicBuildAgentContext
+from examples.demand.demand_agent_context import TopicBuildAgentContext
 from examples.demand.mysql import mysql_db
 
 # Clash Verge TUN 模式兼容:禁止 httpx/urllib 自动检测系统 HTTP 代理
@@ -49,17 +49,17 @@ from examples.demand.config import DEBUG, LOG_FILE, LOG_LEVEL, RUN_CONFIG, TRACE
 CUSTOM_TOOL_MODULES = {
     # demand 示例:严格按工具名白名单加载对应模块
     "think_and_plan": "examples.demand.agent_tools",
-    "get_category_tree": "examples.demand.topic_build_pattern_tools",
-    "get_frequent_itemsets": "examples.demand.topic_build_pattern_tools",
-    "get_itemset_detail": "examples.demand.topic_build_pattern_tools",
-    "get_post_elements": "examples.demand.topic_build_pattern_tools",
-    "search_elements": "examples.demand.topic_build_pattern_tools",
-    "get_element_category_chain": "examples.demand.topic_build_pattern_tools",
-    "get_category_detail": "examples.demand.topic_build_pattern_tools",
-    "search_categories": "examples.demand.topic_build_pattern_tools",
-    "get_category_elements": "examples.demand.topic_build_pattern_tools",
-    "get_category_co_occurrences": "examples.demand.topic_build_pattern_tools",
-    "get_element_co_occurrences": "examples.demand.topic_build_pattern_tools",
+    "get_category_tree": "examples.demand.demand_pattern_tools",
+    "get_frequent_itemsets": "examples.demand.demand_pattern_tools",
+    "get_itemset_detail": "examples.demand.demand_pattern_tools",
+    "get_post_elements": "examples.demand.demand_pattern_tools",
+    "search_elements": "examples.demand.demand_pattern_tools",
+    "get_element_category_chain": "examples.demand.demand_pattern_tools",
+    "get_category_detail": "examples.demand.demand_pattern_tools",
+    "search_categories": "examples.demand.demand_pattern_tools",
+    "get_category_elements": "examples.demand.demand_pattern_tools",
+    "get_category_co_occurrences": "examples.demand.demand_pattern_tools",
+    "get_element_co_occurrences": "examples.demand.demand_pattern_tools",
     "get_weight_score_topn": "examples.demand.weight_score_query_tools",
     "get_weight_score_by_name": "examples.demand.weight_score_query_tools",
     "create_demand_item": "examples.demand.demand_build_agent_tools",
@@ -388,4 +388,5 @@ async def main(cluster_name, platform_type) -> None:
 
 
 if __name__ == "__main__":
-    asyncio.run(main('小阳看天下', 'changwen'))
+    piaoquan_prepare('历史名人')
+    # asyncio.run(main('小阳看天下', 'changwen'))

+ 2 - 2
examples/demand/weight_score_query_tools.py

@@ -10,8 +10,8 @@ import json
 from pathlib import Path
 
 from agent import tool
-from examples.demand.topic_build_agent_context import TopicBuildAgentContext
-from examples.demand.topic_build_pattern_tools import _log_tool_input, _log_tool_output
+from examples.demand.demand_agent_context import TopicBuildAgentContext
+from examples.demand.demand_pattern_tools import _log_tool_input, _log_tool_output
 
 _VALID_LEVELS = {"元素", "分类"}
 _VALID_DIMENSIONS = {"实质", "形式", "意图"}