mirascope 1.23.2__py3-none-any.whl → 1.23.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,4 +12,13 @@ _R = TypeVar("_R")
12
12
  def fn_is_async(
13
13
  fn: Callable[..., Awaitable[_R] | Coroutine[Any, Any, _R]] | Callable[..., _R],
14
14
  ) -> TypeIs[Callable[..., Awaitable[_R]]]:
15
- return inspect.iscoroutinefunction(fn)
15
+ if inspect.iscoroutinefunction(fn):
16
+ return True
17
+
18
+ # Check if it's a wrapper around an `async def` function (using functools.wraps).
19
+ _fn = fn
20
+ while hasattr(_fn, "__wrapped__"):
21
+ _fn = _fn.__wrapped__ # pyright: ignore[reportFunctionMemberAccess]
22
+ if inspect.iscoroutinefunction(_fn):
23
+ return True
24
+ return False
@@ -1,6 +1,5 @@
1
1
  """The `middleware_factory` method for handling the call response."""
2
2
 
3
- import inspect
4
3
  from collections.abc import AsyncGenerator, Awaitable, Callable, Generator
5
4
  from contextlib import AbstractContextManager, contextmanager
6
5
  from functools import wraps
@@ -16,6 +15,7 @@ from pydantic import BaseModel
16
15
 
17
16
  from mirascope.core.base._utils._base_type import BaseType
18
17
 
18
+ from ..core.base._utils import fn_is_async
19
19
  from ..core.base.call_response import BaseCallResponse
20
20
  from ..core.base.stream import BaseStream
21
21
  from ..core.base.structured_stream import BaseStructuredStream
