-
Notifications
You must be signed in to change notification settings - Fork 601
Expand file tree
/
Copy pathprompts.py
More file actions
34 lines (24 loc) · 1.17 KB
/
prompts.py
File metadata and controls
34 lines (24 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Prompt components and builder for LLM-based document analysis."""
SYSTEM_PROMPT: str = "You are a document analysis assistant. Always respond with valid JSON in the exact format requested."
ANALYSIS_REQUEST: str = """
Respond with a JSON object containing:
- summary: A concise 2-3 sentence summary
- keywords: Array of 5 relevant keywords
- sentiment: One of "positive", "negative", or "neutral"
- readability: One of "easy", "medium", or "hard"
""".strip()
EXAMPLE_JSON: str = '{"summary": "This document discusses...", "keywords": ["ai", "machine", "learning", "data", "analysis"], "sentiment": "positive", "readability": "medium"}'
def build_analysis_prompt(filename: str, content_preview: str) -> str:
"""Construct the user message prompt for the analysis request.
Args:
filename: The document filename for context.
content_preview: The pre-cleaned, truncated content preview.
Returns:
A formatted prompt string containing instructions and an example.
"""
return f"""Analyze this document and provide structured analysis in JSON format.
Document: {filename}
Content: {content_preview}
{ANALYSIS_REQUEST}
Example:
{EXAMPLE_JSON}"""