mirascope 1.24.0__py3-none-any.whl → 1.24.1__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.
- mirascope/core/azure/call_response_chunk.py +5 -5
- mirascope/core/base/call_response.py +1 -3
- mirascope/core/base/tool.py +9 -0
- mirascope/core/bedrock/_utils/_message_param_converter.py +10 -9
- mirascope/core/bedrock/call_response.py +0 -1
- mirascope/core/bedrock/tool.py +4 -0
- mirascope/llm/call_response.py +1 -10
- {mirascope-1.24.0.dist-info → mirascope-1.24.1.dist-info}/METADATA +1 -1
- {mirascope-1.24.0.dist-info → mirascope-1.24.1.dist-info}/RECORD +11 -11
- {mirascope-1.24.0.dist-info → mirascope-1.24.1.dist-info}/WHEEL +0 -0
- {mirascope-1.24.0.dist-info → mirascope-1.24.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -75,14 +75,14 @@ class AzureCallResponseChunk(
|
|
|
75
75
|
return self.chunk.id
|
|
76
76
|
|
|
77
77
|
@property
|
|
78
|
-
def usage(self) -> CompletionsUsage:
|
|
78
|
+
def usage(self) -> CompletionsUsage | None:
|
|
79
79
|
"""Returns the usage of the chat completion."""
|
|
80
80
|
return self.chunk.usage
|
|
81
81
|
|
|
82
82
|
@property
|
|
83
|
-
def input_tokens(self) -> int:
|
|
83
|
+
def input_tokens(self) -> int | None:
|
|
84
84
|
"""Returns the number of input tokens."""
|
|
85
|
-
return self.usage.prompt_tokens
|
|
85
|
+
return self.usage.prompt_tokens if self.usage else None
|
|
86
86
|
|
|
87
87
|
@property
|
|
88
88
|
def cached_tokens(self) -> int:
|
|
@@ -90,9 +90,9 @@ class AzureCallResponseChunk(
|
|
|
90
90
|
return 0
|
|
91
91
|
|
|
92
92
|
@property
|
|
93
|
-
def output_tokens(self) -> int:
|
|
93
|
+
def output_tokens(self) -> int | None:
|
|
94
94
|
"""Returns the number of output tokens."""
|
|
95
|
-
return self.usage.completion_tokens
|
|
95
|
+
return self.usage.completion_tokens if self.usage else None
|
|
96
96
|
|
|
97
97
|
@property
|
|
98
98
|
def cost_metadata(self) -> CostMetadata:
|
|
@@ -60,10 +60,8 @@ def transform_tool_outputs(
|
|
|
60
60
|
tools_and_outputs: Sequence[tuple[_BaseToolT, JsonableType]],
|
|
61
61
|
) -> list[_ToolMessageParamT]:
|
|
62
62
|
def recursive_serializer(value: JsonableType) -> BaseType:
|
|
63
|
-
if isinstance(value, str):
|
|
63
|
+
if isinstance(value, str | int | float | bool | None):
|
|
64
64
|
return value
|
|
65
|
-
if isinstance(value, int | float | bool):
|
|
66
|
-
return value # Don't serialize primitives yet
|
|
67
65
|
if isinstance(value, bytes):
|
|
68
66
|
return base64.b64encode(value).decode("utf-8")
|
|
69
67
|
if isinstance(value, BaseModel):
|
mirascope/core/base/tool.py
CHANGED
|
@@ -122,6 +122,15 @@ class BaseTool(BaseModel, ABC):
|
|
|
122
122
|
if field not in {"tool_call", "delta"}
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
@property
|
|
126
|
+
def id(self) -> str | None:
|
|
127
|
+
"""The id of the tool."""
|
|
128
|
+
if tool_call := getattr(self, "tool_call", None):
|
|
129
|
+
# Expect tool_call has an id attribute.
|
|
130
|
+
# If not, we should override this method on the provider tool
|
|
131
|
+
return getattr(tool_call, "id", None)
|
|
132
|
+
return None
|
|
133
|
+
|
|
125
134
|
@abstractmethod
|
|
126
135
|
def call(self, *args: Any, **kwargs: Any) -> Any: # noqa: ANN401
|
|
127
136
|
"""The method to call the tool."""
|
|
@@ -100,25 +100,27 @@ class BedrockMessageParamConverter(BaseMessageParamConverter):
|
|
|
100
100
|
)
|
|
101
101
|
elif "toolUse" in block:
|
|
102
102
|
tool_use = block["toolUse"]
|
|
103
|
+
|
|
104
|
+
tool_use_part = ToolCallPart(
|
|
105
|
+
type="tool_call",
|
|
106
|
+
name=tool_use["name"],
|
|
107
|
+
id=tool_use["toolUseId"],
|
|
108
|
+
args=tool_use["input"],
|
|
109
|
+
)
|
|
103
110
|
if converted_content:
|
|
111
|
+
converted_content.append(tool_use_part)
|
|
104
112
|
converted.append(
|
|
105
113
|
BaseMessageParam(
|
|
106
114
|
role=message_param["role"], content=converted_content
|
|
107
115
|
)
|
|
108
116
|
)
|
|
109
117
|
converted_content = []
|
|
118
|
+
continue
|
|
110
119
|
|
|
111
120
|
converted.append(
|
|
112
121
|
BaseMessageParam(
|
|
113
122
|
role="assistant",
|
|
114
|
-
content=[
|
|
115
|
-
ToolCallPart(
|
|
116
|
-
type="tool_call",
|
|
117
|
-
name=tool_use["name"],
|
|
118
|
-
id=tool_use["toolUseId"],
|
|
119
|
-
args=tool_use["input"],
|
|
120
|
-
)
|
|
121
|
-
],
|
|
123
|
+
content=[tool_use_part],
|
|
122
124
|
)
|
|
123
125
|
)
|
|
124
126
|
elif "toolResult" in block:
|
|
@@ -137,7 +139,6 @@ class BedrockMessageParamConverter(BaseMessageParamConverter):
|
|
|
137
139
|
ToolResultPart(
|
|
138
140
|
type="tool_result",
|
|
139
141
|
id=tool_result["toolUseId"],
|
|
140
|
-
name=tool_result["name"], # pyright: ignore [reportGeneralTypeIssues]
|
|
141
142
|
content=tool_result["content"]
|
|
142
143
|
if isinstance(tool_result["content"], str)
|
|
143
144
|
else tool_result["content"][0]["text"], # pyright: ignore [reportTypedDictNotRequiredAccess]
|
mirascope/core/bedrock/tool.py
CHANGED
|
@@ -56,6 +56,10 @@ class BedrockTool(BaseTool):
|
|
|
56
56
|
|
|
57
57
|
tool_call: SkipJsonSchema[ToolUseBlockContentTypeDef]
|
|
58
58
|
|
|
59
|
+
@property
|
|
60
|
+
def id(self) -> str | None:
|
|
61
|
+
return self.tool_call["toolUse"]["toolUseId"]
|
|
62
|
+
|
|
59
63
|
@classmethod
|
|
60
64
|
def tool_schema(cls) -> ToolTypeDef:
|
|
61
65
|
"""Constructs a JSON Schema tool schema from the `BaseModel` schema defined.
|
mirascope/llm/call_response.py
CHANGED
|
@@ -142,15 +142,6 @@ class CallResponse(
|
|
|
142
142
|
tools_and_outputs: The sequence of tools and their outputs from which the tool
|
|
143
143
|
message parameters should be constructed.
|
|
144
144
|
"""
|
|
145
|
-
|
|
146
|
-
def _get_tool_call_id(_tool: BaseTool) -> str | None:
|
|
147
|
-
"""Get the tool call ID."""
|
|
148
|
-
if tool_call := getattr(_tool, "tool_call", None):
|
|
149
|
-
# Expect tool_call has an id attribute.
|
|
150
|
-
# If not, we should implement a method to get the id on the provider tool
|
|
151
|
-
return getattr(tool_call, "id", None)
|
|
152
|
-
return None
|
|
153
|
-
|
|
154
145
|
return [
|
|
155
146
|
BaseMessageParam(
|
|
156
147
|
role="tool",
|
|
@@ -159,7 +150,7 @@ class CallResponse(
|
|
|
159
150
|
type="tool_result",
|
|
160
151
|
name=tool._name(),
|
|
161
152
|
content=output,
|
|
162
|
-
id=
|
|
153
|
+
id=tool.id,
|
|
163
154
|
)
|
|
164
155
|
],
|
|
165
156
|
)
|
|
@@ -66,7 +66,7 @@ mirascope/core/azure/_call.py,sha256=SHqSJe6_4zgn4Y9PkpDl4vXvLuT4QmVnWUcws9e_RR8
|
|
|
66
66
|
mirascope/core/azure/_call_kwargs.py,sha256=q38xKSgCBWi8DLScepG-KnUfgi67AU6xr2uOHwCZ2mI,435
|
|
67
67
|
mirascope/core/azure/call_params.py,sha256=NK_ggVJbactDip85DbfCaqSWRpO0CgwN1svY-KW4_Yg,1836
|
|
68
68
|
mirascope/core/azure/call_response.py,sha256=FzSqAunmZCeVhQIei2_YcUqZBnJUgmEFFT4jHiJFm28,7068
|
|
69
|
-
mirascope/core/azure/call_response_chunk.py,sha256=
|
|
69
|
+
mirascope/core/azure/call_response_chunk.py,sha256=bWgpT-XldmetNwcQmpVVHRCLn6B6UKM6NK_RAxb2Zio,3224
|
|
70
70
|
mirascope/core/azure/dynamic_config.py,sha256=6SBMGFce7tuXdwHrlKNISpZxVxUnnumbIQB9lGR6nbs,1066
|
|
71
71
|
mirascope/core/azure/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
72
72
|
mirascope/core/azure/stream.py,sha256=XfEO6sOgnXiOhhuagrFdtFI-oQECxBP0Zt0wbfUH1TU,4637
|
|
@@ -88,7 +88,7 @@ mirascope/core/base/_extract_with_tools.py,sha256=MW4v8D1xty7LqLb5RwMFkX-peQqA73
|
|
|
88
88
|
mirascope/core/base/_partial.py,sha256=w_ACCgsDKNLtMyAP-lNmfRdrFEPmzh2BT4aninajxyY,3240
|
|
89
89
|
mirascope/core/base/call_kwargs.py,sha256=0mznCsrj1dYxvdwYNF0RKbc9CiU5G6WvvcjPqOMsOE4,351
|
|
90
90
|
mirascope/core/base/call_params.py,sha256=wtuuOY-SwIZYCDBKfn_xRC0Kf1cUuI4eSQaXu6VrtaE,1331
|
|
91
|
-
mirascope/core/base/call_response.py,sha256=
|
|
91
|
+
mirascope/core/base/call_response.py,sha256=2f7ETVpr3ZPcTfGJ7aQp4xlN-7fU7IWDvdfT-fMzDr0,10632
|
|
92
92
|
mirascope/core/base/call_response_chunk.py,sha256=ZfulgERwgva55TLrQI9XimX8bpgOqBNLs_I-_kELl-4,3606
|
|
93
93
|
mirascope/core/base/dynamic_config.py,sha256=V5IG2X5gPFpfQ47uO8JU1zoC2eNdRftsRZEmwhRPaYI,2859
|
|
94
94
|
mirascope/core/base/from_call_args.py,sha256=8ijMX7PN6a4o6uLdmXJlSRnE-rEVJU5NLxUmNrS8dvU,909
|
|
@@ -101,7 +101,7 @@ mirascope/core/base/response_model_config_dict.py,sha256=OUdx_YkV2vBzUSSB2OYLAAH
|
|
|
101
101
|
mirascope/core/base/stream.py,sha256=ZHjC9MQ3HT9KMbqCKTB0um2fvMLJmRYU_eSGdfRj79I,17274
|
|
102
102
|
mirascope/core/base/stream_config.py,sha256=vwWqNh9NJhTYjiJmfDbC9D5O84je_lBRhNOt4wI3FHM,238
|
|
103
103
|
mirascope/core/base/structured_stream.py,sha256=FIvLXXKninrpQ5P7MsLEqGrU4cfvEDiPbueZqgJ4Dlw,10395
|
|
104
|
-
mirascope/core/base/tool.py,sha256=
|
|
104
|
+
mirascope/core/base/tool.py,sha256=or8Zv0reSLSGjBAxlcfX4MzEQyhyPv-HOivJLJ9rQGs,7220
|
|
105
105
|
mirascope/core/base/toolkit.py,sha256=GmZquYPqvQL2J9Hd6StEwx6jfeFsqtcUyxKvp4iW_7Q,6271
|
|
106
106
|
mirascope/core/base/types.py,sha256=4GVyVzHThWJU2Og-wpVbYNPZD8QMdHltIAV83FUlisM,9247
|
|
107
107
|
mirascope/core/base/_utils/__init__.py,sha256=Tm-9-6k7cZL3IaqebOEaKpTg9nFUMfAGHHeKmC3YzLQ,3192
|
|
@@ -145,19 +145,19 @@ mirascope/core/bedrock/_call.py,sha256=8Z8sdzpTdJsMHBev35B1KH3O16_eMLbtTkOmPB7bz
|
|
|
145
145
|
mirascope/core/bedrock/_call_kwargs.py,sha256=N1d_iglnwZW3JrcaT8WTOeuLT5MYcVLU5vS8u8uyEL4,408
|
|
146
146
|
mirascope/core/bedrock/_types.py,sha256=ntmzYsgT6wuigv1GavkdqCvJnAYRsFvVuIwxafE4DFY,3229
|
|
147
147
|
mirascope/core/bedrock/call_params.py,sha256=3eKNYTteCTaPLqvAcy1vHU5aY9nMVNhmApL45ugPbrQ,1716
|
|
148
|
-
mirascope/core/bedrock/call_response.py,sha256=
|
|
148
|
+
mirascope/core/bedrock/call_response.py,sha256=V9YFYdPxW415t-yBq4Y5Jexn5hkewiePnWv9gghW9JA,8359
|
|
149
149
|
mirascope/core/bedrock/call_response_chunk.py,sha256=EAs0mJseL-C4dlnEhggtUT8_s6L2d5lSAqrIjLxQepI,3524
|
|
150
150
|
mirascope/core/bedrock/dynamic_config.py,sha256=X6v93X9g14mfvkGLL08yX-xTFGgX8y8bVngNmExdUhQ,1166
|
|
151
151
|
mirascope/core/bedrock/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
152
152
|
mirascope/core/bedrock/stream.py,sha256=UyA6b7l3-MjEULzo-DXF-le7N3oQw6W5FFk48_K93a0,5219
|
|
153
|
-
mirascope/core/bedrock/tool.py,sha256=
|
|
153
|
+
mirascope/core/bedrock/tool.py,sha256=tgt__paZyzpN1_NdTVKh-2hIWHah2Ect8lAfM1GEl-s,2758
|
|
154
154
|
mirascope/core/bedrock/_utils/__init__.py,sha256=OYpHXxPRbgasCLz_emLatmNa5WCb_S6pvVFHcNoGy9E,389
|
|
155
155
|
mirascope/core/bedrock/_utils/_convert_common_call_params.py,sha256=i17yrW-_7qdIsf-zS3OD5HIO0uykCdfanPsjV3WxTEY,1091
|
|
156
156
|
mirascope/core/bedrock/_utils/_convert_finish_reason_to_common_finish_reasons.py,sha256=A67-Q3zgpXh9q0iub5IfJw9VRgHvK-pczt1Btot_jks,792
|
|
157
157
|
mirascope/core/bedrock/_utils/_convert_message_params.py,sha256=ZPFj34ed0-4bmMldj4tR6EGb9RsuHkXzSwjmwEeN-KU,4680
|
|
158
158
|
mirascope/core/bedrock/_utils/_get_json_output.py,sha256=hW-IBBQ5YW85VljjFJHDDtu66zsaF2ydTbFxgCX_j6A,1159
|
|
159
159
|
mirascope/core/bedrock/_utils/_handle_stream.py,sha256=s8KNMNDKzvSIkFROtaZgbEJry78X_qCzTvGmHcL7UW0,3776
|
|
160
|
-
mirascope/core/bedrock/_utils/_message_param_converter.py,sha256=
|
|
160
|
+
mirascope/core/bedrock/_utils/_message_param_converter.py,sha256=BCoFozjclkqAZq1InB1ar_IAVGMW9xclU1bK-oi2zI0,6765
|
|
161
161
|
mirascope/core/bedrock/_utils/_setup_call.py,sha256=XQs-JlviE0uhbBxEpjXP8812NbiObLYx5VkAwJJAF84,9168
|
|
162
162
|
mirascope/core/cohere/__init__.py,sha256=vk73WFGBOEmMFEiqWMRnPfxsCBDlDcq8SaLB2A6RKeo,830
|
|
163
163
|
mirascope/core/cohere/_call.py,sha256=y0nB_7h7FWCNxHRPywtAVCYXyeYX3uzTyYBPWnuLwUE,2261
|
|
@@ -339,7 +339,7 @@ mirascope/llm/_context.py,sha256=vtHJkLlFfUwyR_hYEHXAw3xunpHhLn67k4kuFw50GR8,124
|
|
|
339
339
|
mirascope/llm/_override.py,sha256=m4MdOhM-aJRIGP7NBJhscq3ISNct6FBPn3jjmryFo_Q,112292
|
|
340
340
|
mirascope/llm/_protocols.py,sha256=HXspRAC0PduGqbh2BM0CGe5iVj7CC3ZKMPAYvFvbDNQ,16406
|
|
341
341
|
mirascope/llm/_response_metaclass.py,sha256=6DLQb5IrqMldyEXHT_pAsr2DlUVc9CmZuZiBXG37WK8,851
|
|
342
|
-
mirascope/llm/call_response.py,sha256=
|
|
342
|
+
mirascope/llm/call_response.py,sha256=tJ6jHZ4PFaYf_4Hn9OihlVqOxNEM9d6gAi4Bo15XXnQ,4825
|
|
343
343
|
mirascope/llm/call_response_chunk.py,sha256=bZwO43ipc6PO1VLgGSaAPRqCIUyZD_Ty5oxdJX62yno,1966
|
|
344
344
|
mirascope/llm/stream.py,sha256=GtUKyLBlKqqZTOKjdL9FLInCXJ0ZOEAe6nymbjKwyTQ,5293
|
|
345
345
|
mirascope/llm/tool.py,sha256=MQRJBPhP1d-OyOz3PE_VsKmSXca0chySyYO1U9OW8ck,1824
|
|
@@ -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.24.
|
|
375
|
-
mirascope-1.24.
|
|
376
|
-
mirascope-1.24.
|
|
377
|
-
mirascope-1.24.
|
|
374
|
+
mirascope-1.24.1.dist-info/METADATA,sha256=CF6YrOzpQRtxq7M0Pz_cl5d3m2dyjy2rO08z64sEzN8,8542
|
|
375
|
+
mirascope-1.24.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
376
|
+
mirascope-1.24.1.dist-info/licenses/LICENSE,sha256=LAs5Q8mdawTsVdONpDGukwsoc4KEUBmmonDEL39b23Y,1072
|
|
377
|
+
mirascope-1.24.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|