@@ -136,14 +136,14 @@ def middleware_factory(
136
136
  def decorator(
137
137
  fn: Callable[_P, _R | Awaitable[_R]],
138
138
  ) -> Callable[_P, _R | Awaitable[_R]]:
139
- if inspect.iscoroutinefunction(fn):
139
+ if fn_is_async(fn):
140
140
 
141
141
  @wraps(fn)
142
142
  async def wrapper_async(*args: _P.args, **kwargs: _P.kwargs) -> _R:
143
143
  context_manager = custom_context_manager(fn)
144
144
  context = context_manager.__enter__()
145
145
  try:
146
- result = await fn(*args, **kwargs)
146
+ result = await fn(*args, **kwargs) # pyright: ignore [reportGeneralTypeIssues]
147
147
  except Exception as e:
148
148
  if handle_error_async:
149
149
  try:
mirascope/llm/__init__.py CHANGED
@@ -3,11 +3,13 @@ from ._call import call
3
3
  from ._context import context
4
4
  from ._override import override
5
5
  from .call_response import CallResponse
6
+ from .call_response_chunk import CallResponseChunk
6
7
  from .stream import Stream
7
8
  from .tool import Tool
8
9
 
9
10
  __all__ = [
10
11
  "CallResponse",
12
+ "CallResponseChunk",
11
13
  "CostMetadata",
12
14
  "LocalProvider",
13
15
  "Provider",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mirascope
3
- Version: 1.23.2
3
+ Version: 1.23.4
4
4
  Summary: LLM abstractions that aren't obstructions
5
5
  Project-URL: Homepage, https://mirascope.com
6
6
  Project-URL: Documentation, https://mirascope.com/WELCOME
@@ -101,19 +101,19 @@ Provides-Extra: xai
101
101
  Requires-Dist: openai<2,>=1.6.0; extra == 'xai'
102
102
  Description-Content-Type: text/markdown
103
103
 
104
- <div align="center" justiry="start">
105
- <a href="https://mirascope.com">
106
- <img align="bottom" src="https://github.com/Mirascope/mirascope/assets/99370834/e403d7ee-f8bc-4df1-b2d0-33763f021c89" alt="Frog Logo" width="84"/><br><img align="bottom" src="https://uploads-ssl.webflow.com/65a6fd6a1c3b2704d6217d3d/65b5674e9ceef563dc57eb11_Medium%20length%20hero%20headline%20goes%20here.svg" width="400" alt="Mirascope"/>
104
+ <p align="center">
105
+ <a href="https://mirascope.com/#mirascope">
106
+ <img src="https://github.com/user-attachments/assets/58b04850-8f30-40a6-be68-96ed2aa9b6d8" />
107
107
  </a>
108
- </div>
108
+ </p>
109
109
 
110
110
  <p align="center">
111
111
  <a href="https://github.com/Mirascope/mirascope/actions/workflows/tests.yml" target="_blank"><img src="https://github.com/Mirascope/mirascope/actions/workflows/tests.yml/badge.svg?branch=main" alt="Tests"/></a>
112
112
  <a href="https://codecov.io/github/Mirascope/mirascope" target="_blank"><img src="https://codecov.io/github/Mirascope/mirascope/graph/badge.svg?token=HAEAWT3KC9" alt="Coverage"/></a>
113
- <a href="https://mirascope.com/WELCOME" target="_blank"><img src="https://img.shields.io/badge/docs-available-brightgreen" alt="Docs"/></a>
113
+ <a href="https://mirascope.com/docs/mirascope" target="_blank"><img src="https://img.shields.io/badge/docs-available-brightgreen" alt="Docs"/></a>
114
114
  <a href="https://pypi.python.org/pypi/mirascope" target="_blank"><img src="https://img.shields.io/pypi/v/mirascope.svg" alt="PyPI Version"/></a>
115
115
  <a href="https://pypi.python.org/pypi/mirascope" target="_blank"><img src="https://img.shields.io/pypi/pyversions/mirascope.svg" alt="Stars"/></a>
116
- <a href="https://github.com/Mirascope/mirascope/blog/dev/LICENSE"><img src="https://img.shields.io/github/license/Mirascope/mirascope.svg" alt="License"/></a>
116
+ <a href="https://github.com/Mirascope/mirascope/tree/main/LICENSE"><img src="https://img.shields.io/github/license/Mirascope/mirascope.svg" alt="License"/></a>
117
117
  <a href="https://github.com/Mirascope/mirascope/stargazers" target="_blank"><img src="https://img.shields.io/github/stars/Mirascope/mirascope.svg" alt="Stars"/></a>
118
118
  </p>
119
119
 
@@ -114,7 +114,7 @@ mirascope/core/base/_utils/_convert_messages_to_message_params.py,sha256=symOUsX
114
114
  mirascope/core/base/_utils/_convert_provider_finish_reason_to_finish_reason.py,sha256=Mki5mYbYX8vUW-oosC4PaRNUHW_T5xAQWti3_1ndtTk,611
115
115
  mirascope/core/base/_utils/_default_tool_docstring.py,sha256=JLyryjGDaHMU-P7gUpnjkPyELCQsQgi8AP4Dp_yXPOM,277
116
116
  mirascope/core/base/_utils/_extract_tool_return.py,sha256=ZDBZJ4cacFd8nijSWZEhib7B58ZnSFD_rK1FiGNTYU0,1553
117
- mirascope/core/base/_utils/_fn_is_async.py,sha256=17uagVPZpo4-MkfD6fylrX1xGeGypvcGC7mibIwRbfU,409
117
+ mirascope/core/base/_utils/_fn_is_async.py,sha256=dMrvkwqyyNhuaQUHtNMxpMoBoHqZuHPbh4nqfK-KKi0,728
118
118
  mirascope/core/base/_utils/_format_template.py,sha256=3l0Iq1LxQhocR588bzUDtfLalfiq_Rw_tHrVdgoZHiA,1061
119
119
  mirascope/core/base/_utils/_get_audio_type.py,sha256=PN8MlgKgl5OIDANgSUlI4UarLkfBHfWmWWls9shPM8M,683
120
120
  mirascope/core/base/_utils/_get_common_usage.py,sha256=s9Gvq0wl4ZM1V3zmI0LDEIG8wIxWEOXkjuDBjtyFx9s,675
@@ -321,7 +321,7 @@ mirascope/core/xai/_utils/_setup_call.py,sha256=0pCy8SqEQQEFUrCYTe6EEn_z7GuTY7-G
321
321
  mirascope/experimental/graphs/__init__.py,sha256=xwvU6T5lqfMXeHZ0IN8cepzkFkSURpeeV7ozokjzaBY,162
322
322
  mirascope/experimental/graphs/finite_state_machine.py,sha256=xsiguJCW7nyMuITezYKHevM1R2LIs1rdMeqw5kmJITs,26470
323
323
  mirascope/integrations/__init__.py,sha256=ieLWknpbkO_gABIVl9790YTTCCRO9ISQ35-1SeOSU0Q,392
324
- mirascope/integrations/_middleware_factory.py,sha256=rv9MaNgn7AL9Z7qADMRxxD9A_abePqj80Y0SReU9LrE,17305
324
+ mirascope/integrations/_middleware_factory.py,sha256=v-S-hVU5S7P9Lu8PiKyUhmtp_rbQaIJ1droC8BcKBAE,17362
325
325
  mirascope/integrations/tenacity.py,sha256=jk64MBncCMbgoQMaXQgjxg9Y9UstRqTt2RCeA86pdCU,326
326
326
  mirascope/integrations/langfuse/__init__.py,sha256=wG3eBXwGPbFedB28L1K_q1iCf_dERjVmTDCWK4nHZyM,71
327
327
  mirascope/integrations/langfuse/_utils.py,sha256=SsZfQkp-_Ytxzoq03XwEy3a-PuHB6oVs3uy3fAZKMOg,3457
@@ -333,7 +333,7 @@ mirascope/integrations/otel/__init__.py,sha256=OzboYfm3fUNwKTuu08KX83hQHYI4oZYN2
333
333
  mirascope/integrations/otel/_utils.py,sha256=SCVb3MpcpqLpCpumJEbEdINceNdusnyT6iuKPz66sBc,8778
334
334
  mirascope/integrations/otel/_with_hyperdx.py,sha256=f17uxXQk5zZPtyj6zwPwJz5i7atsnUPOoq1LqT8JO0E,1637
335
335
  mirascope/integrations/otel/_with_otel.py,sha256=tbjd6BEbcSfnsm5CWHBoHwbRNrHt6-t4or-SYGQSD-w,1659
336
- mirascope/llm/__init__.py,sha256=rCukXJUqSGiDGNMMM9g3NS8clnrCxgCpaFIXIG1M660,432
336
+ mirascope/llm/__init__.py,sha256=LI3YkfIZLJ_Pzkm2x4W0HbKO-EHDDojc5oYp7qO6YNs,508
337
337
  mirascope/llm/_call.py,sha256=_YOmo5Y4NU2Jz1XcgEEI94UCyzgiAFrKwIH7o2KQ5vM,13933
338
338
  mirascope/llm/_context.py,sha256=vtHJkLlFfUwyR_hYEHXAw3xunpHhLn67k4kuFw50GR8,12481
339
339
  mirascope/llm/_override.py,sha256=m4MdOhM-aJRIGP7NBJhscq3ISNct6FBPn3jjmryFo_Q,112292
@@ -371,7 +371,7 @@ mirascope/v0/base/ops_utils.py,sha256=1Qq-VIwgHBaYutiZsS2MUQ4OgPC3APyywI5bTiTAmA
371
371
  mirascope/v0/base/prompts.py,sha256=FM2Yz98cSnDceYogiwPrp4BALf3_F3d4fIOCGAkd-SE,1298
372
372
  mirascope/v0/base/types.py,sha256=ZfatJoX0Yl0e3jhv0D_MhiSVHLYUeJsdN3um3iE10zY,352
373
373
  mirascope/v0/base/utils.py,sha256=XREPENRQTu8gpMhHU8RC8qH_am3FfGUvY-dJ6x8i-mw,681
374
- mirascope-1.23.2.dist-info/METADATA,sha256=n0lFKABsKJ5IhQy56-SCTdYMubOi9KlUUBePMfSzm3Y,8783
375
- mirascope-1.23.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
376
- mirascope-1.23.2.dist-info/licenses/LICENSE,sha256=LAs5Q8mdawTsVdONpDGukwsoc4KEUBmmonDEL39b23Y,1072
377
- mirascope-1.23.2.dist-info/RECORD,,
374
+ mirascope-1.23.4.dist-info/METADATA,sha256=ULBZnd8FOiYYaxJ4YXoD-eHaWMNhnm_1df5hHFwXha0,8536
375
+ mirascope-1.23.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
376
+ mirascope-1.23.4.dist-info/licenses/LICENSE,sha256=LAs5Q8mdawTsVdONpDGukwsoc4KEUBmmonDEL39b23Y,1072
377
+ mirascope-1.23.4.dist-info/RECORD,,