community_report_prompt.py
Overview
This file defines a comprehensive prompt template named COMMUNITY_REPORT_PROMPT intended for use with AI language models in the context of community information discovery and reporting. The prompt guides an AI assistant to generate detailed, structured, and grounded reports about a community based on given entities, their relationships, and optionally associated claims.
The main purpose of this file is to encapsulate the instructions, expected output format, grounding rules, and example inputs for generating a JSON-formatted narrative report. This report aims to inform human analysts and decision-makers about the makeup, impact, and key insights related to the community's network of entities.
Key Components
Constant: COMMUNITY_REPORT_PROMPT
Type:
strDescription:
A large multi-line string that acts as a prompt template for instructing an AI assistant to create a community report. It includes:Role definition: Assistant acts as an AI supporting a human analyst.
Goal: Write a comprehensive report on a community given entity and relationship data.
Report structure: Specifies the sections of the report:
TITLE
SUMMARY
IMPACT SEVERITY RATING (0-10 float)
RATING EXPLANATION
DETAILED FINDINGS (5-10 key insights)
Output format: Requires JSON-formatted string with specific keys.
Grounding rules: How to reference supporting data when making claims.
Example Input and Output: Demonstrates how entities and relationships are provided and how the output should be formatted.
Instructions for Real Data: How to replace placeholders {entity_df} and
{relation_df}with real data.Strict constraint: No hallucination or fabrication; only use provided data.
Detailed Explanation
Purpose
The prompt is designed to be passed into a large language model (LLM) framework that supports prompt engineering. By providing this detailed instruction, the LLM is expected to generate:
A well-structured JSON report summarizing a community network.
A rating of the community's impact severity.
Grounded insights with explicit references to the input data.
This supports analysts who need synthesized, explainable intelligence about complex entity networks.
Usage Example
Suppose a system collects CSV data of entities and relationships within a community (e.g., organizations, events, people). The system would:
Format the CSV data into strings.
Replace {entity_df} and
{relation_df}placeholders with these strings.Append the entire prompt text to the LLM input.
Send the prompt to the LLM for completion.
Parse the LLM output JSON report for presentation or further analysis.
Implementation Details and Algorithms
Prompt Engineering:
The file uses a single large prompt string to encapsulate all instructions and examples. This approach leverages the LLM's few-shot learning and in-context learning abilities.Grounding Rules Enforcement:
The prompt explicitly instructs the LLM to only include information supported by the input data, referencing datasets and record IDs concisely to maintain transparency and trustworthiness.Structured Output:
The prompt demands a JSON output, enabling downstream systems to parse and use the report automatically.Data Referencing Format:
The grounding rule format allows citing multiple datasets and limiting record IDs shown (max 5 with "+more" if applicable), balancing detail and readability.
Interaction with Other System Components
Data Preprocessing Module:
Prepares entity and relationship CSV data, converting it into the format expected by the prompt.LLM Interface Module:
Injects theCOMMUNITY_REPORT_PROMPTwith real data and sends it to the language model API, then receives and processes the JSON output.Post-Processing/Visualization:
Parses the JSON report to display summaries, ratings, and findings in dashboards or reports.Decision Support Systems:
Use the generated report to inform risk assessments, compliance checks, or strategic actions related to the community.
Mermaid Diagram: Flowchart of Main Functional Elements
flowchart TD
A[Prepare Entity Data CSV] --> B[Insert into COMMUNITY_REPORT_PROMPT]
C[Prepare Relationship Data CSV] --> B
B --> D[Send Prompt to LLM]
D --> E[Receive JSON Report]
E --> F[Parse JSON Report]
F --> G[Display / Use Report in Dashboard]
G --> H[Support Analyst Decision Making]
Summary
The community_report_prompt.py file is a utility resource containing a highly detailed prompt template for generating structured community reports via AI language models. It focuses on:
Defining the assistant's role and output expectations.
Enforcing grounded, data-supported insights.
Providing a replicable, consistent reporting format.
Enabling integration with data preprocessing and downstream analysis components.
This file itself contains no executable code or classes but serves as a core prompt resource critical for the information discovery workflow in the system.