-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAnalysisPrompts.cs
More file actions
192 lines (166 loc) · 6.98 KB
/
AnalysisPrompts.cs
File metadata and controls
192 lines (166 loc) · 6.98 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
namespace Unity.GrantManager.AI
{
internal static class AnalysisPrompts
{
public const string DefaultRubric = @"ELIGIBILITY REQUIREMENTS: Project aligns with program objectives; Applicant is an eligible entity; Budget is reasonable and justified; Timeline is realistic.
COMPLETENESS CHECKS: Required information is present; Supporting materials are provided where applicable; Description is clear.
FINANCIAL REVIEW: Requested amount is within limits; Budget matches scope; Matching funds or contributions are identified.
RISK ASSESSMENT: Applicant capacity; Feasibility; Compliance considerations; Delivery risks.
QUALITY INDICATORS: Clear objectives; Defined beneficiaries; Appropriate approach; Long-term sustainability.";
public const string DefaultRubricV0 = @"BC GOVERNMENT GRANT EVALUATION RUBRIC:
1. ELIGIBILITY REQUIREMENTS:
- Project must align with program objectives
- Applicant must be eligible entity type
- Budget must be reasonable and well-justified
- Project timeline must be realistic
2. COMPLETENESS CHECKS:
- All required fields completed
- Necessary supporting documents provided
- Budget breakdown detailed and accurate
- Project description clear and comprehensive
3. FINANCIAL REVIEW:
- Requested amount is within program limits
- Budget is reasonable for scope of work
- Matching funds or in-kind contributions identified
- Cost per outcome/beneficiary is reasonable
4. RISK ASSESSMENT:
- Applicant capacity to deliver project
- Technical feasibility of proposed work
- Environmental or regulatory compliance
- Potential for cost overruns or delays
5. QUALITY INDICATORS:
- Clear project objectives and outcomes
- Well-defined target audience/beneficiaries
- Appropriate project methodology
- Sustainability plan for long-term impact
EVALUATION CRITERIA:
- HIGH: Meets all requirements, well-prepared application, low risk
- MEDIUM: Meets most requirements, minor issues or missing elements
- LOW: Missing key requirements, significant concerns, high risk";
public const string ScoreRules = @"HIGH: Application demonstrates strong evidence across most rubric areas with few or no issues.
MEDIUM: Application has some gaps or weaknesses that require reviewer attention.
LOW: Application has significant gaps or risks across key rubric areas.";
public const string OutputTemplate = @"{
""rating"": ""<HIGH|MEDIUM|LOW>"",
""errors"": [
{
""title"": ""<string>"",
""detail"": ""<string>""
}
],
""warnings"": [
{
""title"": ""<string>"",
""detail"": ""<string>""
}
],
""summaries"": [
{
""title"": ""<string>"",
""detail"": ""<string>""
}
]
}";
public const string Rules = PromptCoreRules.UseProvidedEvidence + "\n"
+ "- Do not invent fields, documents, requirements, or facts.\n"
+ @"- Treat missing or empty values as findings only when they weaken rubric evidence.
- Prefer material issues; avoid nitpicking.
- Use 3-6 words for title.
- Each detail must be 1-2 complete sentences.
- Each detail must cite concrete evidence from DATA or ATTACHMENTS.
- If ATTACHMENTS evidence is used, cite the attachment by name in detail.
- If no findings exist, return empty arrays.
- Rating must be HIGH, MEDIUM, or LOW.
"
+ PromptCoreRules.MinimumNarrativeWords + "\n"
+ PromptCoreRules.ExactOutputShape + "\n"
+ PromptCoreRules.NoExtraOutputKeys + "\n"
+ PromptCoreRules.ValidJsonOnly + "\n"
+ PromptCoreRules.PlainJsonOnly;
public const string SeverityRules = @"ERROR: Issue that would likely prevent the application from being approved.
WARNING: Issue that could negatively affect the application's approval.
RECOMMENDATION: Reviewer-facing improvement or follow-up consideration.";
public const string OutputTemplateV0 = @"{
""rating"": ""HIGH/MEDIUM/LOW"",
""warnings"": [
{
""category"": ""Brief summary of the warning"",
""message"": ""Detailed warning message with full context and explanation""
}
],
""errors"": [
{
""category"": ""Brief summary of the error"",
""message"": ""Detailed error message with full context and explanation""
}
],
""summaries"": [
{
""category"": ""Brief summary of the recommendation"",
""message"": ""Detailed recommendation with specific actionable guidance""
}
],
""dismissed"": []
}";
public const string RulesV0 = @"- Use only SCHEMA, DATA, ATTACHMENTS, and RUBRIC as evidence.
- Do not invent fields, documents, requirements, or facts.
- Treat missing or empty values as findings only when they weaken rubric evidence.
- Prefer material issues; avoid nitpicking.
- Each error/warning/recommendation must describe one concrete issue or consideration and why it matters.
- Use 3-6 words for category.
- Each message must be 1-2 complete sentences.
- Each message must be grounded in concrete evidence from provided inputs.
- If attachment evidence is used, reference the attachment explicitly in the message.
- Do not provide applicant-facing advice.
- Do not mention rubric section names in findings.
- If no findings exist, return empty arrays.
- rating must be HIGH, MEDIUM, or LOW."
+ "\n" + PromptCoreRules.ExactOutputShape
+ "\n" + PromptCoreRules.NoExtraOutputKeys
+ "\n" + PromptCoreRules.ValidJsonOnly
+ "\n" + PromptCoreRules.PlainJsonOnly;
public static readonly string SystemPrompt = PromptHeader.Build(
"You are an expert grant analyst assistant for human reviewers.",
"Using SCHEMA, DATA, ATTACHMENTS, RUBRIC, SCORE, OUTPUT, and RULES, return review findings.");
public static readonly string SystemPromptV0 = PromptHeader.Build(
"You are an expert grant analyst assistant for human reviewers.",
"Using SCHEMA, DATA, ATTACHMENTS, RUBRIC, SEVERITY, SCORE, OUTPUT, and RULES, return review findings.");
public static string GetRubric(bool useV0) => useV0 ? DefaultRubricV0 : DefaultRubric;
public static string GetSystemPrompt(bool useV0) => useV0 ? SystemPromptV0 : SystemPrompt;
public static string BuildUserPrompt(
string schemaJson,
string dataJson,
string attachmentsJson,
string rubric)
{
return BuildUserPrompt(schemaJson, dataJson, attachmentsJson, rubric, useV0: false);
}
public static string BuildUserPrompt(
string schemaJson,
string dataJson,
string attachmentsJson,
string rubric,
bool useV0)
{
var output = useV0 ? OutputTemplateV0 : OutputTemplate;
var rules = useV0 ? RulesV0 : Rules;
var severitySection = useV0 ? $@"SEVERITY
{SeverityRules}
" : string.Empty;
return $@"SCHEMA
{schemaJson}
DATA
{dataJson}
ATTACHMENTS
{attachmentsJson}
RUBRIC
{rubric}
{severitySection}SCORE
{ScoreRules}
OUTPUT
{output}
RULES
{rules}";
}
}
}