feat: refactor code to prepare merge into main
This commit is contained in:
@@ -8,9 +8,6 @@ data/
|
||||
# Workspace
|
||||
workspace/
|
||||
|
||||
# not hack demo
|
||||
!workspace/amazon_sales_jan.csv
|
||||
|
||||
### Python ###
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
|
||||
@@ -106,23 +106,14 @@ Currently, three tasks of different difficulty levels are set for testing.
|
||||
|
||||
Provide data and specific chart generation requirements, test results, execute the command:
|
||||
```bash
|
||||
python -m app.tool.chart_visualization.test.simple_chart
|
||||
python -m app.tool.chart_visualization.test.chart_demo
|
||||
```
|
||||
The results should be located under `workspace`, involving 9 different chart results.
|
||||
The results should be located under `workspace\visualization`, involving 9 different chart results.
|
||||
|
||||
### Simple Data Report Task
|
||||
|
||||
Provide simple raw data analysis requirements, requiring simple processing of the data, execute the command:
|
||||
```bash
|
||||
python -m app.tool.chart_visualization.test.simple_report
|
||||
python -m app.tool.chart_visualization.test.report_demo
|
||||
```
|
||||
The results are also located under `workspace`.
|
||||
|
||||
### Manus Online Store Operation Analysis Replication
|
||||
|
||||
Replicate the [Manus result](https://manus.im/share/c3onakN6Iajcm1Vt1xAVG7?replay=1), execute the command as follows:
|
||||
|
||||
```
|
||||
python -m app.tool.chart_visualization.test.hack_demo
|
||||
```
|
||||
The results are also located under `workspace`.
|
||||
The results are also located under `workspace\visualization`.
|
||||
|
||||
@@ -110,7 +110,7 @@ VMind本身也需要通过调用大模型得到智能图表生成结果,目前
|
||||
```bash
|
||||
python -m app.tool.chart_visualization.test.simple_chart
|
||||
```
|
||||
结果应位于`worksapce`下,涉及到9种不同的图表结果
|
||||
结果应位于`worksapce\visualization`下,涉及到9种不同的图表结果
|
||||
|
||||
### 简单数据报表任务
|
||||
|
||||
@@ -118,13 +118,5 @@ python -m app.tool.chart_visualization.test.simple_chart
|
||||
```bash
|
||||
python -m app.tool.chart_visualization.test.simple_report
|
||||
```
|
||||
结果同样位于`worksapce`下
|
||||
结果同样位于`worksapce\visualization`下
|
||||
|
||||
### Manus 在线商店运营分析复刻
|
||||
|
||||
复刻[manus结果](https://manus.im/share/c3onakN6Iajcm1Vt1xAVG7?replay=1),执行命令如下:
|
||||
|
||||
```
|
||||
python -m app.tool.chart_visualization.test.hack_demo
|
||||
```
|
||||
结果同样位于`worksapce`下
|
||||
|
||||
+15
-15
@@ -10,7 +10,7 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@visactor/vchart": "^1.13.7",
|
||||
"@visactor/vmind": "2.0.5-alpha.2",
|
||||
"@visactor/vmind": "2.0.5",
|
||||
"canvas": "^2.11.2",
|
||||
"get-stdin": "^9.0.0"
|
||||
},
|
||||
@@ -6389,9 +6389,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@visactor/calculator": {
|
||||
"version": "2.0.5-alpha.2",
|
||||
"resolved": "https://registry.npmjs.org/@visactor/calculator/-/calculator-2.0.5-alpha.2.tgz",
|
||||
"integrity": "sha512-8+/7cC3d/1L8nBvUNRYPxbKKqV04SMpB4RefWhAf8n1paUbNMFcqT7vszjRaak2wayg6MzaH1HoEASt5JLLdsg==",
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://bnpm.byted.org/@visactor/calculator/-/calculator-2.0.5.tgz",
|
||||
"integrity": "sha512-/NBDB/wBQLeQuSspDBuiEAbbyfJS/xPX6mubVsLGhfy65UwUBojAQgmX25FcRJnUsRXooK5heshni19DBBf8xA==",
|
||||
"dependencies": {
|
||||
"@visactor/vutils": "~0.19.3",
|
||||
"node-sql-parser": "~4.17.0",
|
||||
@@ -6399,9 +6399,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@visactor/chart-advisor": {
|
||||
"version": "2.0.5-alpha.2",
|
||||
"resolved": "https://registry.npmjs.org/@visactor/chart-advisor/-/chart-advisor-2.0.5-alpha.2.tgz",
|
||||
"integrity": "sha512-vRYfaxnFszgba2V29i5qUtwv4leS9wiXvelDKHVlqDe0AKByWTezZrSZ0NbN/HajeLxOMvlqWVvCKCT5fYMwtg==",
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://bnpm.byted.org/@visactor/chart-advisor/-/chart-advisor-2.0.5.tgz",
|
||||
"integrity": "sha512-pvHceRlworB7kDSmbWXUtherLLXh5nMj0aEGuxtzKQyHmeO0sjuu9gGXBFIgscGliSZM4tmeNrFU9eBLGJ8dxw==",
|
||||
"dependencies": {
|
||||
"@visactor/vutils": "~0.19.3"
|
||||
}
|
||||
@@ -6566,13 +6566,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@visactor/vmind": {
|
||||
"version": "2.0.5-alpha.2",
|
||||
"resolved": "https://registry.npmjs.org/@visactor/vmind/-/vmind-2.0.5-alpha.2.tgz",
|
||||
"integrity": "sha512-ThAIZNYg8LzFXmR9R5Bg+GzbOwquDWifMWpw3906DnKmbCSIeQwTTaAAARcIfJ0bb/1k3wU8hxfrhzQ9Ythsdw==",
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://bnpm.byted.org/@visactor/vmind/-/vmind-2.0.5.tgz",
|
||||
"integrity": "sha512-QztQaeSkdeRZYOUlB4qaBpx3/swyO3JzFH8eYvSgvptS/rf8aQDZiufAUasafDLkcME5N6RpBGkcGYIDkmt74Q==",
|
||||
"dependencies": {
|
||||
"@stdlib/stats-base-dists-t-quantile": "0.2.1",
|
||||
"@visactor/calculator": "2.0.5-alpha.2",
|
||||
"@visactor/chart-advisor": "2.0.5-alpha.2",
|
||||
"@visactor/calculator": "2.0.5",
|
||||
"@visactor/chart-advisor": "2.0.5",
|
||||
"@visactor/vchart-theme": "^1.11.2",
|
||||
"@visactor/vdataset": "~0.19.3",
|
||||
"@visactor/vutils": "~0.19.3",
|
||||
@@ -6827,7 +6827,7 @@
|
||||
},
|
||||
"node_modules/big-integer": {
|
||||
"version": "1.6.52",
|
||||
"resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.52.tgz",
|
||||
"resolved": "https://bnpm.byted.org/big-integer/-/big-integer-1.6.52.tgz",
|
||||
"integrity": "sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg==",
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
@@ -7749,7 +7749,7 @@
|
||||
},
|
||||
"node_modules/node-sql-parser": {
|
||||
"version": "4.17.0",
|
||||
"resolved": "https://registry.npmjs.org/node-sql-parser/-/node-sql-parser-4.17.0.tgz",
|
||||
"resolved": "https://bnpm.byted.org/node-sql-parser/-/node-sql-parser-4.17.0.tgz",
|
||||
"integrity": "sha512-3IhovpmUBpcETnoKK/KBdkz2mz53kVG5E1dnqz1QuYvtzdxYZW5xaGGEvW9u6Yyy2ivwR3eUZrn9inmEVef02w==",
|
||||
"dependencies": {
|
||||
"big-integer": "^1.6.48"
|
||||
@@ -8266,7 +8266,7 @@
|
||||
},
|
||||
"node_modules/ts-pattern": {
|
||||
"version": "4.1.4",
|
||||
"resolved": "https://registry.npmjs.org/ts-pattern/-/ts-pattern-4.1.4.tgz",
|
||||
"resolved": "https://bnpm.byted.org/ts-pattern/-/ts-pattern-4.1.4.tgz",
|
||||
"integrity": "sha512-Mcw65oUd1w5ktKi5BRwrnz16Otwk9iv7P0dKgvbi+A1albCDgnixohSqNLuFwIp5dzxPmTPm0iDQ6p1ZJr9uGw=="
|
||||
},
|
||||
"node_modules/typedarray": {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@visactor/vchart": "^1.13.7",
|
||||
"@visactor/vmind": "2.0.5-alpha.2",
|
||||
"@visactor/vmind": "2.0.5",
|
||||
"canvas": "^2.11.2",
|
||||
"get-stdin": "^9.0.0"
|
||||
},
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
import asyncio
|
||||
import time
|
||||
|
||||
from app.agent.data_analysis import DataAnalysis
|
||||
from app.agent.manus import Manus
|
||||
from app.flow.base import FlowType
|
||||
from app.flow.flow_factory import FlowFactory
|
||||
from app.logger import logger
|
||||
|
||||
|
||||
async def run_flow():
|
||||
agents = {
|
||||
# "manus": Manus(),
|
||||
"visactor": DataAnalysis(),
|
||||
}
|
||||
|
||||
try:
|
||||
prompt = """Here's last month's sales data from my Amazon store in './data/amazon_sales_jan2025.xlsx'. Could you analyze it?"""
|
||||
|
||||
flow = FlowFactory.create_flow(
|
||||
flow_type=FlowType.PLANNING,
|
||||
agents=agents,
|
||||
)
|
||||
logger.warning("Processing your request...")
|
||||
|
||||
try:
|
||||
start_time = time.time()
|
||||
result = await asyncio.wait_for(
|
||||
flow.execute(prompt),
|
||||
timeout=3600, # 60 minute timeout for the entire execution
|
||||
)
|
||||
elapsed_time = time.time() - start_time
|
||||
logger.info(f"Request processed in {elapsed_time:.2f} seconds")
|
||||
logger.info(result)
|
||||
except asyncio.TimeoutError:
|
||||
logger.error("Request processing timed out after 1 hour")
|
||||
logger.info(
|
||||
"Operation terminated due to timeout. Please try a simpler request."
|
||||
)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
logger.info("Operation cancelled by user.")
|
||||
except Exception as e:
|
||||
logger.error(f"Error: {str(e)}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(run_flow())
|
||||
@@ -0,0 +1,190 @@
|
||||
import asyncio
|
||||
|
||||
from app.agent.data_analysis import DataAnalysis
|
||||
from app.logger import logger
|
||||
|
||||
prefix = "Help me generate charts and save them locally, specifically:"
|
||||
tasks = [
|
||||
{
|
||||
"prompt": "Help me show the sales of different products in different regions",
|
||||
"data": """Product Name,Region,Sales
|
||||
Coke,South,2350
|
||||
Coke,East,1027
|
||||
Coke,West,1027
|
||||
Coke,North,1027
|
||||
Sprite,South,215
|
||||
Sprite,East,654
|
||||
Sprite,West,159
|
||||
Sprite,North,28
|
||||
Fanta,South,345
|
||||
Fanta,East,654
|
||||
Fanta,West,2100
|
||||
Fanta,North,1679
|
||||
Xingmu,South,1476
|
||||
Xingmu,East,830
|
||||
Xingmu,West,532
|
||||
Xingmu,North,498
|
||||
""",
|
||||
},
|
||||
{
|
||||
"prompt": "Show market share of each brand",
|
||||
"data": """Brand Name,Market Share,Average Price,Net Profit
|
||||
Apple,0.5,7068,314531
|
||||
Samsung,0.2,6059,362345
|
||||
Vivo,0.05,3406,234512
|
||||
Nokia,0.01,1064,-1345
|
||||
Xiaomi,0.1,4087,131345""",
|
||||
},
|
||||
{
|
||||
"prompt": "Please help me show the sales trend of each product",
|
||||
"data": """Date,Type,Value
|
||||
2023-01-01,Product A,52.9
|
||||
2023-01-01,Product B,63.6
|
||||
2023-01-01,Product C,11.2
|
||||
2023-01-02,Product A,45.7
|
||||
2023-01-02,Product B,89.1
|
||||
2023-01-02,Product C,21.4
|
||||
2023-01-03,Product A,67.2
|
||||
2023-01-03,Product B,82.4
|
||||
2023-01-03,Product C,31.7
|
||||
2023-01-04,Product A,80.7
|
||||
2023-01-04,Product B,55.1
|
||||
2023-01-04,Product C,21.1
|
||||
2023-01-05,Product A,65.6
|
||||
2023-01-05,Product B,78
|
||||
2023-01-05,Product C,31.3
|
||||
2023-01-06,Product A,75.6
|
||||
2023-01-06,Product B,89.1
|
||||
2023-01-06,Product C,63.5
|
||||
2023-01-07,Product A,67.3
|
||||
2023-01-07,Product B,77.2
|
||||
2023-01-07,Product C,43.7
|
||||
2023-01-08,Product A,96.1
|
||||
2023-01-08,Product B,97.6
|
||||
2023-01-08,Product C,59.9
|
||||
2023-01-09,Product A,96.1
|
||||
2023-01-09,Product B,100.6
|
||||
2023-01-09,Product C,66.8
|
||||
2023-01-10,Product A,101.6
|
||||
2023-01-10,Product B,108.3
|
||||
2023-01-10,Product C,56.9""",
|
||||
},
|
||||
{
|
||||
"prompt": "Show the popularity of search keywords",
|
||||
"data": """Keyword,Popularity
|
||||
Hot Word,1000
|
||||
Zao Le Wo Men,800
|
||||
Rao Jian Huo,400
|
||||
My Wish is World Peace,400
|
||||
Xiu Xiu Xiu,400
|
||||
Shenzhou 11,400
|
||||
Hundred Birds Facing the Wind,400
|
||||
China Women's Volleyball Team,400
|
||||
My Guan Na,400
|
||||
Leg Dong,400
|
||||
Hot Pot Hero,400
|
||||
Baby's Heart is Bitter,400
|
||||
Olympics,400
|
||||
Awesome My Brother,400
|
||||
Poetry and Distance,400
|
||||
Song Joong-ki,400
|
||||
PPAP,400
|
||||
Blue Thin Mushroom,400
|
||||
Rain Dew Evenly,400
|
||||
Friendship's Little Boat Says It Flips,400
|
||||
Beijing Slump,400
|
||||
Dedication,200
|
||||
Apple,200
|
||||
Dog Belt,200
|
||||
Old Driver,200
|
||||
Melon-Eating Crowd,200
|
||||
Zootopia,200
|
||||
City Will Play,200
|
||||
Routine,200
|
||||
Water Reverse,200
|
||||
Why Don't You Go to Heaven,200
|
||||
Snake Spirit Man,200
|
||||
Why Don't You Go to Heaven,200
|
||||
Samsung Explosion Gate,200
|
||||
Little Li Oscar,200
|
||||
Ugly People Need to Read More,200
|
||||
Boyfriend Power,200
|
||||
A Face of Confusion,200
|
||||
Descendants of the Sun,200""",
|
||||
},
|
||||
{
|
||||
"prompt": "Help me compare the performance of different electric vehicle brands using a scatter plot",
|
||||
"data": """Range,Charging Time,Brand Name,Average Price
|
||||
2904,46,品牌1,2350
|
||||
1231,146,品牌2,1027
|
||||
5675,324,品牌3,1242
|
||||
543,57,品牌4,6754
|
||||
326,234,品牌5,215
|
||||
1124,67,品牌6,654
|
||||
3426,81,品牌7,159
|
||||
2134,24,品牌8,28
|
||||
1234,52,品牌9,345
|
||||
2345,27,品牌10,654
|
||||
526,145,品牌11,2100
|
||||
234,93,品牌12,1679
|
||||
567,94,品牌13,1476
|
||||
789,45,品牌14,830
|
||||
469,75,品牌15,532
|
||||
5689,54,品牌16,498
|
||||
""",
|
||||
},
|
||||
{
|
||||
"prompt": "Show conversion rates for each process",
|
||||
"data": """Process,Conversion Rate,Month
|
||||
Step1,100,1
|
||||
Step2,80,1
|
||||
Step3,60,1
|
||||
Step4,40,1""",
|
||||
},
|
||||
{
|
||||
"prompt": "Show the difference in breakfast consumption between men and women",
|
||||
"data": """Day,Men-Breakfast,Women-Breakfast
|
||||
周一,15,22
|
||||
周二,12,10
|
||||
周三,15,20
|
||||
周四,10,12
|
||||
周五,13,15
|
||||
周六,10,15
|
||||
周日,12,14""",
|
||||
},
|
||||
{
|
||||
"prompt": "Help me show this person's performance in different aspects, is he a hexagonal warrior",
|
||||
"data": """dimension,performance
|
||||
Strength,5
|
||||
Speed,5
|
||||
Shooting,3
|
||||
Endurance,5
|
||||
Precision,5
|
||||
Growth,5""",
|
||||
},
|
||||
{
|
||||
"prompt": "Show data flow",
|
||||
"data": """Origin,Destination,value
|
||||
Node A,Node 1,10
|
||||
Node A,Node 2,5
|
||||
Node B,Node 2,8
|
||||
Node B,Node 3,2
|
||||
Node C,Node 2,4
|
||||
Node A,Node C,2
|
||||
Node C,Node 1,2""",
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
async def main():
|
||||
for index, item in enumerate(tasks):
|
||||
logger.info(f"Begin task {index} / {len(tasks)}!")
|
||||
agent = DataAnalysis()
|
||||
await agent.run(
|
||||
f"{prefix},chart_description:{item["prompt"]},Data:{item["data"]}"
|
||||
)
|
||||
logger.info(f"Finish with {item["prompt"]}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@@ -1,47 +0,0 @@
|
||||
import asyncio
|
||||
import time
|
||||
|
||||
from app.agent.data_analysis import DataAnalysis
|
||||
from app.flow.flow_factory import FlowFactory, FlowType
|
||||
from app.logger import logger
|
||||
|
||||
|
||||
async def run_flow():
|
||||
agents = {
|
||||
"visactor": DataAnalysis(),
|
||||
}
|
||||
|
||||
try:
|
||||
prompt = """Here's January sales data from my Amazon store. Could you analyze it thoroughly with visualizations and recommend specific, data-driven strategies to boost next month's sales by 10%?
|
||||
data_file_path = "workspace/amazon_sales_jan.csv"
|
||||
"""
|
||||
|
||||
flow = FlowFactory.create_flow(
|
||||
flow_type=FlowType.PLANNING,
|
||||
agents=agents,
|
||||
)
|
||||
logger.warning("Processing your request...")
|
||||
|
||||
try:
|
||||
start_time = time.time()
|
||||
result = await asyncio.wait_for(
|
||||
flow.execute(prompt),
|
||||
timeout=3600, # 60 minute timeout for the entire execution
|
||||
)
|
||||
elapsed_time = time.time() - start_time
|
||||
logger.info(f"Request processed in {elapsed_time:.2f} seconds")
|
||||
logger.info(result)
|
||||
except asyncio.TimeoutError:
|
||||
logger.error("Request processing timed out after 1 hour")
|
||||
logger.info(
|
||||
"Operation terminated due to timeout. Please try a simpler request."
|
||||
)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
logger.info("Operation cancelled by user.")
|
||||
except Exception as e:
|
||||
logger.error(f"Error: {str(e)}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(run_flow())
|
||||
@@ -0,0 +1,28 @@
|
||||
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(
|
||||
"""Requirement:
|
||||
1. Analyze the following data and generate a graphical data report in HTML format. The final product should be a data report.
|
||||
2. The chart should include insights.
|
||||
|
||||
Data:
|
||||
Month | Team A | Team B | Team C
|
||||
January | 1200 hours | 1350 hours | 1100 hours
|
||||
February | 1250 hours | 1400 hours | 1150 hours
|
||||
March | 1180 hours | 1300 hours | 1300 hours
|
||||
April | 1220 hours | 1280 hours | 1400 hours
|
||||
May | 1230 hours | 1320 hours | 1450 hours
|
||||
June | 1200 hours | 1250 hours | 1500 hours """
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@@ -1,190 +0,0 @@
|
||||
import asyncio
|
||||
|
||||
from app.agent.data_analysis import DataAnalysis
|
||||
from app.logger import logger
|
||||
|
||||
prefix = "帮我生成图表并保存在本地,具体为:"
|
||||
tasks = [
|
||||
{
|
||||
"prompt": "帮我展示不同区域各商品销售额",
|
||||
"data": """商品名称,region,销售额
|
||||
可乐,south,2350
|
||||
可乐,east,1027
|
||||
可乐,west,1027
|
||||
可乐,north,1027
|
||||
雪碧,south,215
|
||||
雪碧,east,654
|
||||
雪碧,west,159
|
||||
雪碧,north,28
|
||||
芬达,south,345
|
||||
芬达,east,654
|
||||
芬达,west,2100
|
||||
芬达,north,1679
|
||||
醒目,south,1476
|
||||
醒目,east,830
|
||||
醒目,west,532
|
||||
醒目,north,498
|
||||
""",
|
||||
},
|
||||
{
|
||||
"prompt": "展示各品牌市场占有率",
|
||||
"data": """品牌名称,市场份额,平均价格,净利润
|
||||
Apple,0.5,7068,314531
|
||||
Samsung,0.2,6059,362345
|
||||
Vivo,0.05,3406,234512
|
||||
Nokia,0.01,1064,-1345
|
||||
Xiaomi,0.1,4087,131345""",
|
||||
},
|
||||
{
|
||||
"prompt": "请帮我展示各产品的销售趋势",
|
||||
"data": """date,type,value
|
||||
2023-01-01,产品 A,52.9
|
||||
2023-01-01,产品 B,63.6
|
||||
2023-01-01,产品 C,11.2
|
||||
2023-01-02,产品 A,45.7
|
||||
2023-01-02,产品 B,89.1
|
||||
2023-01-02,产品 C,21.4
|
||||
2023-01-03,产品 A,67.2
|
||||
2023-01-03,产品 B,82.4
|
||||
2023-01-03,产品 C,31.7
|
||||
2023-01-04,产品 A,80.7
|
||||
2023-01-04,产品 B,55.1
|
||||
2023-01-04,产品 C,21.1
|
||||
2023-01-05,产品 A,65.6
|
||||
2023-01-05,产品 B,78
|
||||
2023-01-05,产品 C,31.3
|
||||
2023-01-06,产品 A,75.6
|
||||
2023-01-06,产品 B,89.1
|
||||
2023-01-06,产品 C,63.5
|
||||
2023-01-07,产品 A,67.3
|
||||
2023-01-07,产品 B,77.2
|
||||
2023-01-07,产品 C,43.7
|
||||
2023-01-08,产品 A,96.1
|
||||
2023-01-08,产品 B,97.6
|
||||
2023-01-08,产品 C,59.9
|
||||
2023-01-09,产品 A,96.1
|
||||
2023-01-09,产品 B,100.6
|
||||
2023-01-09,产品 C,66.8
|
||||
2023-01-10,产品 A,101.6
|
||||
2023-01-10,产品 B,108.3
|
||||
2023-01-10,产品 C,56.9 """,
|
||||
},
|
||||
{
|
||||
"prompt": "展示搜索关键词热度",
|
||||
"data": """关键词,热度
|
||||
热词,1000
|
||||
燥了我们,800
|
||||
娆贱货,400
|
||||
我的心愿是世界和平,400
|
||||
咻咻咻,400
|
||||
神舟十一号,400
|
||||
百鸟朝风,400
|
||||
中国女排,400
|
||||
我的关呐,400
|
||||
腿咚,400
|
||||
火锅英雄,400
|
||||
宝宝心里苦,400
|
||||
奥运会,400
|
||||
厉害了我的哥,400
|
||||
诗和远方,400
|
||||
宋仲基,400
|
||||
PPAP,400
|
||||
蓝瘦香菇,400
|
||||
雨露均沾,400
|
||||
友谊的小船说翻就翻就翻,400
|
||||
北京瘫,400
|
||||
敬业,200
|
||||
Apple,200
|
||||
狗带,200
|
||||
老司机,200
|
||||
吃瓜群众,200
|
||||
疯狂动物城,200
|
||||
城会玩,200
|
||||
套路,200
|
||||
水逆,200
|
||||
你咋不上天呢,200
|
||||
蛇精男,200
|
||||
你咋不上天呢,200
|
||||
三星爆炸门,200
|
||||
小李子奥斯卡,200
|
||||
人丑就要多读书,200
|
||||
男友力,200
|
||||
一脸懵逼,200
|
||||
太阳的后裔,200""",
|
||||
},
|
||||
{
|
||||
"prompt": "帮我比较不同电动汽车品牌性能,使用散点图",
|
||||
"data": """续航里程,充电时间,品牌名称,平均价格
|
||||
2904,46,品牌1,2350
|
||||
1231,146,品牌2,1027
|
||||
5675,324,品牌3,1242
|
||||
543,57,品牌4,6754
|
||||
326,234,品牌5,215
|
||||
1124,67,品牌6,654
|
||||
3426,81,品牌7,159
|
||||
2134,24,品牌8,28
|
||||
1234,52,品牌9,345
|
||||
2345,27,品牌10,654
|
||||
526,145,品牌11,2100
|
||||
234,93,品牌12,1679
|
||||
567,94,品牌13,1476
|
||||
789,45,品牌14,830
|
||||
469,75,品牌15,532
|
||||
5689,54,品牌16,498
|
||||
""",
|
||||
},
|
||||
{
|
||||
"prompt": "展示各个流程转化率",
|
||||
"data": """流程,转化率,Month
|
||||
Step1,100,1
|
||||
Step2,80,1
|
||||
Step3,60,1
|
||||
Step4,40,1""",
|
||||
},
|
||||
{
|
||||
"prompt": "展示男女早餐饭量不同",
|
||||
"data": """时间,男-早餐,女-早餐
|
||||
周一,15,22
|
||||
周二,12,10
|
||||
周三,15,20
|
||||
周四,10,12
|
||||
周五,13,15
|
||||
周六,10,15
|
||||
周日,12,14""",
|
||||
},
|
||||
{
|
||||
"prompt": "帮我展示这个人在不同方面的绩效,他是否是六边形战士",
|
||||
"data": """dimension,performance
|
||||
Strength,5
|
||||
Speed,5
|
||||
Shooting,3
|
||||
Endurance,5
|
||||
Precision,5
|
||||
Growth,5""",
|
||||
},
|
||||
{
|
||||
"prompt": "展示数据流动",
|
||||
"data": """始发地,终点站,value
|
||||
Node A,Node 1,10
|
||||
Node A,Node 2,5
|
||||
Node B,Node 2,8
|
||||
Node B,Node 3,2
|
||||
Node C,Node 2,4
|
||||
Node A,Node C,2
|
||||
Node C,Node 1,2""",
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
async def main():
|
||||
for index, item in enumerate(tasks):
|
||||
logger.info(f"Begin task {index} / {len(tasks)}!")
|
||||
agent = DataAnalysis()
|
||||
await agent.run(
|
||||
f"{prefix},chart_description:{item["prompt"]},Data:{item["data"]}"
|
||||
)
|
||||
logger.info(f"Finish with {item["prompt"]}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@@ -1,26 +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(
|
||||
"""Requriment:
|
||||
1. 分析以下数据并生成一个图文数据报告,格式为html.最终生成的产物是一个data report
|
||||
2. 图表中需要有insights
|
||||
Data:月份 团队A 团队B 团队C
|
||||
1月 1200小时 1350小时 1100小时
|
||||
2月 1250小时 1400小时 1150小时
|
||||
3月 1180小时 1300小时 1300小时
|
||||
4月 1220小时 1280小时 1400小时
|
||||
5月 1230小时 1320小时 1450小时
|
||||
6月 1200小时 1250小时 1500小时"""
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
@@ -1,35 +0,0 @@
|
||||
import asyncio
|
||||
from app.tool.chart_visualization import DataVisualization
|
||||
|
||||
|
||||
async def mock_request(delay, value):
|
||||
await asyncio.sleep(delay) # 模拟异步IO操作(如网络请求)
|
||||
return value
|
||||
|
||||
|
||||
async def main():
|
||||
# 创建多个异步任务
|
||||
tasks = [
|
||||
mock_request(1, "结果1"),
|
||||
mock_request(2, "结果2"),
|
||||
mock_request(3, "结果3"),
|
||||
]
|
||||
|
||||
# 并发执行所有任务,等待全部完成
|
||||
results = await asyncio.gather(*tasks)
|
||||
print(results) # 输出: ['结果1', '结果2', '结果3']
|
||||
|
||||
|
||||
async def test_chart():
|
||||
chartTool = DataVisualization()
|
||||
print(
|
||||
await chartTool.execute(
|
||||
"workspace/insight_metadata.json", "html", "insight", "en"
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(test_chart())
|
||||
# 运行主协程
|
||||
# asyncio.run(main())
|
||||
@@ -1,33 +0,0 @@
|
||||
|
||||
Date,Orders,Unique Customers,Units Sold,Gross Sales,Shipping Revenue,Coupon Discounts,Amazon Fees,Product Costs,Net Profit
|
||||
2025-01-01,32,32,90,4889.77,207.99,21.85,971.12,2077.17,1819.62
|
||||
2025-01-02,36,36,96,4972.16,231.16,26.48,990.58,2519.63,1435.47
|
||||
2025-01-03,73,73,205,9825.29,404.94,102.72,2000.86,4654.32,3067.4
|
||||
2025-01-04,41,41,98,5130.56,324.75,63.76,1030.67,2400.23,1635.91
|
||||
2025-01-05,44,44,106,5568.8,290.83,38.01,1110.14,2507.41,1913.24
|
||||
2025-01-06,59,59,176,9520,398.19,76.52,1888.17,4210.95,3344.35
|
||||
2025-01-07,30,30,69,3671.35,116.31,67.24,758.09,1652.76,1193.26
|
||||
2025-01-08,33,33,76,3994.76,203.96,42.57,809.22,1754.02,1388.94
|
||||
2025-01-09,34,34,72,3951.52,170.48,54.09,802.75,1815.56,1279.12
|
||||
2025-01-10,23,23,62,3668.6,163.86,27.04,697.75,1558.88,1384.95
|
||||
2025-01-11,40,39,99,5613.62,227.37,60.28,1096.68,2162.3,2294.33
|
||||
2025-01-12,56,56,143,7360.95,337.38,86.23,1471.73,3128.14,2674.85
|
||||
2025-01-13,28,28,87,4824.28,178.06,38.84,932.81,2182.23,1670.4
|
||||
2025-01-14,79,79,224,11752.01,498.92,157.39,2296.52,5288.05,4010.05
|
||||
2025-01-15,31,31,83,4417.38,162.41,22.98,879.71,1812.87,1701.81
|
||||
2025-01-16,22,22,63,3059.84,143.63,35.2,628.26,1501.43,894.94
|
||||
2025-01-17,61,61,153,8402.49,266.58,102.95,1653.07,3557.96,3088.52
|
||||
2025-01-18,45,45,111,5675.84,272.96,115.73,1154,2722.39,1683.73
|
||||
2025-01-19,50,50,130,7414.15,291.18,58.19,1432.57,3145.7,2777.71
|
||||
2025-01-20,25,25,57,2764.26,127.84,12.99,553.08,1327.38,870.81
|
||||
2025-01-21,71,70,174,9422.4,448.88,94.24,1886.04,4215.84,3226.28
|
||||
2025-01-22,27,27,85,4452.05,123.86,43.29,876.61,2144.1,1388.06
|
||||
2025-01-23,23,23,52,2743.56,169.7,16.61,571.97,1170.05,984.94
|
||||
2025-01-24,27,27,57,2916.34,128.36,80.67,588.89,1460.32,786.47
|
||||
2025-01-25,41,41,103,5169.94,283.01,57.09,1031.37,2473.02,1608.45
|
||||
2025-01-26,34,34,79,3872.66,214.95,17.74,791.34,1878.31,1185.27
|
||||
2025-01-27,27,27,67,3819.79,163.96,11.69,736.01,1466.49,1605.6
|
||||
2025-01-28,29,29,73,3763.56,219.63,39.17,754.63,1756.67,1213.09
|
||||
2025-01-29,28,28,73,3815.55,166.24,33.68,768.02,1627.24,1386.61
|
||||
2025-01-30,28,28,83,4088.25,170.95,27.9,820.94,1915.65,1323.77
|
||||
2025-01-31,36,36,91,5263.66,153.04,78.98,1037.9,2082.35,2064.44
|
||||
|
Reference in New Issue
Block a user