Update agents/tools/chess_tools.py
Browse files- agents/tools/chess_tools.py +3 -36
agents/tools/chess_tools.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import
|
| 2 |
from agents.mcp.mcp_client import (
|
| 3 |
call_mcp_tool,
|
| 4 |
MCP_SSE_URL_CHESS_EVALUATION,
|
|
@@ -6,42 +6,9 @@ from agents.mcp.mcp_client import (
|
|
| 6 |
)
|
| 7 |
from crewai.tools import tool
|
| 8 |
|
| 9 |
-
class ChessTools():
|
| 10 |
-
@tool("Remove Piece Tool")
|
| 11 |
-
def remove_piece_tool(fen: str, file: int, rank: int) -> str:
|
| 12 |
-
"""Remove piece from chess board.
|
| 13 |
-
|
| 14 |
-
Args:
|
| 15 |
-
fen (str): Chess board position in FEN notation
|
| 16 |
-
file (int): Chess board file
|
| 17 |
-
rank (int): Chess board rank
|
| 18 |
-
|
| 19 |
-
Returns:
|
| 20 |
-
Result string
|
| 21 |
-
|
| 22 |
-
Raises:
|
| 23 |
-
RuntimeError: If processing fails
|
| 24 |
-
"""
|
| 25 |
-
try:
|
| 26 |
-
board = chess.Board(fen)
|
| 27 |
-
|
| 28 |
-
board.remove_piece_at(chess.square(file_index=file, rank_index=rank))
|
| 29 |
-
|
| 30 |
-
fen = board.board_fen() + " " + \
|
| 31 |
-
(chess.BLACK if board.turn == chess.BLACK else chess.WHITE) + " " + \
|
| 32 |
-
board.castling_xfen() + " " + \
|
| 33 |
-
(board.ep_square_name() if board.ep_square else "-") + " " + \
|
| 34 |
-
str(board.halfmove_clock) + " " + \
|
| 35 |
-
str(board.fullmove_number)
|
| 36 |
-
|
| 37 |
-
print(f"🤖 FEN remove_piece_tool: {fen}")
|
| 38 |
-
|
| 39 |
-
return fen
|
| 40 |
-
except Exception as e:
|
| 41 |
-
raise RuntimeError(f"Processing failed: {str(e)}")
|
| 42 |
-
|
| 43 |
@tool("Get Best Move Tool")
|
| 44 |
-
def
|
| 45 |
"""Get best move for chess board position.
|
| 46 |
|
| 47 |
Args:
|
|
|
|
| 1 |
+
import os
|
| 2 |
from agents.mcp.mcp_client import (
|
| 3 |
call_mcp_tool,
|
| 4 |
MCP_SSE_URL_CHESS_EVALUATION,
|
|
|
|
| 6 |
)
|
| 7 |
from crewai.tools import tool
|
| 8 |
|
| 9 |
+
class ChessTools():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
@tool("Get Best Move Tool")
|
| 11 |
+
def get_best_move_tool(fen: str) -> str:
|
| 12 |
"""Get best move for chess board position.
|
| 13 |
|
| 14 |
Args:
|