mirror of https://github.com/microsoft/autogen.git
Clean chess examples. (#6203)
Signed-off-by: zhanluxianshen <zhanluxianshen@163.com> Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
This commit is contained in:
parent
f9268204ad
commit
687946258f
|
@ -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:
|
||||
|
|
|
@ -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__":
|
||||
|
|
Loading…
Reference in New Issue