Revert "feat: generate structured analysis reports"
This reverts commit 96c23f1f56.
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import sys
|
||||
from io import StringIO
|
||||
|
||||
from app.tool.chart_visualization.utils import extract_executable_code
|
||||
from app.tool.python_execute import PythonExecute
|
||||
from app.tool.chart_visualization.utils import (
|
||||
extract_executable_code,
|
||||
)
|
||||
|
||||
|
||||
class NormalPythonExecute(PythonExecute):
|
||||
@@ -10,86 +12,9 @@ class NormalPythonExecute(PythonExecute):
|
||||
|
||||
name: str = "common_python_execute"
|
||||
description: str = (
|
||||
"""
|
||||
A tool for executing Python code with data anaylsis.
|
||||
Prefix: 帮我生成结果保存在本地./data下
|
||||
|
||||
Data Analysis Agent Protocol (Non-Visual)
|
||||
|
||||
=== Core Requirements ===
|
||||
1. Strictly text-based outputs only
|
||||
2. Prohibited actions:
|
||||
- Any chart/image generation
|
||||
- Interactive visual elements
|
||||
- Graphical libraries import
|
||||
|
||||
=== Execution Phases ===
|
||||
|
||||
1. DATA LOADING (Auto-detect format)
|
||||
- Supported formats: CSV/Excel/JSON
|
||||
- Mandatory checks:
|
||||
a) File existence verification
|
||||
b) Column structure validation
|
||||
c) Basic integrity checks
|
||||
|
||||
2. ANALYSIS PIPELINE
|
||||
- Cleaning:
|
||||
• Null handling (drop or impute)
|
||||
• Deduplication
|
||||
• Outlier treatment (IQR/Z-score)
|
||||
|
||||
- Transformation:
|
||||
• Date parsing
|
||||
• Derived metrics
|
||||
• Aggregations
|
||||
|
||||
3. REPORT GENERATION
|
||||
Output 1: data_exploration.md
|
||||
┌──────────────────────┬──────────────────────────────┐
|
||||
│ Section │ Content Requirements │
|
||||
├──────────────────────┼──────────────────────────────┤
|
||||
│ Dataset Metadata │ Rows/Columns/Temporal Range │
|
||||
│ Column Descriptions │ Type/Stats/Unique Values │
|
||||
│ Key Findings │ 3-5 bullet points │
|
||||
└──────────────────────┴──────────────────────────────┘
|
||||
|
||||
Output 2: preprocessing_results.md
|
||||
┌──────────────────────┬──────────────────────────────┐
|
||||
│ Section │ Content Requirements │
|
||||
├──────────────────────┼──────────────────────────────┤
|
||||
│ Cleaning Log │ Rows affected by each operation │
|
||||
│ Derived Metrics │ Formula/Summary Stats │
|
||||
│ Anomaly Report │ Z-score >2.5 cases │
|
||||
└──────────────────────┴──────────────────────────────┘
|
||||
|
||||
=== Implementation Rules ===
|
||||
1. Code Generation Constraints:
|
||||
- Forbidden libraries: matplotlib, seaborn, plotly
|
||||
- Maximum column width: 120 chars
|
||||
- Required docstrings for all functions
|
||||
|
||||
2. Error Handling:
|
||||
- Skip corrupted records with logging
|
||||
- Continue processing after non-critical errors
|
||||
- Fail fast on structural issues
|
||||
|
||||
3. Output Validation:
|
||||
- Markdown syntax check
|
||||
- Statistical validity verification
|
||||
- Cross-report consistency
|
||||
|
||||
=== Sample Invocation ===
|
||||
def analyze(data_path):
|
||||
'''Main analysis workflow'''
|
||||
df = load_data(data_path) # Phase 1
|
||||
cleaned = clean_and_transform(df) # Phase 2
|
||||
generate_reports(cleaned) # Phase 3
|
||||
=== 执行约束 ===
|
||||
当检测到错误时:
|
||||
1. 分析错误类型(数据/逻辑/环境)
|
||||
2. 生成修正方案(自动重试≤3次)
|
||||
3. 严重错误时回滚中间文件
|
||||
"""
|
||||
"""Executes Python code strings. Note:
|
||||
1. Only outputs from print() are visible; function return values are not captured. Use print() statements to display results
|
||||
2. Applicable to scenarios **excluding data analysis and chart generation**"""
|
||||
)
|
||||
parameters: dict = {
|
||||
"type": "object",
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import asyncio
|
||||
|
||||
from app.agent.data_analysis import DataAnalysis
|
||||
|
||||
# from app.agent.manus import Manus
|
||||
|
||||
|
||||
async def main():
|
||||
agent = DataAnalysis()
|
||||
# agent = Manus()
|
||||
await agent.run(
|
||||
"""Here's last month's sales data from my Amazon store in './data/amazon_sales_jan2025.xlsx'. Could you analyze it? """
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user