|
import os |
|
import sys |
|
import json |
|
from pathlib import Path |
|
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent.parent / "src")) |
|
|
|
|
|
src_dir = str(Path(__file__).parent.parent / "src") |
|
sys.path.insert(0, src_dir) |
|
|
|
def main(): |
|
print("Testing chess image analysis") |
|
|
|
|
|
test_image = str(Path(__file__).parent.parent / "data/downloaded_files" / "cca530fc-4052-43b2-b130-b30968d8aa44.png") |
|
|
|
if not os.path.exists(test_image): |
|
print(f"Error: Test image not found at {test_image}") |
|
return |
|
|
|
print(f"Processing chess image: {test_image}") |
|
|
|
|
|
from file_processing_tool import process_image_file |
|
|
|
|
|
result = process_image_file(test_image) |
|
|
|
|
|
chess_analysis = result.get("chess_analysis", None) |
|
|
|
if chess_analysis and isinstance(chess_analysis, dict) and "recommended_move" in chess_analysis: |
|
print("\nChess Position Analysis:") |
|
print(f"Recommended move: {chess_analysis['recommended_move']}") |
|
print(f"Explanation: {chess_analysis.get('explanation', 'No explanation provided')}") |
|
|
|
|
|
question = "Review the chess position provided in the image. It is black's turn. Provide the correct next move for black which guarantees a win. Please provide your response in algebraic notation." |
|
print(f"\nQuestion: {question}") |
|
print(f"Answer: {chess_analysis['recommended_move']}") |
|
else: |
|
print("\nCould not determine the answer from the analysis.") |
|
if result.get("error"): |
|
print(f"Error: {result['error']}") |
|
|
|
if __name__ == "__main__": |
|
main() |
|
|