File size: 4,556 Bytes
b6b1ef4
 
 
208f6e3
f968168
9035a17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ac23533
 
 
9035a17
 
 
 
 
ac23533
9035a17
 
 
 
f968168
 
5e33aed
9035a17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57baa06
 
f968168
0039fc3
 
9258dbe
0039fc3
 
 
 
 
 
 
 
d8b2dec
0039fc3
9258dbe
0039fc3
9258dbe
0039fc3
 
 
9258dbe
0039fc3
 
 
9258dbe
0039fc3
 
 
9258dbe
0039fc3
 
 
9258dbe
0039fc3
 
 
9258dbe
0039fc3
9258dbe
0039fc3
9258dbe
0039fc3
f968168
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
# References:

# https://claude.ai/public/artifacts/9d6efdeb-7c0d-4c8d-a71f-ba5c8f0da6e1

PROMPT_IMG_TO_FEN = """
You are an expert image to FEN generation assistant with highest attention to detail.
Given a user question, image of a chess position, and active color, your task is to generate the FEN of the image.
If the user question mentions not to move certain pieces, remove them from the FEN.

**Active Color**: {active_color}

**Rules:**
- Start from rank 8 to rank 1.
- For each rank, go from file a to file h.
- Use uppercase for white pieces: K=King, Q=Queen, R=Rook, B=Bishop, N=Knight, P=Pawn.
- Use lowercase for black pieces: k, q, r, b, n, p.
- Use numbers (1-8) for consecutive empty squares.
- Separate ranks with '/'.
- Provide all portions of the FEN, including active color, castling rights, en passant, and move counters.
- Return ONLY the FEN, nothing else.

**Examples:**

**FEN**: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1

**FEN**: r1bq1rk1/pp1n1ppp/2p1pn2/3p4/3P4/2N1PN2/PPQ2PPP/R1B2RK1 w KQ - 4 12

**FEN**: r1bqkb1r/pppp1ppp/2n2n2/4p3/2B1P3/8/PPPP1PPP/RNBQK1NR b KQkq - 0 4

**FEN**: rnbqkbnr/ppp1pppp/8/8/3pP3/8/PPP2PPP/RNBQKBNR b KQkq d3 0 2

**FEN**: 8/6p1/5K2/8/8/8/7k/8 w - - 0 1

**User Question:** {question}

**FEN:**
"""

PROMPT_ALGEBRAIC_NOTATION = """
You are an expert algebraic chess notation (aka standard notation) generation assistant with highest attention to detail.
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.
Only provide your answer, no explanation.

**Position Evaluation in UCI Notation**: {position_evaluation}

**Rules:**
- Each move lists the piece letter (K, Q, R, B, N). Pawns are written with no letter.
- The destination square (file + rank) always appears (e.g., e4, c6).
- Captures use an "x" before the destination (e.g., Bxe5, exd5).
- Checks add "+", checkmate adds "#".
- Castling is written as O-O (king-side) or O-O-O (queen-side).
- Pawn promotion adds "=Piece" after the move (e.g., e8=Q).
- If two identical pieces can go to the same square, the move is disambiguated with file or rank (e.g., Nbd2 or R1e2).
- En passant is recorded like a standard capture (e.g., exd6 e.p.).

**Examples:**

**Algebraic Chess Notation:** Qxb1, Ra8#

**Algebraic Chess Notation:** R1e2

**Algebraic Chess Notation:** Nf3+

**User Question:** {question}

**Algebraic Chess Notation:**
"""

PROMPT_FINAL_ANSWER = """
You are an expert final answer generation assistant with highest attention to detail.
Given a question and an initial answer, your task is to generate the final answer.

**Rules:**
- The final answer must be a number and/or string OR as few words as possible OR a comma-separated list of numbers and/or strings.
- If you are asked for a number, don't use comma to write your number neither use units such as USD, $, percent, or % unless specified otherwise.
- If you are asked for a string, don't use articles, neither abbreviations (for example cities), and write the digits in plain text unless specified otherwise.
- If you are asked for a comma-separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.
- If the final answer is a number, use a number not a word.
- If the final answer is a string, start with an uppercase character.
- If the final answer is a comma-separated list of numbers, use a space character after each comma.
- If the final answer is a comma-separated list of strings, use a space character after each comma and start with a lowercase character.
- Do not add any content to the final answer that is not in the initial answer.

**Examples:**

**Question:** What is the biggest city in California?
**Initial Answer:** The biggest city in California is Los Angeles.
**Final Answer:** Los Angeles

**Question:** How many 'r's are in strawberry?
**Initial Answer:** There are 3 'r's in strawberry.
**Final Answer:** 3

**Question:** What is the opposite of black?
**Initial Answer:** The opposite of black is white.
**Final Answer:** White

**Question:** What are the first 5 numbers in the Fibonacci sequence?
**Initial Answer:** The first 5 numbers in the Fibonacci sequence are 0, 1, 1, 2, 3.
**Final Answer:** 0, 1, 1, 2, 3

**Question:** What is the opposite of bad, worse, worst?
**Initial Answer:** The opposite of bad, worse, worst is good, better, best.
**Final Answer:** good, better, best

**Question:** {question}

**Initial Answer:** {answer}

**Final Answer:** 
"""