Skip to content

Commit 1f1c225

Browse files
Fix Python 3.10 TypedDict compatibility issue with ParamDefDict type alias
1 parent b776690 commit 1f1c225

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/lmstudio/json_api.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,19 +1098,20 @@ def __init__(
10981098
class ToolParamDefDict(TypedDict):
10991099
type: type[Any]
11001100
default: NotRequired[Any]
1101+
ParamDefDict: TypeAlias = ToolParamDefDict
11011102
else:
11021103

11031104
class ToolParamDefDict(TypedDict, Generic[T]):
11041105
type: type[T]
11051106
default: NotRequired[T]
1106-
1107+
ParamDefDict: TypeAlias = ToolParamDefDict[Any]
11071108

11081109
class ToolFunctionDefDict(TypedDict):
11091110
"""SDK input format to specify an LLM tool call and its implementation (as a dict)."""
11101111

11111112
name: str
11121113
description: str
1113-
parameters: Mapping[str, type[Any] | ToolParamDefDict[Any]]
1114+
parameters: Mapping[str, type[Any] | ParamDefDict]
11141115
implementation: Callable[..., Any]
11151116

11161117

@@ -1124,12 +1125,12 @@ class ToolFunctionDef:
11241125

11251126
name: str
11261127
description: str
1127-
parameters: Mapping[str, type[Any] | ToolParamDefDict[Any]]
1128+
parameters: Mapping[str, type[Any] | ParamDefDict]
11281129
implementation: Callable[..., Any]
11291130

11301131
@staticmethod
11311132
def _extract_type_and_default(
1132-
param_value: type[Any] | ToolParamDefDict[Any],
1133+
param_value: type[Any] | ParamDefDict,
11331134
) -> tuple[type[Any], Any]:
11341135
"""Extract type and default value from parameter definition."""
11351136
if isinstance(param_value, dict):

0 commit comments

Comments
 (0)