Revert "feat: optimize chart generation file name"

This reverts commit f1cad2f69e.
This commit is contained in:
ZJU_czx
2025-04-03 21:09:13 +08:00
parent 3f544a49c5
commit 0971678eef
4 changed files with 10 additions and 19 deletions
+1 -2
View File
@@ -1,8 +1,7 @@
SYSTEM_PROMPT = """You are an AI agent designed to data analysis / visualization task. You have various tools at your disposal that you can call upon to efficiently complete complex requests.
# Note:
1. The workspace directory is: {directory}; Read / write file in workspace
2. Generate analysis conclusion report in the end
3. Use at most One Tool in each step"""
2. Generate analysis conclusion report in the end"""
NEXT_STEP_PROMPT = """Based on user needs, break down the problem and use different tools step by step to solve it.
# Note
@@ -28,7 +28,7 @@ class VisualizationPrepare(NormalPythonExecute):
3. Save information in json file.( format: {"csvFilePath": string, "chartTitle": string}[])
## Insight Type
1. Select the insights from the data_visualization results that you want to add to the chart.
2. Save information in json file.( format: {"chartPath": string, "insights_id": number[]}[]) (chartPath is output by data_visualization tool)
2. Save information in json file.( format: {"chartPath": string, "insights_id": number[]}[])
# Note
1. You can generate one or multiple csv data with different visualization needs.
2. Make each chart data esay, clean and different.
@@ -195,11 +195,7 @@ Outputs:
return {"observation": f"{success_template}"}
async def execute(
self,
json_path: str,
output_type: str | None = "html",
tool_type: str | None = "visualization",
language: str | None = "en",
self, json_path: str, output_type: str, tool_type: str, language: str
) -> str:
try:
logger.info(f"📈 data_visualization with {json_path} in: {tool_type} ")
@@ -140,10 +140,7 @@ const setInsightTemplate = (
}
if (res) {
fs.writeFileSync(path, res, "utf-8");
return {
insight_path: path,
insight_md: res + "\n ## Next Step\nConsider add insights into chart",
};
return { insight_path: path, insight_md: res };
}
return {};
};
@@ -194,7 +191,7 @@ async function generateChart(
} = {};
const {
dataset,
userPrompt = "",
userPrompt,
directory,
width,
height,
@@ -202,12 +199,11 @@ async function generateChart(
fileName,
language,
} = options;
const chartTitle = userPrompt.trim();
try {
// Get chart spec and save in local file
const jsonDataset = isString(dataset) ? JSON.parse(dataset) : dataset;
const { spec, error, chartType } = await vmind.generateChart(
chartTitle,
userPrompt,
undefined,
jsonDataset,
{
@@ -222,18 +218,18 @@ async function generateChart(
}
spec.title = {
text: chartTitle,
text: userPrompt,
};
if (!fs.existsSync(path.join(directory, "visualization"))) {
fs.mkdirSync(path.join(directory, "visualization"));
}
const specPath = getSavedPathName(directory, chartTitle, "json");
const specPath = getSavedPathName(directory, fileName, "json");
res.chart_path = await saveChartRes({
directory,
spec,
width,
height,
fileName: chartTitle,
fileName,
outputType,
});
@@ -278,7 +274,7 @@ async function generateChart(
res = {
...res,
...setInsightTemplate(
getSavedPathName(directory, chartTitle, "md"),
getSavedPathName(directory, fileName, "md"),
userPrompt,
insightsText
),