Update app.py
Browse filesjust a copy from another one.
app.py
CHANGED
|
@@ -7,6 +7,32 @@ from tools.final_answer import FinalAnswerTool
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 11 |
@tool
|
| 12 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|
|
|
|
| 7 |
|
| 8 |
from Gradio_UI import GradioUI
|
| 9 |
|
| 10 |
+
@tool
|
| 11 |
+
def get_best_move_lichess(fen: str) -> str:
|
| 12 |
+
"""A tool that guesses next best move on giving input in FEN(Forsyth–Edwards Notation) format
|
| 13 |
+
Args:
|
| 14 |
+
fen: A string representing a valid FEN chess format (e.g.,'r1bqkbnr/pppppppp/n7/8/8/5N2/PPPPPPPP/RNBQKB1R w KQkq - 2 2').
|
| 15 |
+
"""
|
| 16 |
+
url = "https://lichess.org/api/cloud-eval"
|
| 17 |
+
params = {
|
| 18 |
+
"fen": fen,
|
| 19 |
+
"multiPv": 1,
|
| 20 |
+
"variant": "standard",
|
| 21 |
+
}
|
| 22 |
+
headers = {
|
| 23 |
+
"Accept": "application/json"
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
response = requests.get(url, params=params, headers=headers)
|
| 27 |
+
|
| 28 |
+
if response.status_code != 200:
|
| 29 |
+
raise RuntimeError(f"Failed to query Lichess API: {response.status_code} - {response.text}")
|
| 30 |
+
|
| 31 |
+
data = response.json()
|
| 32 |
+
best = data.get("pvs", [])[0]
|
| 33 |
+
return best.get("moves", "").split()[0]
|
| 34 |
+
|
| 35 |
+
|
| 36 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 37 |
@tool
|
| 38 |
def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
|