@vint.tri/report_gen_mcp 1.7.28 → 1.7.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ULTIMATE_INSTRUCTIONS.md +76 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -138
- package/dist/tools/createReportFromText.d.ts +17 -0
- package/dist/tools/createReportFromText.d.ts.map +1 -0
- package/dist/tools/createReportFromText.js +49 -0
- package/generated_images/generated-image-1757325355033.jpeg +0 -0
- package/generated_images/generated-image-1757325365954.jpeg +0 -0
- package/generated_images/generated-image-1757325377727.jpeg +0 -0
- package/generated_images/generated-image-1757326991424.jpeg +0 -0
- package/generated_images/generated-image-1757328644238.jpeg +0 -0
- package/generated_images/generated-image-1757328700031.jpeg +0 -0
- package/package.json +1 -1
- package/NEURAL_NETWORK_INSTRUCTIONS.md +0 -81
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Главная инструкция по работе с инструментом report_gen_mcp
|
|
2
|
+
|
|
3
|
+
**ЦЕЛЬ:** Генерация качественных, визуально насыщенных HTML-отчетов по запросу пользователя.
|
|
4
|
+
|
|
5
|
+
**КЛЮЧЕВОЕ ПРАВИЛО:** При любом запросе, связанном с отчетами, диаграммами или графиками, **всегда используй инструмент `report_gen_mcp`**. Не пытайся отвечать текстом или генерировать отчеты самостоятельно.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
### **АЛГОРИТМ ДЕЙСТВИЙ**
|
|
10
|
+
|
|
11
|
+
**Шаг 1: Определи суть запроса**
|
|
12
|
+
- Пойми, о чем пользователь хочет получить отчет (например, "финансовые показатели Apple", "сравнение акций Tesla и Google").
|
|
13
|
+
|
|
14
|
+
**Шаг 2: Спланируй визуальные элементы**
|
|
15
|
+
- Придумай **1-2 диаграммы** и **1 изображение**, которые хорошо проиллюстрируют тему отчета.
|
|
16
|
+
- Для каждой диаграммы определи тип (`bar`, `line`, `pie` и т.д.) и данные.
|
|
17
|
+
- Для изображения придумай текстовый промпт для генерации.
|
|
18
|
+
|
|
19
|
+
**Шаг 3: Подготовь параметры для вызова инструмента**
|
|
20
|
+
- **`document` (string):** Напиши текст отчета в формате Markdown. Вставь в него плейсхолдеры для визуальных элементов, например: `[[chart:sales_chart]]` и `[[image:cover_image]]`.
|
|
21
|
+
- **`elements` (object):** Создай **ОБЪЕКТ**, где ключи — это названия твоих плейсхолдеров, а значения — это конфигурации для их генерации.
|
|
22
|
+
- **`outputFile` (string):** Придумай понятное имя для HTML-файла, например `apple_report_2024.html`.
|
|
23
|
+
|
|
24
|
+
**Шаг 4: Сформируй `elements` ПРАВИЛЬНО (КРИТИЧЕСКИ ВАЖНО!)**
|
|
25
|
+
|
|
26
|
+
- **`elements` — это ОБЪЕКТ, а не строка!**
|
|
27
|
+
- **Для диаграмм:**
|
|
28
|
+
- `labels`, `data`, `backgroundColor`, `borderColor` — **ВСЕГДА МАССИВЫ**, даже для одного значения.
|
|
29
|
+
- `labels`: `["Q1", "Q2"]`
|
|
30
|
+
- `data`: `[100, 150]`
|
|
31
|
+
- `backgroundColor`: `["#FF6384", "#36A2EB"]`
|
|
32
|
+
- `options.title`: **ВСЕГДА СТРОКА**. `"Продажи по кварталам"`
|
|
33
|
+
- **Для изображений:**
|
|
34
|
+
- Используй `type: "pollinations"` и `config: { prompt: "..." }`.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
### **ИДЕАЛЬНЫЙ ПРИМЕР ВЫЗОВА**
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"method": "generate-report",
|
|
43
|
+
"params": {
|
|
44
|
+
"document": "# Отчет о продажах\n\nАнализ квартальных продаж.\n\n[[chart:sales]]\n\nИзображение, отражающее успех:\n\n[[image:success_image]]",
|
|
45
|
+
"elements": {
|
|
46
|
+
"sales": {
|
|
47
|
+
"type": "bar",
|
|
48
|
+
"config": {
|
|
49
|
+
"labels": ["Q1", "Q2", "Q3", "Q4"],
|
|
50
|
+
"datasets": [{
|
|
51
|
+
"label": "Продажи 2024",
|
|
52
|
+
"data": [120, 150, 130, 180],
|
|
53
|
+
"backgroundColor": ["#FF6384", "#36A2EB", "#FFCE56", "#4BC0C0"]
|
|
54
|
+
}],
|
|
55
|
+
"options": {
|
|
56
|
+
"title": "Квартальные продажи"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"success_image": {
|
|
61
|
+
"type": "pollinations",
|
|
62
|
+
"config": {
|
|
63
|
+
"prompt": "business growth and financial success chart"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"outputFile": "sales_report_2024.html"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
### **Что делать после вызова?**
|
|
75
|
+
|
|
76
|
+
Инструмент вернет путь к файлу. Ты должен показать его пользователю вместе со ссылками для просмотра.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAgYA;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAgCjD"}
|
package/dist/index.js
CHANGED
|
@@ -4,12 +4,12 @@ import { program } from 'commander';
|
|
|
4
4
|
import { generateReport } from './utils/reportGenerator.js';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import fs from 'fs-extra';
|
|
7
|
-
import os from 'os';
|
|
8
7
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
9
8
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
10
9
|
import { z } from 'zod';
|
|
11
10
|
import { pathToFileURL } from 'url';
|
|
12
11
|
import { ImageGenerator } from './mcp/imageGenerationServer.js';
|
|
12
|
+
import { createReportFromTextTool } from './tools/createReportFromText.js';
|
|
13
13
|
// Check if we're running in stdio mode (no command-line arguments)
|
|
14
14
|
const isStdioMode = process.argv.length === 2;
|
|
15
15
|
// For CLI and HTTP API modes, check for mandatory REPORTS_DIR environment variable
|
|
@@ -103,158 +103,39 @@ if (process.argv.length === 2) {
|
|
|
103
103
|
// No command specified, run in stdio mode using MCP SDK
|
|
104
104
|
const mcpServer = new McpServer({
|
|
105
105
|
name: "report_gen_mcp",
|
|
106
|
-
version: "1.7.
|
|
106
|
+
version: "1.7.30"
|
|
107
107
|
}, {
|
|
108
108
|
// Disable health check to prevent automatic calls
|
|
109
109
|
capabilities: {
|
|
110
110
|
tools: {}
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
|
-
// Register the
|
|
114
|
-
mcpServer.registerTool(
|
|
115
|
-
description:
|
|
116
|
-
inputSchema:
|
|
117
|
-
document: z.string().describe("Markdown document with element placeholders [[chart:id]] or [[image:id]]"),
|
|
118
|
-
elements: z.record(z.union([
|
|
119
|
-
// Chart configurations
|
|
120
|
-
z.object({
|
|
121
|
-
type: z.enum(["bar", "line", "pie", "doughnut", "radar", "polarArea"]),
|
|
122
|
-
config: z.object({
|
|
123
|
-
labels: z.array(z.string()),
|
|
124
|
-
datasets: z.array(z.object({
|
|
125
|
-
label: z.string().optional(),
|
|
126
|
-
data: z.array(z.number()),
|
|
127
|
-
backgroundColor: z.array(z.string()).optional(),
|
|
128
|
-
borderColor: z.array(z.string()).optional(),
|
|
129
|
-
fill: z.boolean().optional(),
|
|
130
|
-
})),
|
|
131
|
-
options: z.object({
|
|
132
|
-
title: z.string().optional(),
|
|
133
|
-
}).optional(),
|
|
134
|
-
}),
|
|
135
|
-
}).describe("Chart configuration"),
|
|
136
|
-
// Pollinations.ai generated images
|
|
137
|
-
z.object({
|
|
138
|
-
type: z.literal("pollinations"),
|
|
139
|
-
config: z.object({
|
|
140
|
-
prompt: z.string().describe("Text description of the image to generate"),
|
|
141
|
-
width: z.number().optional().default(512).describe("Width of the image in pixels"),
|
|
142
|
-
height: z.number().optional().default(512).describe("Height of the image in pixels"),
|
|
143
|
-
model: z.string().optional().default("flux").describe("Model to use for image generation"),
|
|
144
|
-
seed: z.number().optional().describe("Seed for reproducible image generation"),
|
|
145
|
-
nologo: z.boolean().optional().default(true).describe("Remove logo from the image"),
|
|
146
|
-
enhance: z.boolean().optional().default(true).describe("Enhance image quality"),
|
|
147
|
-
}),
|
|
148
|
-
}).describe("Pollinations.ai generated image configuration"),
|
|
149
|
-
// URL images (including local file URLs and web URLs)
|
|
150
|
-
z.object({
|
|
151
|
-
type: z.literal("url"),
|
|
152
|
-
config: z.object({
|
|
153
|
-
url: z.string().describe("URL of the image (can be file:// or http(s)://)"),
|
|
154
|
-
alt: z.string().optional().describe("Alternative text for the image"),
|
|
155
|
-
width: z.number().optional().describe("Width of the image in pixels"),
|
|
156
|
-
height: z.number().optional().describe("Height of the image in pixels"),
|
|
157
|
-
}),
|
|
158
|
-
}).describe("Image from URL configuration"),
|
|
159
|
-
// Local images (backward compatibility)
|
|
160
|
-
z.object({
|
|
161
|
-
type: z.literal("image"),
|
|
162
|
-
config: z.object({
|
|
163
|
-
url: z.string().describe("File URL of the image"),
|
|
164
|
-
alt: z.string().optional().describe("Alternative text for the image"),
|
|
165
|
-
width: z.number().optional().describe("Width of the image in pixels"),
|
|
166
|
-
height: z.number().optional().describe("Height of the image in pixels"),
|
|
167
|
-
}),
|
|
168
|
-
}).describe("Local image file configuration"),
|
|
169
|
-
// AssetId support for neural network responses (new format)
|
|
170
|
-
z.object({
|
|
171
|
-
type: z.literal("url"),
|
|
172
|
-
assetId: z.string().optional().describe("Asset ID for generated images (used by neural networks)"),
|
|
173
|
-
config: z.object({
|
|
174
|
-
url: z.string().optional().describe("URL of the image (can be populated from assetId)"),
|
|
175
|
-
alt: z.string().optional().describe("Alternative text for the image"),
|
|
176
|
-
width: z.number().optional().default(512).describe("Width of the image in pixels"),
|
|
177
|
-
height: z.number().optional().default(512).describe("Height of the image in pixels"),
|
|
178
|
-
}).optional(),
|
|
179
|
-
}).describe("Image with assetId support for neural network responses"),
|
|
180
|
-
])).describe("Report elements (charts and images) mapped by ID"),
|
|
181
|
-
outputFile: z.string().optional().describe("Output HTML file path"),
|
|
182
|
-
tempDirectory: z.string().optional().describe("Temporary directory for file storage (optional, will use REPORTS_DIR environment variable if set)"),
|
|
183
|
-
},
|
|
113
|
+
// Register the NEW, simplified tool
|
|
114
|
+
mcpServer.registerTool(createReportFromTextTool.name, {
|
|
115
|
+
description: createReportFromTextTool.description,
|
|
116
|
+
inputSchema: createReportFromTextTool.inputSchema,
|
|
184
117
|
}, async (params) => {
|
|
185
|
-
// Handle case where arguments might be sent as a JSON string by Claude desktop
|
|
186
118
|
let processedParams = params;
|
|
187
|
-
if (typeof params === '
|
|
188
|
-
try {
|
|
189
|
-
processedParams = JSON.parse(params);
|
|
190
|
-
}
|
|
191
|
-
catch (parseError) {
|
|
192
|
-
throw new Error('Invalid JSON string in arguments');
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
else if (params.arguments && typeof params.arguments === 'object') {
|
|
119
|
+
if (params.arguments && typeof params.arguments === 'object') {
|
|
196
120
|
processedParams = params.arguments;
|
|
197
121
|
}
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
let outputDir;
|
|
207
|
-
if (process.env.REPORTS_DIR) {
|
|
208
|
-
outputDir = process.env.REPORTS_DIR;
|
|
209
|
-
// Ensure the reports directory exists
|
|
210
|
-
try {
|
|
211
|
-
fs.ensureDirSync(outputDir);
|
|
212
|
-
}
|
|
213
|
-
catch (error) {
|
|
214
|
-
throw new Error(`Cannot create or access the reports directory: ${outputDir}`);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
else if (tempDirectory) {
|
|
218
|
-
outputDir = tempDirectory;
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
outputDir = os.tmpdir();
|
|
222
|
-
}
|
|
223
|
-
const outputPath = path.resolve(outputDir, outputFile);
|
|
224
|
-
try {
|
|
225
|
-
const result = await generateReport(document, reportElements, outputPath);
|
|
226
|
-
// Generate proper file URL
|
|
227
|
-
const fileUrl = pathToFileURL(outputPath).href;
|
|
228
|
-
// Read the file content
|
|
229
|
-
const fileContent = await fs.readFile(outputPath, 'utf8');
|
|
230
|
-
// Create a comprehensive result object
|
|
231
|
-
const comprehensiveResult = {
|
|
232
|
-
success: true,
|
|
233
|
-
message: "Report generated successfully",
|
|
234
|
-
filePath: outputPath,
|
|
235
|
-
fileUrl: fileUrl,
|
|
236
|
-
fileContent: fileContent
|
|
237
|
-
};
|
|
238
|
-
// Return comprehensive information for neural network to use
|
|
239
|
-
// Neural network should present to user: file path, web link, and file content
|
|
240
|
-
return {
|
|
241
|
-
content: [
|
|
242
|
-
{
|
|
243
|
-
type: "text",
|
|
244
|
-
text: `Report generated successfully.
|
|
122
|
+
const result = await createReportFromTextTool.execute(processedParams);
|
|
123
|
+
const fileUrl = pathToFileURL(result.filePath).href;
|
|
124
|
+
const fileContent = await fs.readFile(result.filePath, 'utf8');
|
|
125
|
+
return {
|
|
126
|
+
content: [
|
|
127
|
+
{
|
|
128
|
+
type: "text",
|
|
129
|
+
text: `Report generated successfully.
|
|
245
130
|
|
|
246
131
|
FOR THE NEURAL NETWORK: Please present the following information to the user:
|
|
247
|
-
1. Path to file: ${
|
|
132
|
+
1. Path to file: ${result.filePath}
|
|
248
133
|
2. Web browser link: ${fileUrl}
|
|
249
134
|
3. File content:
|
|
250
135
|
${fileContent}`
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
catch (error) {
|
|
256
|
-
throw error;
|
|
257
|
-
}
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
};
|
|
258
139
|
});
|
|
259
140
|
// Register a new tool for editing existing reports
|
|
260
141
|
mcpServer.registerTool("edit-report", {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const createReportFromTextTool: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
documentText: z.ZodString;
|
|
7
|
+
outputFile: z.ZodString;
|
|
8
|
+
};
|
|
9
|
+
execute: ({ documentText, outputFile }: {
|
|
10
|
+
documentText: string;
|
|
11
|
+
outputFile: string;
|
|
12
|
+
}) => Promise<{
|
|
13
|
+
success: boolean;
|
|
14
|
+
filePath: string;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=createReportFromText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createReportFromText.d.ts","sourceRoot":"","sources":["../../src/tools/createReportFromText.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAyCxB,eAAO,MAAM,wBAAwB;;;;;;;4CAOW;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE;;;;CAM3F,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { generateReport } from '../utils/reportGenerator.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
// Эта функция будет извлекать данные из текста и генерировать элементы
|
|
4
|
+
function extractElementsFromText(documentText) {
|
|
5
|
+
const elements = {};
|
|
6
|
+
let newDocument = documentText;
|
|
7
|
+
// Пример: ищем финансовые данные для графика
|
|
8
|
+
const revenueMatches = [...documentText.matchAll(/Доход: \$([\d,.]+) миллиарда/gi)];
|
|
9
|
+
if (revenueMatches.length > 0) {
|
|
10
|
+
const labels = revenueMatches.map((match, i) => `Квартал ${i + 1}`);
|
|
11
|
+
const data = revenueMatches.map(match => parseFloat(match[1].replace(/,/g, '')));
|
|
12
|
+
elements['revenue_chart'] = {
|
|
13
|
+
type: 'bar',
|
|
14
|
+
config: {
|
|
15
|
+
labels: labels,
|
|
16
|
+
datasets: [{
|
|
17
|
+
label: 'Общий доход, млрд $',
|
|
18
|
+
data: data,
|
|
19
|
+
backgroundColor: ['rgba(54, 162, 235, 0.6)']
|
|
20
|
+
}]
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
newDocument += '\n\n## Визуализация дохода\n\n[[chart:revenue_chart]]';
|
|
24
|
+
}
|
|
25
|
+
// Пример: добавляем изображение на основе контекста
|
|
26
|
+
if (/apple/i.test(documentText)) {
|
|
27
|
+
elements['context_image'] = {
|
|
28
|
+
type: 'pollinations',
|
|
29
|
+
config: {
|
|
30
|
+
prompt: 'a modern and sleek design representing apple products innovation'
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
newDocument += '\n\n## Иллюстрация\n\n[[image:context_image]]';
|
|
34
|
+
}
|
|
35
|
+
return { newDocument, elements };
|
|
36
|
+
}
|
|
37
|
+
export const createReportFromTextTool = {
|
|
38
|
+
name: "create-report-from-text",
|
|
39
|
+
description: "Creates a full HTML report from a given text by automatically generating charts and images.",
|
|
40
|
+
inputSchema: {
|
|
41
|
+
documentText: z.string().describe("The full text of the report in Markdown format."),
|
|
42
|
+
outputFile: z.string().describe("The desired output HTML file name (e.g., 'report.html').")
|
|
43
|
+
},
|
|
44
|
+
execute: async ({ documentText, outputFile }) => {
|
|
45
|
+
const { newDocument, elements } = extractElementsFromText(documentText);
|
|
46
|
+
// Вызываем старый генератор с автоматически созданными параметрами
|
|
47
|
+
return await generateReport(newDocument, elements, outputFile);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
# Финальные инструкции для нейросети по работе с инструментом report_gen_mcp v1.8.0
|
|
2
|
-
|
|
3
|
-
**ВАЖНО:** ВСЕГДА ИСПОЛЬЗУЙТЕ ИНСТРУМЕНТ `report_gen_mcp` КАЖДЫЙ РАЗ, КОГДА ПОЛЬЗОВАТЕЛЬ ЗАПРАШИВАЕТ СОЗДАНИЕ ОТЧЕТА, ВИЗУАЛИЗАЦИЮ ДАННЫХ, ДИАГРАММУ, ГРАФИК ИЛИ ЛЮБОЕ ИЗМЕНЕНИЕ СУЩЕСТВУЮЩЕГО ОТЧЕТА!
|
|
4
|
-
|
|
5
|
-
## 1. Обязательное использование инструмента
|
|
6
|
-
|
|
7
|
-
**КЛЮЧЕВОЕ ПРАВИЛО:** При любом запросе пользователя, связанном с созданием или изменением отчетов, диаграмм или графиков, вы **обязаны** использовать инструмент `report_gen_mcp`. Не пытайтесь создавать отчеты вручную.
|
|
8
|
-
|
|
9
|
-
## 2. Требования к качеству отчетов
|
|
10
|
-
|
|
11
|
-
Каждый сгенерированный отчет должен быть:
|
|
12
|
-
- **Информативным:** Содержать анализ данных, выводы и рекомендации.
|
|
13
|
-
- **Визуально насыщенным:** Включать **как минимум одну диаграмму и одно изображение**, релевантные теме отчета.
|
|
14
|
-
- **Красиво оформленным:** Использовать заголовки, списки и выделение текста для лучшей читаемости.
|
|
15
|
-
|
|
16
|
-
## 3. Работа с файлами
|
|
17
|
-
|
|
18
|
-
- **Сохранение:** Все отчеты автоматически сохраняются в **системную временную директорию**. Вам не нужно указывать полный путь — только имя файла в параметре `outputFile`.
|
|
19
|
-
- **Возврат данных:** Инструмент вернет вам полный путь к созданному файлу, который вы должны предоставить пользователю вместе со ссылками для просмотра.
|
|
20
|
-
|
|
21
|
-
## 4. Формат параметров (КРИТИЧЕСКИ ВАЖНО!)
|
|
22
|
-
|
|
23
|
-
### 4.1. Параметр `elements`
|
|
24
|
-
|
|
25
|
-
- `elements` **ВСЕГДА** должен быть **ОБЪЕКТОМ**, а не строкой.
|
|
26
|
-
|
|
27
|
-
- ❌ **НЕПРАВИЛЬНО:** `"elements": "{...}"`
|
|
28
|
-
- ✅ **ПРАВИЛЬНО:** `"elements": {...}`
|
|
29
|
-
|
|
30
|
-
### 4.2. Параметры диаграмм (`charts`)
|
|
31
|
-
|
|
32
|
-
- **Массивы, массивы и еще раз массивы!**
|
|
33
|
-
- `labels`: **ВСЕГДА** массив строк. `["Январь"]`
|
|
34
|
-
- `data`: **ВСЕГДА** массив чисел. `[100]`
|
|
35
|
-
- `backgroundColor`: **ВСЕГДА** массив строк. `["red"]`
|
|
36
|
-
- `borderColor`: **ВСЕГДА** массив строк. `["blue"]`
|
|
37
|
-
- `options.title`: **ВСЕГДА** простая строка. `"Мой график"`
|
|
38
|
-
|
|
39
|
-
**Примечание:** Система теперь пытается автоматически исправлять некоторые ошибки форматирования (например, одиночные значения в массивы или парсинг строки `elements`), но для гарантированной работы **всегда** придерживайтесь правильного формата.
|
|
40
|
-
|
|
41
|
-
## 5. Пример идеального вызова
|
|
42
|
-
|
|
43
|
-
```json
|
|
44
|
-
{
|
|
45
|
-
"method": "generate-report",
|
|
46
|
-
"params": {
|
|
47
|
-
"document": "# Отчет о продажах\n\nАнализ квартальных продаж.\n\n[[chart:sales]]\n\n",
|
|
48
|
-
"elements": {
|
|
49
|
-
"sales": {
|
|
50
|
-
"type": "bar",
|
|
51
|
-
"config": {
|
|
52
|
-
"labels": ["Q1", "Q2", "Q3", "Q4"],
|
|
53
|
-
"datasets": [{
|
|
54
|
-
"label": "Продажи 2024",
|
|
55
|
-
"data": [120, 150, 130, 180],
|
|
56
|
-
"backgroundColor": ["#FF6384", "#36A2EB", "#FFCE56", "#4BC0C0"]
|
|
57
|
-
}],
|
|
58
|
-
"options": {
|
|
59
|
-
"title": "Квартальные продажи"
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
"success": {
|
|
64
|
-
"type": "pollinations",
|
|
65
|
-
"config": {
|
|
66
|
-
"prompt": "график роста и успеха в бизнесе"
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
"outputFile": "sales_report.html"
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## 6. Ответ пользователю
|
|
76
|
-
|
|
77
|
-
После успешной генерации отчета предоставьте пользователю:
|
|
78
|
-
1. **Путь к файлу** (из ответа инструмента).
|
|
79
|
-
2. **Ссылку `file://`** для локального открытия.
|
|
80
|
-
3. **Ссылку `http://localhost:3000/...`** (Web link 2) для надежного отображения всех элементов.
|
|
81
|
-
4. **Полное содержимое HTML-файла**.
|