mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: Replace the global DEFAULT_USER_PERSONA_REGISTRY with a function call to get_default_persona_registry
PiperOrigin-RevId: 871422993
This commit is contained in:
committed by
Copybara-Service
parent
e1e0d63616
commit
2703613572
@@ -20,7 +20,7 @@ from pydantic import Field
|
||||
from pydantic import field_validator
|
||||
|
||||
from .common import EvalBaseModel
|
||||
from .simulation.pre_built_personas import DEFAULT_USER_PERSONA_REGISTRY
|
||||
from .simulation.pre_built_personas import get_default_persona_registry
|
||||
from .simulation.user_simulator_personas import UserPersona
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ class ConversationScenario(EvalBaseModel):
|
||||
cls, value: Optional[UserPersona | str]
|
||||
) -> Optional[UserPersona]:
|
||||
if value is not None and isinstance(value, str):
|
||||
return DEFAULT_USER_PERSONA_REGISTRY.get_persona(value)
|
||||
return get_default_persona_registry().get_persona(value)
|
||||
return value
|
||||
|
||||
|
||||
|
||||
@@ -509,7 +509,7 @@ class _PreBuiltPersonas(enum.Enum):
|
||||
)
|
||||
|
||||
|
||||
def _get_default_persona_registry() -> UserPersonaRegistry:
|
||||
def get_default_persona_registry() -> UserPersonaRegistry:
|
||||
registry = UserPersonaRegistry()
|
||||
|
||||
registry.register_persona(
|
||||
@@ -523,6 +523,3 @@ def _get_default_persona_registry() -> UserPersonaRegistry:
|
||||
)
|
||||
|
||||
return registry
|
||||
|
||||
|
||||
DEFAULT_USER_PERSONA_REGISTRY = _get_default_persona_registry()
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from google.adk.evaluation.simulation import pre_built_personas
|
||||
from google.adk.evaluation.simulation.pre_built_personas import get_default_persona_registry
|
||||
|
||||
|
||||
def test_get_default_persona_registry():
|
||||
"""Tests that the default persona registry can be loaded."""
|
||||
assert pre_built_personas.DEFAULT_USER_PERSONA_REGISTRY is not None
|
||||
assert get_default_persona_registry() is not None
|
||||
|
||||
Reference in New Issue
Block a user