Python: added generic types to ChatOptions and ChatResponse/AgentResponse for Response Format (#3305)

* added generic types to ChatOptions and ChatResponse/AgentResponse for response format

* fix typevar import

* fix for older python versions

* fix missing import

* fixed imports

* fixed mypy

* mypy fix
This commit is contained in:
Eduard van Valkenburg
2026-01-28 22:23:02 +01:00
committed by GitHub
Unverified
parent 1f8463f9bb
commit 1226828ec2
42 changed files with 486 additions and 281 deletions
@@ -1,8 +1,9 @@
# Copyright (c) Microsoft. All rights reserved.
import sys
from collections.abc import Callable, Mapping
from pathlib import Path
from typing import Any, Literal, TypedDict, cast
from typing import Any, Literal, cast
import yaml
from agent_framework import (
@@ -42,6 +43,11 @@ from ._models import (
agent_schema_dispatch,
)
if sys.version_info >= (3, 11):
from typing import TypedDict # type: ignore # pragma: no cover
else:
from typing_extensions import TypedDict # type: ignore # pragma: no cover
class ProviderTypeMapping(TypedDict, total=True):
package: str
@@ -24,10 +24,11 @@ See: dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/PowerFx/
"""
import logging
import sys
from collections.abc import Mapping
from dataclasses import dataclass
from decimal import Decimal as _Decimal
from typing import Any, Literal, TypedDict, cast
from typing import Any, Literal, cast
from agent_framework._workflows import (
Executor,
@@ -36,6 +37,12 @@ from agent_framework._workflows import (
)
from powerfx import Engine
if sys.version_info >= (3, 11):
from typing import TypedDict # type: ignore # pragma: no cover
else:
from typing_extensions import TypedDict # type: ignore # pragma: no cover
logger = logging.getLogger(__name__)