Skip to content

Commit 798d902

Browse files
authored
Merge pull request #707 from Mirascope/fix-dynamic-config-message-typing-issue
Fix dynamic config message typing issue
2 parents 173b9fb + 9a95d9e commit 798d902

File tree

5 files changed

+15
-18
lines changed

5 files changed

+15
-18
lines changed

mirascope/core/base/_utils/_setup_call.py

+6-10
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@
44
from collections.abc import (
55
Awaitable,
66
Callable,
7+
Sequence,
78
)
8-
from typing import (
9-
Any,
10-
Protocol,
11-
TypeVar,
12-
cast,
13-
)
9+
from typing import Any, Protocol, TypeVar, cast
1410

1511
from ..call_kwargs import BaseCallKwargs
1612
from ..call_params import BaseCallParams, CommonCallParams
@@ -33,17 +29,17 @@ def __call__(self, common_params: CommonCallParams) -> _BaseCallParamsT: ...
3329

3430
def setup_call(
3531
fn: Callable[..., _BaseDynamicConfigT | Awaitable[_BaseDynamicConfigT]]
36-
| Callable[..., list[BaseMessageParam]]
37-
| Callable[..., Awaitable[list[BaseMessageParam]]],
32+
| Callable[..., Sequence[BaseMessageParam]]
33+
| Callable[..., Awaitable[Sequence[BaseMessageParam]]],
3834
fn_args: dict[str, Any],
3935
dynamic_config: _BaseDynamicConfigT,
40-
tools: list[type[BaseTool] | Callable] | None,
36+
tools: Sequence[type[BaseTool] | Callable] | None,
4137
tool_type: type[_BaseToolT],
4238
call_params: _BaseCallParamsT | CommonCallParams,
4339
convert_common_call_params: ConvertCommonParamsFunc[_BaseCallParamsT],
4440
) -> tuple[
4541
str | None,
46-
list[BaseMessageParam | Any],
42+
Sequence[BaseMessageParam | Any],
4743
list[type[_BaseToolT]] | None,
4844
BaseCallKwargs,
4945
]:

mirascope/core/base/dynamic_config.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""The base type in a function as an LLM call to return for dynamic configuration."""
22

3-
from collections.abc import Callable
3+
from collections.abc import Callable, Sequence
44
from typing import Any, Generic, TypeVar
55

66
from typing_extensions import NotRequired, TypedDict
@@ -17,11 +17,11 @@
1717
class DynamicConfigBase(TypedDict):
1818
metadata: NotRequired[Metadata]
1919
computed_fields: NotRequired[dict[str, Any | list[Any] | list[list[Any]]]]
20-
tools: NotRequired[list[type[BaseTool] | Callable]]
20+
tools: NotRequired[Sequence[type[BaseTool] | Callable]]
2121

2222

2323
class DynamicConfigMessages(DynamicConfigBase, Generic[_MessageParamT]):
24-
messages: NotRequired[list[_MessageParamT]]
24+
messages: NotRequired[Sequence[_MessageParamT]]
2525

2626

2727
class DynamicConfigCallParams(DynamicConfigBase, Generic[_CallParamsT]):
@@ -35,12 +35,12 @@ class DynamicConfigClient(DynamicConfigBase, Generic[_ClientT]):
3535
class DynamicConfigMessagesCallParams(
3636
DynamicConfigBase, Generic[_MessageParamT, _CallParamsT]
3737
):
38-
messages: NotRequired[list[_MessageParamT]]
38+
messages: NotRequired[Sequence[_MessageParamT]]
3939
call_params: NotRequired[_CallParamsT]
4040

4141

4242
class DynamicConfigMessagesClient(DynamicConfigBase, Generic[_MessageParamT, _ClientT]):
43-
messages: NotRequired[list[_MessageParamT]]
43+
messages: NotRequired[Sequence[_MessageParamT]]
4444
client: NotRequired[_ClientT | None]
4545

4646

@@ -52,7 +52,7 @@ class DynamicConfigCallParamsClient(DynamicConfigBase, Generic[_CallParamsT, _Cl
5252
class DynamicConfigFull(
5353
DynamicConfigBase, Generic[_MessageParamT, _CallParamsT, _ClientT]
5454
):
55-
messages: NotRequired[list[_MessageParamT]]
55+
messages: NotRequired[Sequence[_MessageParamT]]
5656
call_params: NotRequired[_CallParamsT]
5757
client: NotRequired[_ClientT | None]
5858

mirascope/integrations/_middleware_factory.py

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def default_context_manager(
4747

4848

4949
def middleware_factory(
50+
*,
5051
custom_context_manager: Callable[
5152
[SyncFunc | AsyncFunc], AbstractContextManager[_T]
5253
] = default_context_manager,

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "mirascope"
3-
version = "1.9.4"
3+
version = "1.9.5"
44
description = "LLM abstractions that aren't obstructions"
55
readme = "README.md"
66
license = { file = "LICENSE" }

uv.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)