Update multi_agent.py
Browse files- multi_agent.py +6 -6
multi_agent.py
CHANGED
|
@@ -47,7 +47,7 @@ def create_agent(llm: ChatOpenAI, tools: list, system_prompt: str):
|
|
| 47 |
|
| 48 |
def agent_node(state, agent, name):
|
| 49 |
try:
|
| 50 |
-
print("###
|
| 51 |
result = agent.invoke(state)
|
| 52 |
return {"messages": [HumanMessage(content=result["output"], name=name)]}
|
| 53 |
except Exception as e:
|
|
@@ -60,7 +60,7 @@ def get_legal_moves() -> Annotated[str, "A list of legal moves in UCI format"]:
|
|
| 60 |
The input should always be an empty string,
|
| 61 |
and this function will always return legal moves in UCI format."""
|
| 62 |
try:
|
| 63 |
-
print("### get_legal_moves")
|
| 64 |
global legal_moves
|
| 65 |
legal_moves = ",".join([str(move) for move in board.legal_moves])
|
| 66 |
return legal_moves
|
|
@@ -74,7 +74,7 @@ def make_move(move: Annotated[str, "A move in UCI format."]) -> Annotated[str, "
|
|
| 74 |
The input should always be a move in UCI format,
|
| 75 |
and this function will always return the result of the move in UCI format."""
|
| 76 |
try:
|
| 77 |
-
print("### make_move")
|
| 78 |
move = chess.Move.from_uci(move)
|
| 79 |
board.push_uci(str(move))
|
| 80 |
|
|
@@ -209,7 +209,7 @@ def should_continue(state):
|
|
| 209 |
print("### checkmate")
|
| 210 |
return END # checkmate or stalemate
|
| 211 |
|
| 212 |
-
print("### chess_board_proxy")
|
| 213 |
return "chess_board_proxy"
|
| 214 |
|
| 215 |
def initialize():
|
|
@@ -224,11 +224,11 @@ def initialize():
|
|
| 224 |
legal_moves = ""
|
| 225 |
|
| 226 |
def run_multi_agent(moves_num):
|
|
|
|
|
|
|
| 227 |
global num_moves
|
| 228 |
num_moves = moves_num
|
| 229 |
|
| 230 |
-
initialize()
|
| 231 |
-
|
| 232 |
graph = create_graph()
|
| 233 |
|
| 234 |
result = ""
|
|
|
|
| 47 |
|
| 48 |
def agent_node(state, agent, name):
|
| 49 |
try:
|
| 50 |
+
print(f"### {name} ###")
|
| 51 |
result = agent.invoke(state)
|
| 52 |
return {"messages": [HumanMessage(content=result["output"], name=name)]}
|
| 53 |
except Exception as e:
|
|
|
|
| 60 |
The input should always be an empty string,
|
| 61 |
and this function will always return legal moves in UCI format."""
|
| 62 |
try:
|
| 63 |
+
#print("### get_legal_moves")
|
| 64 |
global legal_moves
|
| 65 |
legal_moves = ",".join([str(move) for move in board.legal_moves])
|
| 66 |
return legal_moves
|
|
|
|
| 74 |
The input should always be a move in UCI format,
|
| 75 |
and this function will always return the result of the move in UCI format."""
|
| 76 |
try:
|
| 77 |
+
#print("### make_move")
|
| 78 |
move = chess.Move.from_uci(move)
|
| 79 |
board.push_uci(str(move))
|
| 80 |
|
|
|
|
| 209 |
print("### checkmate")
|
| 210 |
return END # checkmate or stalemate
|
| 211 |
|
| 212 |
+
print("### chess_board_proxy ###")
|
| 213 |
return "chess_board_proxy"
|
| 214 |
|
| 215 |
def initialize():
|
|
|
|
| 224 |
legal_moves = ""
|
| 225 |
|
| 226 |
def run_multi_agent(moves_num):
|
| 227 |
+
initialize()
|
| 228 |
+
|
| 229 |
global num_moves
|
| 230 |
num_moves = moves_num
|
| 231 |
|
|
|
|
|
|
|
| 232 |
graph = create_graph()
|
| 233 |
|
| 234 |
result = ""
|