mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: [BREAKING]: Introducing Options as TypedDict and Generic (#3140)
* WIP typeddict for options * updated all clients and ChatAgents * updated everything * added ADR * fix mypy * proper typevar imports * fixed import * fixed other imports * slight update in the sample * updated from feedback * fixes * fixed missing covariants and test fixes * fixed typing * updated anthropic thinking config * ruff fixes * fixed int tests * fix tests and mypy * updated integration tests * updated docstring and test fix * improved options handling in obser * mypy fix * updated a host of integration tests * fix tests * bedrock fix
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
# Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
"""Unified Purview model definitions and public export surface."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Mapping, MutableMapping, Sequence
|
||||
from datetime import datetime
|
||||
from enum import Enum, Flag, auto
|
||||
@@ -179,6 +175,8 @@ def translate_activity(activity: Activity) -> ProtectionScopeActivities:
|
||||
# Simple value models
|
||||
# --------------------------------------------------------------------------------------
|
||||
|
||||
TAliasSerializable = TypeVar("TAliasSerializable", bound="_AliasSerializable")
|
||||
|
||||
|
||||
class _AliasSerializable(SerializationMixin):
|
||||
"""Base class adding alias mapping + pydantic-compat helpers.
|
||||
@@ -232,7 +230,7 @@ class _AliasSerializable(SerializationMixin):
|
||||
return json.dumps(self.model_dump(by_alias=by_alias, exclude_none=exclude_none, **kwargs))
|
||||
|
||||
@classmethod
|
||||
def model_validate(cls, value: MutableMapping[str, Any]) -> _AliasSerializable: # type: ignore[name-defined]
|
||||
def model_validate(cls: type[TAliasSerializable], value: MutableMapping[str, Any]) -> TAliasSerializable: # type: ignore[name-defined]
|
||||
return cls(**value)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user