Spaces:
Sleeping
Sleeping
File size: 1,119 Bytes
c976573 72846b4 c976573 |
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 |
from langchain_core.tools import tool
from image_to_text_tool import image_to_text
from utils import get_base64
from typing import Literal
@tool
def convert_chessboard_image_to_fen(chessboard_image_base64_path: str, current_player: Literal["black", "white"]) -> str:
"""
Given the path to a file with a chessboard image in base64, returns the FEN description of the chessboard.
Args:
image_path: Path to the image file with the chessboard.
current_player: Whose turn it is to play. Must be either 'black' or 'white'.
Returns:
JSON with FEN (Forsyth-Edwards Notation) string representing the current board position.
"""
chessboard_image_base64_str = get_base64(chessboard_image_base64_path)
print("Calling chessboard description")
fen = image_to_text.invoke(
{
"image_base64_str": chessboard_image_base64_str,
"instructions": f'Return the fen notation of this chessboard. Assume {current_player} will play.'
}
)
print("FEN returned: " + fen)
#gabarito do FEN: 3r2k1/pp3pp1/4b2p/7Q/3n4/PqBBR2P/5PP1/6K1 b - - 0 1
|