.
This commit is contained in:
@@ -154,17 +154,17 @@ public class OpenAiChartService {
|
||||
// learningsAsString + "\n---";
|
||||
// }
|
||||
private String buildChartDataPrompt(String learningsAsString) {
|
||||
return "You are an AI data analyst. Carefully analyze the following text. Find all sets of numerical data suitable for simple bar or pie charts. For EACH data set you find, create a JSON object."
|
||||
return "You are an AI data analyst robot. Carefully analyze the following text. Find all sets of numerical data suitable for simple bar or pie charts. For EACH data set you find, create a JSON object."
|
||||
+
|
||||
" Return ONLY a JSON array of these objects. The structure of each object MUST STRICTLY be: " +
|
||||
"{\"chartType\": \"bar\" or \"pie\", \"title\": \"Chart Title\", \"labels\": [\"Label 1\"], \"data\": [number1]}. "
|
||||
"{\"chartType\": \"bar\" or \"pie\", \"title\": \"Chart Title\", \"labels\": [\"Label 1\"], \"data\": [number1, number2]}. "
|
||||
+
|
||||
|
||||
// --- НОВЫЕ ВАЖНЫЕ ПРАВИЛА ---
|
||||
"IMPORTANT RULES:\n" +
|
||||
"1. The 'data' array MUST contain ONLY NUMBERS (e.g., 1.08), not text like 'KZT1.08 trillion'.\n" +
|
||||
"2. DO NOT omit any keys.\n\n" +
|
||||
// --- КОНЕЦ НОВЫХ ПРАВИЛ ---
|
||||
"CRITICAL RULES:\n" +
|
||||
"1. The 'data' array MUST contain ONLY NUMBERS. Do not include text, units, or placeholders like 'trillion' or 'placeholder'. Convert all values to simple numbers (e.g., '1.08 trillion' becomes 1.08).\n"
|
||||
+
|
||||
"2. If a numerical value is not available for a label, you MUST use the number 0 as a placeholder.\n" +
|
||||
"3. DO NOT omit any keys.\n\n" +
|
||||
|
||||
"Example of a correct response:\n" +
|
||||
"[{\"chartType\":\"bar\",\"title\":\"Growth by Year\",\"labels\":[\"2023\",\"2024\"],\"data\":[100,150]}]"
|
||||
|
||||
@@ -92,38 +92,23 @@ public class ReportSynthesisService {
|
||||
}
|
||||
|
||||
private String buildTextPrompt(String originalQuery, String learningsAsString, String lang) {
|
||||
return "You are a professional AI analyst. Your task is to write a detailed, structured, and well-written report based on the provided data."
|
||||
return "You are a professional AI report writer. Your task is to write a detailed and structured report based on the provided data."
|
||||
+
|
||||
"\n\n" +
|
||||
"IMPORTANT: Do not ask any clarifying questions at the end. Do not write any personal introductions or conclusions outside of the report's content. Your response must be ONLY the report itself and nothing more."
|
||||
"CRITICAL INSTRUCTION: Your entire response must be ONLY the final report in Markdown format. Start directly with the main title. Do NOT include any conversational text, introductions, summaries of your instructions, or any questions at the end. Your output should be pure Markdown."
|
||||
+
|
||||
"\n\n" +
|
||||
"### Research Topic:\n" +
|
||||
originalQuery + "\n\n" +
|
||||
"### Collected Data (Learnings):\n" +
|
||||
learningsAsString + "\n\n" +
|
||||
"### Your Task:\n" +
|
||||
"1. **Language:** Write the report entirely in the " + (lang == null ? "English" : lang)
|
||||
+ " language.\n" +
|
||||
"2. **Structure:** The report must have a clear structure: an introduction, a main body with several sections and subsections, and a conclusion.\n"
|
||||
"### Report Requirements:\n" +
|
||||
"1. **Language:** " + (lang == null ? "English" : lang) + ".\n" +
|
||||
"2. **Structure:** The report must have an introduction, a main body with sections (using `##`) and subsections (using `###`), and a conclusion.\n"
|
||||
+
|
||||
"3. **Formatting:** Use Markdown. For main section headings, use `##`. For subsections, use `###`. For lists, use `-`.\n"
|
||||
+
|
||||
"4. **Style:** Transform the disjointed learnings into a single, cohesive, and well-written article. Do not just list the facts; analyze, summarize, and build a logical narrative.\n"
|
||||
+
|
||||
"5. **Constraint:** Use ONLY the information provided in the collected data. Do not add any information that is not present in the source learnings.\n\n"
|
||||
+
|
||||
"Start the report with a main title (using `#`).";
|
||||
}
|
||||
|
||||
private String buildChartDataPrompt(String learningsAsString) {
|
||||
return "Ты — AI-аналитик данных. Внимательно проанализируй следующий текст. Найди в нём все наборы числовых данных, которые можно представить в виде простых диаграмм (столбчатых или круговых). Для КАЖДОГО найденного набора данных создай JSON-объект. Верни ТОЛЬКО JSON-массив этих объектов. Структура каждого объекта: {\"chartType\": \"bar\" или \"pie\", \"title\": \"Название диаграммы\", \"labels\": [\"Метка 1\"], \"data\": [число1]}. Если подходящих данных нет, верни пустой массив []. Текст для анализа:\n---\n"
|
||||
+ learningsAsString + "\n---";
|
||||
}
|
||||
|
||||
private String buildSvgPrompt(String json) {
|
||||
return "Ты — эксперт по визуализации данных. На основе следующего JSON, сгенерируй полный и валидный SVG-код для диаграммы. SVG должен быть стильным и читаемым, с подписями на русском языке. Не добавляй никаких комментариев, верни ТОЛЬКО SVG-код. JSON с данными:\n---\n"
|
||||
+ json + "\n---";
|
||||
"3. **Style:** Transform the disjointed learnings into a cohesive, well-written article.\n" +
|
||||
"4. **Constraint:** Use ONLY the information from the 'Collected Data'.\n\n" +
|
||||
"Begin your response immediately with the main title using '#'.";
|
||||
}
|
||||
|
||||
private String extractJsonArray(String ollamaResponse) {
|
||||
|
||||
Reference in New Issue
Block a user