Skip to content

Commit 218a001

Browse files
fix for older python versions
1 parent f7369ed commit 218a001

File tree

1 file changed

+12
-3
lines changed
  • python/packages/core/agent_framework

1 file changed

+12
-3
lines changed

python/packages/core/agent_framework/_types.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Sequence,
1313
)
1414
from copy import deepcopy
15-
from typing import Any, ClassVar, Generic, Literal, TypedDict, cast, overload
15+
from typing import TYPE_CHECKING, Any, ClassVar, Generic, Literal, TypedDict, cast, overload
1616

1717
from pydantic import BaseModel, ValidationError
1818

@@ -2810,7 +2810,7 @@ class ToolMode(TypedDict, total=False):
28102810
# region TypedDict-based Chat Options
28112811

28122812

2813-
class ChatOptions(TypedDict, Generic[TResponseModel], total=False):
2813+
class _ChatOptionsBase(TypedDict, total=False):
28142814
"""Common request settings for AI services as a TypedDict.
28152815
28162816
All fields are optional (total=False) to allow partial specification.
@@ -2863,7 +2863,7 @@ class ChatOptions(TypedDict, Generic[TResponseModel], total=False):
28632863
allow_multiple_tool_calls: bool
28642864

28652865
# Response configuration
2866-
response_format: type[TResponseModel] | Mapping[str, Any] | None
2866+
response_format: type[BaseModel] | Mapping[str, Any] | None
28672867

28682868
# Metadata
28692869
metadata: dict[str, Any]
@@ -2875,6 +2875,15 @@ class ChatOptions(TypedDict, Generic[TResponseModel], total=False):
28752875
instructions: str
28762876

28772877

2878+
if TYPE_CHECKING:
2879+
2880+
class ChatOptions(_ChatOptionsBase, Generic[TResponseModel], total=False):
2881+
response_format: type[TResponseModel] | Mapping[str, Any] | None
2882+
2883+
else:
2884+
ChatOptions = _ChatOptionsBase
2885+
2886+
28782887
# region Chat Options Utility Functions
28792888

28802889

0 commit comments

Comments
 (0)