A programming framework for agentic AI
Fix chess example #298 (#301)
Eric Zhu19f5463200b7
diff --git a/python/samples/common/agents/_chat_completion_agent.py b/python/samples/common/agents/_chat_completion_agent.pyindex 302c44aff..8cb98a2d8 100644--- a/python/samples/common/agents/_chat_completion_agent.py+++ b/python/samples/common/agents/_chat_completion_agent.py@@ -189,12 +189,10 @@ class ChatCompletionAgent(TypeRoutedAgent):and all(isinstance(x, FunctionCall) for x in response.content)):# Send a function call message to itself.- response = await (- await self.send_message(- message=FunctionCallMessage(content=response.content, source=self.metadata["name"]),- recipient=self.id,- cancellation_token=cancellation_token,- )+ response = await self.send_message(+ message=FunctionCallMessage(content=response.content, source=self.metadata["name"]),+ recipient=self.id,+ cancellation_token=cancellation_token,)# Make an assistant message from the response.hisorical_messages = await self._memory.get_messages()diff --git a/python/samples/common/types.py b/python/samples/common/types.pyindex e526c719a..02b0d1eba 100644--- a/python/samples/common/types.py+++ b/python/samples/common/types.py@@ -53,6 +53,7 @@ class PublishNow:response_format: ResponseFormat = field(default=ResponseFormat.text)+@dataclassclass Reset: ...diff --git a/python/samples/demos/chess_game.py b/python/samples/demos/chess_game.pyindex edbab5068..45ea19926 100644--- a/python/samples/demos/chess_game.py+++ b/python/samples/demos/chess_game.py@@ -169,7 +169,7 @@ async def chess_game(runtime: AgentRuntime) -> None: # type: ignore),],memory=BufferedChatMemory(buffer_size=10),- model_client=get_chat_completion_client_from_envs(model="gpt-4-turbo"),+ model_client=get_chat_completion_client_from_envs(model="gpt-4o"),tools=black_tools,),)@@ -186,7 +186,7 @@ async def chess_game(runtime: AgentRuntime) -> None: # type: ignore),],memory=BufferedChatMemory(buffer_size=10),- model_client=get_chat_completion_client_from_envs(model="gpt-4-turbo"),+ model_client=get_chat_completion_client_from_envs(model="gpt-4o"),tools=white_tools,),)@@ -205,11 +205,10 @@ async def chess_game(runtime: AgentRuntime) -> None: # type: ignoreasync def main() -> None:runtime = SingleThreadedAgentRuntime()await chess_game(runtime)+ run_context = runtime.start()# Publish an initial message to trigger the group chat manager to start orchestration.await runtime.publish_message(TextMessage(content="Game started.", source="System"), namespace="default")- while True:- await runtime.process_next()- await asyncio.sleep(1)+ await run_context.stop_when_idle()if __name__ == "__main__":