mirascope 1.22.3__py3-none-any.whl → 1.22.5__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.
@@ -48,7 +48,9 @@ class GoogleMessageParamConverter(BaseMessageParamConverter):
48
48
  for message_param in message_params:
49
49
  if isinstance(message_param, dict):
50
50
  message_param = Content.model_validate(message_param)
51
- role: str = "assistant"
51
+ role = message_param.role
52
+ if not role or role == "model":
53
+ role = "assistant"
52
54
  content_list = []
53
55
  for part in message_param.parts or []:
54
56
  if part.text:
@@ -22,6 +22,7 @@ def convert_message_params(
22
22
  else:
23
23
  converted_content = []
24
24
 
25
+ tool_calls = []
25
26
  for part in content:
26
27
  if part.type == "text":
27
28
  converted_content.append(part.model_dump())
@@ -100,25 +101,16 @@ def convert_message_params(
100
101
  }
101
102
  )
102
103
  elif part.type == "tool_call":
103
- converted_message_param = {
104
- "role": "assistant",
105
- "name": part.name,
106
- "tool_calls": [
107
- {
108
- "function": {
109
- "name": part.name,
110
- "arguments": json.dumps(part.args),
111
- },
112
- "type": "function",
113
- "id": part.id,
114
- }
115
- ],
116
- }
117
-
118
- if converted_content:
119
- converted_message_param["content"] = converted_content
120
- converted_content = []
121
- converted_message_params.append(converted_message_param)
104
+ tool_calls.append(
105
+ {
106
+ "function": {
107
+ "name": part.name,
108
+ "arguments": json.dumps(part.args),
109
+ },
110
+ "type": "function",
111
+ "id": part.id,
112
+ }
113
+ )
122
114
  elif part.type == "tool_result":
123
115
  if converted_content:
124
116
  converted_message_params.append(
@@ -138,9 +130,19 @@ def convert_message_params(
138
130
  "OpenAI currently only supports text, image and audio parts. "
139
131
  f"Part provided: {part.type}"
140
132
  )
141
- if converted_content:
133
+ if tool_calls:
134
+ converted_message_param = {
135
+ "role": "assistant",
136
+ "tool_calls": tool_calls,
137
+ }
138
+ converted_message_params.append(converted_message_param)
139
+ if converted_content:
140
+ converted_message_param["content"] = converted_content
141
+ elif converted_content:
142
142
  converted_message_params.append(
143
- {"role": message_param.role, "content": converted_content}
143
+ {
144
+ "role": message_param.role,
145
+ "content": converted_content,
146
+ }
144
147
  )
145
- # print(converted_message_params)
146
148
  return converted_message_params
mirascope/llm/_call.py CHANGED
@@ -238,6 +238,7 @@ def _call(
238
238
  | Awaitable[_ParsedOutputT]
239
239
  | Awaitable[(_ResponseModelT | CallResponse)],
240
240
  ]:
241
+ fn.__mirascope_call__ = True # pyright: ignore [reportFunctionMemberAccess]
241
242
  if fn_is_async(fn):
242
243
  # Create a wrapper function that captures the current context when called
243
244
  @wraps(fn)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mirascope
3
- Version: 1.22.3
3
+ Version: 1.22.5
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
@@ -224,7 +224,7 @@ mirascope/core/google/_utils/_convert_finish_reason_to_common_finish_reasons.py,
224
224
  mirascope/core/google/_utils/_convert_message_params.py,sha256=9I7Q79Z8tBCLZtfjWJNQkuKgz0n2L43SzHB3cV3hNmY,8926
225
225
  mirascope/core/google/_utils/_get_json_output.py,sha256=sxDgT0Ra6YJynL5_hhakf0dNJEhZm0DfAgfcvC_DAFU,1596
226
226
  mirascope/core/google/_utils/_handle_stream.py,sha256=BxFuheAu1LKPrPsDxxiLWd2KoajkwJyx2_QT1NXwtWE,1212
227
- mirascope/core/google/_utils/_message_param_converter.py,sha256=wvvxUY9lOhR_kFZ4JigjWmN8O8Vovu-fLoi-NDtyorE,6580
227
+ mirascope/core/google/_utils/_message_param_converter.py,sha256=qOj8bAdQusFhLg-mzQ1TJwbMQHvjY7DYrTGOIylu5hs,6661
228
228
  mirascope/core/google/_utils/_setup_call.py,sha256=UoV4McGgSS79PKErjArCmrq1HmpFvq2qegJYoyY4P5U,6469
229
229
  mirascope/core/google/_utils/_validate_media_type.py,sha256=sUOjKpC498L-NCiECejAAfSzMUAvZT84rf-2Yo-JE58,1042
230
230
  mirascope/core/groq/__init__.py,sha256=8jWCQScdei_TImGMWUwiKnlOwffQqaXdAL-bluFmEL0,798
@@ -285,7 +285,7 @@ mirascope/core/openai/stream.py,sha256=jyI9Q4-Ne4N34n30RzRCYsi8z-hFqXbV_Occ7KrFk
285
285
  mirascope/core/openai/tool.py,sha256=iJWJQrY3-1Rq5OywzKFO9JUAcglneGD0UtkS3pcA0pg,3154
286
286
  mirascope/core/openai/_utils/__init__.py,sha256=Y1nMFOydpFvMWcuoB8TzMD33uZoMIM0C8_kYJkv_JJE,388
287
287
  mirascope/core/openai/_utils/_convert_common_call_params.py,sha256=gvxsRdULxiC2137M9l53hUmF0ZkBxFQFurhWBcl_5Cg,739
288
- mirascope/core/openai/_utils/_convert_message_params.py,sha256=1VkGEQktopnhmYWJ8-xJKi1KY54ego7Jc3xBhdezbBA,6236
288
+ mirascope/core/openai/_utils/_convert_message_params.py,sha256=B4pNV-QDR6bLaJVif1pjEogeEASzhPA6YokPGGLQaNw,6219
289
289
  mirascope/core/openai/_utils/_get_json_output.py,sha256=Q_5R6NFFDvmLoz9BQiymC5AEyYvxKPH2_XnOQZ8hIkU,1215
290
290
  mirascope/core/openai/_utils/_handle_stream.py,sha256=adsHAcTtGyMMFU9xnUsE4Yd2wrhSNSjcVddkS74mli0,5226
291
291
  mirascope/core/openai/_utils/_message_param_converter.py,sha256=r6zJ54xHMxxJ-2daY8l5FyDIa0HsdXeP0cN1wHNt6-E,4101
@@ -334,7 +334,7 @@ mirascope/integrations/otel/_utils.py,sha256=SCVb3MpcpqLpCpumJEbEdINceNdusnyT6iu
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
336
  mirascope/llm/__init__.py,sha256=rCukXJUqSGiDGNMMM9g3NS8clnrCxgCpaFIXIG1M660,432
337
- mirascope/llm/_call.py,sha256=zPULSy5GLlJszphRvc3WUSFEsmP83Abp0FzbZefTa8Y,13848
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
340
340
  mirascope/llm/_protocols.py,sha256=HXspRAC0PduGqbh2BM0CGe5iVj7CC3ZKMPAYvFvbDNQ,16406
@@ -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.22.3.dist-info/METADATA,sha256=FCTObICqUL1p5C3m5zBUJP2tvPnWlT_Rsumt0u90_H0,8783
375
- mirascope-1.22.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
376
- mirascope-1.22.3.dist-info/licenses/LICENSE,sha256=LAs5Q8mdawTsVdONpDGukwsoc4KEUBmmonDEL39b23Y,1072
377
- mirascope-1.22.3.dist-info/RECORD,,
374
+ mirascope-1.22.5.dist-info/METADATA,sha256=HIVPcLXEYG16Rr2SxAz1ogSCdHk5vQGGJZrcmmdB56M,8783
375
+ mirascope-1.22.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
376
+ mirascope-1.22.5.dist-info/licenses/LICENSE,sha256=LAs5Q8mdawTsVdONpDGukwsoc4KEUBmmonDEL39b23Y,1072
377
+ mirascope-1.22.5.dist-info/RECORD,,