dolphinium
commited on
Commit
·
23cb0fc
1
Parent(s):
3a70c72
fed LLM directly with raw data for now.
Browse files- llm_prompts.py +7 -22
llm_prompts.py
CHANGED
@@ -241,25 +241,8 @@ def get_synthesis_report_prompt(query, quantitative_data, qualitative_data, plan
|
|
241 |
"""
|
242 |
Generates the prompt for synthesizing a final report from the query results.
|
243 |
"""
|
244 |
-
qualitative_prompt_str = ""
|
245 |
-
dimension = plan.get('analysis_dimension', 'N/A')
|
246 |
query_filter = plan.get('query_filter', 'Not available') # Extract query filter from the plan
|
247 |
-
|
248 |
-
for group in qualitative_data.get(dimension, {}).get('groups', []):
|
249 |
-
group_value = group.get('groupValue', 'N/A')
|
250 |
-
if group.get('doclist', {}).get('docs'):
|
251 |
-
doc = group.get('doclist', {}).get('docs', [{}])[0]
|
252 |
-
title = doc.get('abstract', ['No Title'])
|
253 |
-
content_list = doc.get('content', [])
|
254 |
-
content_snip = (' '.join(content_list[0].split()[:40]) + '...') if content_list else 'No content available.'
|
255 |
-
metric_val_raw = doc.get(plan.get('sort_field_for_examples'), 'N/A')
|
256 |
-
metric_val = metric_val_raw[0] if isinstance(metric_val_raw, list) else metric_val_raw
|
257 |
-
|
258 |
-
qualitative_prompt_str += f"- **For category `{group_value}`:**\n"
|
259 |
-
qualitative_prompt_str += f" - **Top Example Title:** {title}\n"
|
260 |
-
qualitative_prompt_str += f" - **Metric Value:** {metric_val}\n"
|
261 |
-
qualitative_prompt_str += f" - **Content Snippet:** {content_snip}\n\n"
|
262 |
-
|
263 |
return f"""
|
264 |
You are a top-tier business intelligence analyst. Your task is to write an insightful, data-driven report for an executive. You must synthesize quantitative data (the 'what') with qualitative examples (the 'why') to tell a complete story.
|
265 |
|
@@ -280,8 +263,10 @@ This data shows the high-level aggregates based on the filters above.
|
|
280 |
```
|
281 |
|
282 |
**4. Qualitative Data (The 'Why'):**
|
283 |
-
These are the
|
284 |
-
|
|
|
|
|
285 |
|
286 |
---
|
287 |
### REPORTING INSTRUCTIONS
|
@@ -298,7 +283,7 @@ Your report must be in clean, professional Markdown and follow this structure pr
|
|
298 |
|
299 |
`### Key Drivers & Illustrative Examples`
|
300 |
- **This is the most important section.** Explain the "so what?" behind the numbers.
|
301 |
-
- Use the qualitative examples to explain *why* a category is high or low.
|
302 |
|
303 |
`### Deeper Dive: Suggested Follow-up Analyses`
|
304 |
- Propose 2-3 logical next questions based on your analysis to uncover deeper trends.
|
@@ -411,4 +396,4 @@ plt.tight_layout()
|
|
411 |
|
412 |
Now, generate the raw Python code to create the best possible visualization for the user's goal based on the provided data.
|
413 |
Do not wrap the code in ```python ... ```.
|
414 |
-
"""
|
|
|
241 |
"""
|
242 |
Generates the prompt for synthesizing a final report from the query results.
|
243 |
"""
|
|
|
|
|
244 |
query_filter = plan.get('query_filter', 'Not available') # Extract query filter from the plan
|
245 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
return f"""
|
247 |
You are a top-tier business intelligence analyst. Your task is to write an insightful, data-driven report for an executive. You must synthesize quantitative data (the 'what') with qualitative examples (the 'why') to tell a complete story.
|
248 |
|
|
|
263 |
```
|
264 |
|
265 |
**4. Qualitative Data (The 'Why'):**
|
266 |
+
These are the most significant documents driving the numbers for each category, presented as raw JSON from Solr's grouping feature.
|
267 |
+
```json
|
268 |
+
{json.dumps(qualitative_data, indent=2)}
|
269 |
+
```
|
270 |
|
271 |
---
|
272 |
### REPORTING INSTRUCTIONS
|
|
|
283 |
|
284 |
`### Key Drivers & Illustrative Examples`
|
285 |
- **This is the most important section.** Explain the "so what?" behind the numbers.
|
286 |
+
- Use the qualitative examples from the raw JSON to explain *why* a category is high or low. For each main category, reference the top example document's title (e.g., 'abstract' field) and key metrics.
|
287 |
|
288 |
`### Deeper Dive: Suggested Follow-up Analyses`
|
289 |
- Propose 2-3 logical next questions based on your analysis to uncover deeper trends.
|
|
|
396 |
|
397 |
Now, generate the raw Python code to create the best possible visualization for the user's goal based on the provided data.
|
398 |
Do not wrap the code in ```python ... ```.
|
399 |
+
"""
|