akhaliq HF staff commited on
Commit
4235d5e
1 Parent(s): 91db6aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -18,9 +18,11 @@ def get_ai_move(fen):
18
  str or None: The AI's move in UCI format, or None if an error occurs.
19
  """
20
  # Prepare the prompt for the AI
21
- prompt = f"""As a chess engine, analyze the following board position given in FEN notation:
22
  {fen}
23
- It's your turn to move. Provide the best move in UCI format (e.g., e2e4). Only provide the move, without any additional text."""
 
 
24
 
25
  try:
26
  # Generate the response from the AI model
@@ -28,7 +30,7 @@ It's your turn to move. Provide the best move in UCI format (e.g., e2e4). Only p
28
  model="gemini-1.5-flash",
29
  prompt=prompt,
30
  temperature=0, # To make the output more deterministic
31
- max_output_tokens=5
32
  )
33
  ai_move = response.result.strip()
34
  print(f"AI move: {ai_move}")
 
18
  str or None: The AI's move in UCI format, or None if an error occurs.
19
  """
20
  # Prepare the prompt for the AI
21
+ prompt = f"""You are playing a chess game, and the current board position is given in FEN notation:
22
  {fen}
23
+ It's your turn to move. You need to provide the best legal chess move following the rules of chess.
24
+ The move should be in UCI format, which represents the starting and ending squares (for example, 'e2e4').
25
+ Make sure the move you provide is legal and valid according to the current board position."""
26
 
27
  try:
28
  # Generate the response from the AI model
 
30
  model="gemini-1.5-flash",
31
  prompt=prompt,
32
  temperature=0, # To make the output more deterministic
33
+ max_output_tokens=10
34
  )
35
  ai_move = response.result.strip()
36
  print(f"AI move: {ai_move}")