From 8e8ea2c9b9b3c06692ebbd12058820ac6a2d6190 Mon Sep 17 00:00:00 2001 From: DavdGao Date: Mon, 26 Feb 2024 13:03:59 +0800 Subject: [PATCH] Add sorted function in required fields to avoid randomness --- src/agentscope/service/service_factory.py | 4 +++- tests/service_factory_test.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/agentscope/service/service_factory.py b/src/agentscope/service/service_factory.py index d717c6960..e9e2ad891 100644 --- a/src/agentscope/service/service_factory.py +++ b/src/agentscope/service/service_factory.py @@ -121,7 +121,9 @@ def get( ), ) - args_required = list(set(args_agent) - set(args_defaults.keys())) + args_required = sorted( + list(set(args_agent) - set(args_defaults.keys())), + ) # Prepare types of the arguments, remove the return type args_types = { diff --git a/tests/service_factory_test.py b/tests/service_factory_test.py index de8c529f6..385f4c457 100644 --- a/tests/service_factory_test.py +++ b/tests/service_factory_test.py @@ -126,7 +126,7 @@ def func( # type: ignore "b": {}, "a": {"type": "string"}, }, - "required": ["b", "a"], + "required": ["a", "b"], }, }, },