A programming framework for agentic AI
Clean chess examples. (#6203)
湛露先生687946258f9d
diff --git a/python/samples/agentchat_chess_game/main.py b/python/samples/agentchat_chess_game/main.pyindex 914659cf5..7b603508e 100644--- a/python/samples/agentchat_chess_game/main.py+++ b/python/samples/agentchat_chess_game/main.py@@ -66,11 +66,14 @@ def get_user_prompt(board: chess.Board) -> str:def extract_move(response: str) -> str:- start = response.find("<move>") + len("<move>")+ start = response.find("<move>")end = response.find("</move>")+if start == -1 or end == -1:raise ValueError("Invalid response format.")- return response[start:end]+ if end < start:+ raise ValueError("Invalid response format.")+ return response[start+ len("<move>"):end].strip()async def get_ai_move(board: chess.Board, player: AssistantAgent, max_tries: int) -> str:diff --git a/python/samples/core_distributed-group-chat/run_writer_agent.py b/python/samples/core_distributed-group-chat/run_writer_agent.pyindex 3b5c5877f..85774b635 100644--- a/python/samples/core_distributed-group-chat/run_writer_agent.py+++ b/python/samples/core_distributed-group-chat/run_writer_agent.py@@ -22,6 +22,8 @@ async def main(config: AppConfig) -> None:Console().print(Markdown("Starting **`Writer Agent`**"))await writer_agent_runtime.start()+ model_client = AzureOpenAIChatCompletionClient(**config.client_config)+writer_agent_type = await BaseGroupChatAgent.register(writer_agent_runtime,config.writer_agent.topic_type,@@ -29,7 +31,7 @@ async def main(config: AppConfig) -> None:description=config.writer_agent.description,group_chat_topic_type=config.group_chat_manager.topic_type,system_message=config.writer_agent.system_message,- model_client=AzureOpenAIChatCompletionClient(**config.client_config),+ model_client=model_client,ui_config=config.ui_agent,),)@@ -37,10 +39,11 @@ async def main(config: AppConfig) -> None:TypeSubscription(topic_type=config.writer_agent.topic_type, agent_type=writer_agent_type.type))await writer_agent_runtime.add_subscription(- TypeSubscription(topic_type=config.group_chat_manager.topic_type, agent_type=config.writer_agent.topic_type)+ TypeSubscription(topic_type=config.group_chat_manager.topic_type, agent_type=writer_agent_type.type))await writer_agent_runtime.stop_when_signal()+ await model_client.close()if __name__ == "__main__":