Update app.py
Browse files
app.py
CHANGED
|
@@ -18,6 +18,12 @@ def position_evaluation(fen):
|
|
| 18 |
Returns:
|
| 19 |
tuple: (result, error) - Best move with continuation in UCI notation
|
| 20 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
print("")
|
| 22 |
|
| 23 |
print(f"🤖 Chess position_evaluation: fen={fen}")
|
|
@@ -44,6 +50,14 @@ def _noop(*args, **kwargs):
|
|
| 44 |
|
| 45 |
gradio.utils.watchfn_spaces = _noop
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
# Graphical user interface
|
| 48 |
|
| 49 |
mcp = gr.Interface(
|
|
|
|
| 18 |
Returns:
|
| 19 |
tuple: (result, error) - Best move with continuation in UCI notation
|
| 20 |
"""
|
| 21 |
+
is_valid, err_msg = validate_input(fen)
|
| 22 |
+
|
| 23 |
+
if not is_valid:
|
| 24 |
+
gr.Warning(f"Invalid input: {err_msg}")
|
| 25 |
+
return None, err_msg
|
| 26 |
+
|
| 27 |
print("")
|
| 28 |
|
| 29 |
print(f"🤖 Chess position_evaluation: fen={fen}")
|
|
|
|
| 50 |
|
| 51 |
gradio.utils.watchfn_spaces = _noop
|
| 52 |
|
| 53 |
+
def validate_input(fen):
|
| 54 |
+
is_valid = True
|
| 55 |
+
|
| 56 |
+
if fen.len() > 100:
|
| 57 |
+
is_valid = False
|
| 58 |
+
|
| 59 |
+
return is_valid
|
| 60 |
+
|
| 61 |
# Graphical user interface
|
| 62 |
|
| 63 |
mcp = gr.Interface(
|