SergeyO7 commited on
Commit
7fb8030
·
verified ·
1 Parent(s): 1900d53

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +4 -28
agent.py CHANGED
@@ -14,8 +14,8 @@ import whisper
14
  import time
15
  from youtube_transcript_api import YouTubeTranscriptApi
16
  from SPARQLWrapper import SPARQLWrapper, JSON
17
- import chess
18
- import chess.engine
19
  import shutil
20
  import traceback
21
 
@@ -86,30 +86,6 @@ import traceback
86
  #
87
  # return f"The image description: '{response}'"
88
 
89
- class ChessEngineTool(Tool):
90
- name = "chess_engine"
91
- description = "Analyzes a chess position (FEN) with Stockfish and returns the best move."
92
- inputs = {
93
- "fen": {"type": "string", "description": "FEN string of the position."},
94
- "time_limit": {"type": "number", "description": "Time in seconds for engine analysis.", "nullable": True}
95
- }
96
- output_type = "string"
97
-
98
- def forward(self, fen: str, time_limit: float = 0.1) -> str:
99
- # figure out where the binary actually is
100
- sf_bin = shutil.which("stockfish") or "/usr/games/stockfish"
101
- if not sf_bin:
102
- raise RuntimeError(
103
- f"Cannot find stockfish on PATH or at /usr/games/stockfish. "
104
- "Did you install it in apt.txt or via apt-get?"
105
- )
106
-
107
- board = chess.Board(fen)
108
- engine = chess.engine.SimpleEngine.popen_uci(sf_bin)
109
- result = engine.play(board, chess.engine.Limit(time=time_limit))
110
- engine.quit()
111
- return board.san(result.move)
112
-
113
  class DuckDuckGoSearchTool(Tool):
114
  name = "web_search"
115
  description = "Searches the web using DuckDuckGo and returns results as a string."
@@ -358,8 +334,8 @@ class MagAgent:
358
  ExcelReaderTool(),
359
  VisitWebpageTool(),
360
  PythonCodeReaderTool()
361
- # Uncomment to add ChessEngineTool (requires python-chess and Stockfish)
362
- ChessEngineTool()
363
  # GoogleSearchTool,
364
  # ImageAnalysisTool,
365
  # LocalFileAudioTool()
 
14
  import time
15
  from youtube_transcript_api import YouTubeTranscriptApi
16
  from SPARQLWrapper import SPARQLWrapper, JSON
17
+ #import chess
18
+ #import chess.engine
19
  import shutil
20
  import traceback
21
 
 
86
  #
87
  # return f"The image description: '{response}'"
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  class DuckDuckGoSearchTool(Tool):
90
  name = "web_search"
91
  description = "Searches the web using DuckDuckGo and returns results as a string."
 
334
  ExcelReaderTool(),
335
  VisitWebpageTool(),
336
  PythonCodeReaderTool()
337
+ # ChessEngineTool (requires python-chess and Stockfish)
338
+ # ChessEngineTool()
339
  # GoogleSearchTool,
340
  # ImageAnalysisTool,
341
  # LocalFileAudioTool()