Update agents/models/prompts.py
Browse files- agents/models/prompts.py +54 -237
agents/models/prompts.py
CHANGED
|
@@ -3,250 +3,67 @@
|
|
| 3 |
# https://claude.ai/public/artifacts/9d6efdeb-7c0d-4c8d-a71f-ba5c8f0da6e1
|
| 4 |
|
| 5 |
PROMPT_IMG_TO_FEN = """
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
-
|
| 16 |
-
-
|
| 17 |
-
-
|
| 18 |
-
-
|
| 19 |
-
-
|
| 20 |
-
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
<analysis_framework>
|
| 25 |
-
1. **Board Orientation Detection**: First establish if the board is viewed from White's perspective (rank 1 at bottom) or Black's perspective (rank 8 at bottom). Look for coordinate markers, piece starting positions, or other orientation clues.
|
| 26 |
-
|
| 27 |
-
2. **Systematic Piece Identification**: Scan each square methodically using this approach:
|
| 28 |
-
- Start from rank 8, file a (top-left if White's perspective)
|
| 29 |
-
- Progress through each file (a→h) before moving to the next rank
|
| 30 |
-
- For each occupied square, identify: piece type, piece color, exact position
|
| 31 |
-
- For empty squares, count consecutive empties for numerical notation
|
| 32 |
-
|
| 33 |
-
3. **Piece Recognition Protocol**:
|
| 34 |
-
- **King**: Largest piece, cross-topped, central importance
|
| 35 |
-
- **Queen**: Second largest, crown with multiple points/ornaments
|
| 36 |
-
- **Rook**: Castle-like structure, crenellated top
|
| 37 |
-
- **Bishop**: Pointed mitre/hat shape, diagonal mover
|
| 38 |
-
- **Knight**: Horse head profile, L-shaped mover
|
| 39 |
-
- **Pawn**: Smallest pieces, simple rounded/pointed top
|
| 40 |
-
|
| 41 |
-
4. **Color Determination**: White pieces are lighter colored, Black pieces are darker colored. Account for lighting variations and piece material differences.
|
| 42 |
-
|
| 43 |
-
5. **Special Situation Analysis**:
|
| 44 |
-
- Castling rights: Analyze if kings and rooks are on starting squares and haven't moved
|
| 45 |
-
- En passant: Check if the last move was a two-square pawn advance creating en passant opportunity
|
| 46 |
-
- Move counters: Determine halfmove clock and fullmove number based on position complexity
|
| 47 |
-
|
| 48 |
-
6. **User Instruction Processing**: If user specifies piece removal ("don't move X piece" or "remove Y piece"), eliminate those pieces from the final FEN by treating their squares as empty.
|
| 49 |
-
</analysis_framework>
|
| 50 |
-
|
| 51 |
-
<accuracy_validation>
|
| 52 |
-
- Double-check each rank's piece count (max 8 squares per rank)
|
| 53 |
-
- Verify piece placement logic against chess rules
|
| 54 |
-
- Confirm FEN syntax: ranks separated by '/', numbers for consecutive empty squares
|
| 55 |
-
- Validate that White pieces use uppercase, Black pieces use lowercase
|
| 56 |
-
- Ensure all six FEN components are present and correctly formatted
|
| 57 |
-
</accuracy_validation>
|
| 58 |
-
</methodology>
|
| 59 |
-
|
| 60 |
-
<examples>
|
| 61 |
-
<example_1>
|
| 62 |
-
Standard starting position:
|
| 63 |
-
**Image**: Full chess starting setup
|
| 64 |
-
**Analysis**: All pieces on starting squares, White to move, all castling rights available
|
| 65 |
**FEN**: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
|
| 66 |
-
</example_1>
|
| 67 |
|
| 68 |
-
<example_2>
|
| 69 |
-
Mid-game position with castling:
|
| 70 |
-
**Image**: Kings castled, some pieces developed
|
| 71 |
-
**Analysis**: Both kings castled kingside, no en passant, multiple moves played
|
| 72 |
**FEN**: r1bq1rk1/pp1n1ppp/2p1pn2/3p4/3P4/2N1PN2/PPQ2PPP/R1B2RK1 w KQ - 4 12
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
**Analysis**: Black pawn moved two squares, creating en passant target on d6
|
| 79 |
-
**FEN**: rnbqkbnr/ppp1pppp/8/3pP3/8/8/PPPP1PPP/RNBQKBNR w KQkq d6 0 2
|
| 80 |
-
</example_3>
|
| 81 |
-
|
| 82 |
-
<example_4>
|
| 83 |
-
Endgame position:
|
| 84 |
-
**Image**: Only kings and few pawns remaining
|
| 85 |
-
**Analysis**: Simplified position, no castling rights, precise piece counting crucial
|
| 86 |
**FEN**: 8/6p1/5K2/8/8/8/7k/8 w - - 0 1
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
**Image**: Standard position but user says "remove the white queen"
|
| 92 |
-
**Analysis**: Generate FEN as normal but replace white queen square with empty square notation
|
| 93 |
-
**FEN**: rnbqkbnr/pppppppp/8/8/8/8/PPPP1PPP/RNB1KBNR w KQkq - 0 1
|
| 94 |
-
</example_5>
|
| 95 |
-
</examples>
|
| 96 |
-
|
| 97 |
-
<output_requirements>
|
| 98 |
-
<format_specification>
|
| 99 |
-
- Return ONLY the complete FEN notation string
|
| 100 |
-
- No additional text, explanations, or formatting
|
| 101 |
-
- FEN must contain all six components: piece placement, active color, castling rights, en passant target, halfmove clock, fullmove number
|
| 102 |
-
- Use exact notation: uppercase for White pieces (KQRBNP), lowercase for Black pieces (kqrbnp)
|
| 103 |
-
- Numbers 1-8 for consecutive empty squares
|
| 104 |
-
- Forward slashes (/) separating ranks
|
| 105 |
-
- Spaces separating the six FEN components
|
| 106 |
-
</format_specification>
|
| 107 |
-
|
| 108 |
-
<quality_assurance>
|
| 109 |
-
- Each rank must account for exactly 8 squares
|
| 110 |
-
- Piece symbols must be valid chess notation
|
| 111 |
-
- Castling rights format: combination of KQkq or "-" if none available
|
| 112 |
-
- En passant format: algebraic square notation or "-" if not applicable
|
| 113 |
-
- Move counters must be non-negative integers
|
| 114 |
-
- Total character validation for syntactic correctness
|
| 115 |
-
</quality_assurance>
|
| 116 |
-
</output_requirements>
|
| 117 |
-
|
| 118 |
-
<constraint_handling>
|
| 119 |
-
- If image quality is poor, focus on distinguishable piece characteristics
|
| 120 |
-
- If board orientation is ambiguous, assume White's perspective (rank 1 at bottom)
|
| 121 |
-
- If piece identification is uncertain, use context clues (piece positioning, game logic)
|
| 122 |
-
- If user instructions conflict with image, prioritize user instructions for final FEN
|
| 123 |
-
- If castling rights are ambiguous, make conservative assumption (assume rights lost unless clearly preserved)
|
| 124 |
-
</constraint_handling>
|
| 125 |
"""
|
| 126 |
|
| 127 |
PROMPT_ALGEBRAIC_NOTATION = """
|
| 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 |
-
2. **UCI Parsing**
|
| 156 |
-
- Extract piece type from UCI notation
|
| 157 |
-
- Identify origin and destination squares
|
| 158 |
-
- Determine if move involves capture, promotion, or castling
|
| 159 |
-
|
| 160 |
-
3. **Algebraic Conversion**
|
| 161 |
-
- Apply piece letter (K, Q, R, B, N, or blank for pawns)
|
| 162 |
-
- Add capture notation "x" if applicable
|
| 163 |
-
- Include destination square
|
| 164 |
-
- Add disambiguation if multiple pieces can reach same square
|
| 165 |
-
- Append check "+", checkmate "#", or promotion "=Piece"
|
| 166 |
-
|
| 167 |
-
4. **Validation**
|
| 168 |
-
- Verify notation follows FIDE standards exactly
|
| 169 |
-
- Confirm disambiguation is minimal but sufficient
|
| 170 |
-
- Check special move notation (castling, en passant, promotion)
|
| 171 |
-
|
| 172 |
-
5. **Edge Case Handling**
|
| 173 |
-
- Ambiguous piece moves requiring file or rank disambiguation
|
| 174 |
-
- Pawn captures with file specification
|
| 175 |
-
- Promotion moves with piece specification
|
| 176 |
-
- Castling legality and notation
|
| 177 |
-
- En passant captures
|
| 178 |
-
</methodology>
|
| 179 |
-
|
| 180 |
-
<examples>
|
| 181 |
-
<example_1>
|
| 182 |
-
UCI: e2e4
|
| 183 |
-
Position: Opening, white pawn moves
|
| 184 |
-
Algebraic: e4
|
| 185 |
-
Reasoning: Pawn move, no piece letter needed
|
| 186 |
-
</example_1>
|
| 187 |
-
|
| 188 |
-
<example_2>
|
| 189 |
-
UCI: Ng1f3
|
| 190 |
-
Position: Knight development, no ambiguity
|
| 191 |
-
Algebraic: Nf3
|
| 192 |
-
Reasoning: Knight to f3, no disambiguation needed
|
| 193 |
-
</example_2>
|
| 194 |
-
|
| 195 |
-
<example_3>
|
| 196 |
-
UCI: Qd1xd8
|
| 197 |
-
Position: Queen captures on d8, giving check
|
| 198 |
-
Algebraic: Qxd8+
|
| 199 |
-
Reasoning: Queen captures, check notation added
|
| 200 |
-
</example_3>
|
| 201 |
-
|
| 202 |
-
<example_4>
|
| 203 |
-
UCI: Nb1d2
|
| 204 |
-
Position: Two knights can reach d2 (b1 and f3)
|
| 205 |
-
Algebraic: Nbd2
|
| 206 |
-
Reasoning: Disambiguation by file (b-file knight)
|
| 207 |
-
</example_4>
|
| 208 |
-
|
| 209 |
-
<example_5>
|
| 210 |
-
UCI: e7e8q
|
| 211 |
-
Position: Pawn promotes to queen on 8th rank
|
| 212 |
-
Algebraic: e8=Q
|
| 213 |
-
Reasoning: Pawn promotion with piece specification
|
| 214 |
-
</example_5>
|
| 215 |
-
|
| 216 |
-
<example_6>
|
| 217 |
-
UCI: e1g1
|
| 218 |
-
Position: White king castles kingside
|
| 219 |
-
Algebraic: O-O
|
| 220 |
-
Reasoning: Kingside castling notation
|
| 221 |
-
</example_6>
|
| 222 |
-
|
| 223 |
-
<example_7>
|
| 224 |
-
UCI: exd6
|
| 225 |
-
Position: En passant capture
|
| 226 |
-
Algebraic: exd6
|
| 227 |
-
Reasoning: Standard capture notation for en passant
|
| 228 |
-
</example_7>
|
| 229 |
-
</examples>
|
| 230 |
-
|
| 231 |
-
<constraints>
|
| 232 |
-
- Never include explanations or reasoning in output
|
| 233 |
-
- Use exact FIDE algebraic notation standards
|
| 234 |
-
- Apply minimal sufficient disambiguation
|
| 235 |
-
- Handle all special moves correctly (castling, en passant, promotion)
|
| 236 |
-
- Verify check/checkmate indicators
|
| 237 |
-
- Process only the requested move notation
|
| 238 |
-
</constraints>
|
| 239 |
-
|
| 240 |
-
<output_requirements>
|
| 241 |
-
Provide ONLY the algebraic chess notation for the requested move(s).
|
| 242 |
-
Format: Single notation or comma-separated list if multiple moves requested.
|
| 243 |
-
No additional text, explanations, or formatting.
|
| 244 |
-
Accuracy requirement: 99% precision in notation generation.
|
| 245 |
-
</output_requirements>
|
| 246 |
-
|
| 247 |
-
<position_evaluation_uci>{position_evaluation}</position_evaluation_uci>
|
| 248 |
-
|
| 249 |
-
<user_question>{question}</user_question>
|
| 250 |
"""
|
| 251 |
|
| 252 |
PROMPT_FINAL_ANSWER = """
|
|
|
|
| 3 |
# https://claude.ai/public/artifacts/9d6efdeb-7c0d-4c8d-a71f-ba5c8f0da6e1
|
| 4 |
|
| 5 |
PROMPT_IMG_TO_FEN = """
|
| 6 |
+
You are an expert image to FEN generation assistant with highest attention to detail.
|
| 7 |
+
Given a user question, image of a chess position, and active color, your task is to generate the FEN of the image.
|
| 8 |
+
If the user question mentions not to move certain pieces, remove them from the FEN.
|
| 9 |
+
|
| 10 |
+
**Active Color**: {active_color}
|
| 11 |
+
|
| 12 |
+
**Rules:**
|
| 13 |
+
- Start from rank 8 to rank 1.
|
| 14 |
+
- For each rank, go from file a to file h.
|
| 15 |
+
- Use uppercase for white pieces: K=King, Q=Queen, R=Rook, B=Bishop, N=Knight, P=Pawn.
|
| 16 |
+
- Use lowercase for black pieces: k, q, r, b, n, p.
|
| 17 |
+
- Use numbers (1-8) for consecutive empty squares.
|
| 18 |
+
- Separate ranks with '/'.
|
| 19 |
+
- Provide all portions of the FEN, including active color, castling rights, en passant, and move counters.
|
| 20 |
+
- Return ONLY the FEN, nothing else.
|
| 21 |
+
|
| 22 |
+
**Examples:**
|
| 23 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
**FEN**: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
|
|
|
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
**FEN**: r1bq1rk1/pp1n1ppp/2p1pn2/3p4/3P4/2N1PN2/PPQ2PPP/R1B2RK1 w KQ - 4 12
|
| 27 |
+
|
| 28 |
+
**FEN**: r1bqkb1r/pppp1ppp/2n2n2/4p3/2B1P3/8/PPPP1PPP/RNBQK1NR b KQkq - 0 4
|
| 29 |
+
|
| 30 |
+
**FEN**: rnbqkbnr/ppp1pppp/8/8/3pP3/8/PPP2PPP/RNBQKBNR b KQkq d3 0 2
|
| 31 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
**FEN**: 8/6p1/5K2/8/8/8/7k/8 w - - 0 1
|
| 33 |
+
|
| 34 |
+
**User Question:** {question}
|
| 35 |
+
|
| 36 |
+
**FEN:**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
"""
|
| 38 |
|
| 39 |
PROMPT_ALGEBRAIC_NOTATION = """
|
| 40 |
+
You are an expert algebraic chess notation (aka standard notation) generation assistant with highest attention to detail.
|
| 41 |
+
Given a user question, image of a chess position, and position evaluation in UCI notation, your task is to answer the question in algebraic chess notation.
|
| 42 |
+
Only provide your answer, no explanation.
|
| 43 |
+
|
| 44 |
+
**Position Evaluation in UCI Notation**: {position_evaluation}
|
| 45 |
+
|
| 46 |
+
**Rules:**
|
| 47 |
+
- Each move lists the piece letter (K, Q, R, B, N). Pawns are written with no letter.
|
| 48 |
+
- The destination square (file + rank) always appears (e.g., e4, c6).
|
| 49 |
+
- Captures use an "x" before the destination (e.g., Bxe5, exd5).
|
| 50 |
+
- Checks add "+", checkmate adds "#".
|
| 51 |
+
- Castling is written as O-O (king-side) or O-O-O (queen-side).
|
| 52 |
+
- Pawn promotion adds "=Piece" after the move (e.g., e8=Q).
|
| 53 |
+
- If two identical pieces can go to the same square, the move is disambiguated with file or rank (e.g., Nbd2 or R1e2).
|
| 54 |
+
- En passant is recorded like a standard capture (e.g., exd6 e.p.).
|
| 55 |
+
|
| 56 |
+
**Examples:**
|
| 57 |
+
|
| 58 |
+
**Algebraic Chess Notation:** Qxb1, Ra8#
|
| 59 |
+
|
| 60 |
+
**Algebraic Chess Notation:** R1e2
|
| 61 |
+
|
| 62 |
+
**Algebraic Chess Notation:** Nf3+
|
| 63 |
+
|
| 64 |
+
**User Question:** {question}
|
| 65 |
+
|
| 66 |
+
**Algebraic Chess Notation:**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
"""
|
| 68 |
|
| 69 |
PROMPT_FINAL_ANSWER = """
|