bstraehle commited on
Commit
89043fd
·
verified ·
1 Parent(s): 5675ea4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -14,7 +14,20 @@ def analysis(question, fen):
14
  print(f"FEN: {fen}")
15
  #print("Ground Truth: 1K1N1Bq1/P4p1q/b1P5/4p3/3P4/1p4p1/pp6/1kr5")
16
  # TODO https://lichess.org/api#tag/analysis/get/api/cloud-eval
17
- return "rxf3, rf1#"
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  mcp = gr.Interface(
20
  fn=analysis,
 
14
  print(f"FEN: {fen}")
15
  #print("Ground Truth: 1K1N1Bq1/P4p1q/b1P5/4p3/3P4/1p4p1/pp6/1kr5")
16
  # TODO https://lichess.org/api#tag/analysis/get/api/cloud-eval
17
+ #return "rxf3, rf1#"
18
+ url = "https://lichess.org/api/cloud-eval"
19
+ params = {"fen": fen}
20
+
21
+ try:
22
+ response = requests.get(url, params=params, timeout=10)
23
+ response.raise_for_status()
24
+
25
+ data = response.json()
26
+ return data.get("pvs", [])
27
+
28
+ except requests.exceptions.RequestException as e:
29
+ print(f"Error calling Lichess API: {e}")
30
+ return None
31
 
32
  mcp = gr.Interface(
33
  fn=analysis,