mirascope 1.18.1__py3-none-any.whl → 1.18.2__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/google/_utils/_convert_message_params.py +30 -26
- mirascope/core/google/_utils/_message_param_converter.py +8 -2
- {mirascope-1.18.1.dist-info → mirascope-1.18.2.dist-info}/METADATA +1 -1
- {mirascope-1.18.1.dist-info → mirascope-1.18.2.dist-info}/RECORD +6 -6
- {mirascope-1.18.1.dist-info → mirascope-1.18.2.dist-info}/WHEEL +0 -0
- {mirascope-1.18.1.dist-info → mirascope-1.18.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -63,7 +63,10 @@ def convert_message_params(
|
|
|
63
63
|
)
|
|
64
64
|
)
|
|
65
65
|
elif part.type == "image_url":
|
|
66
|
-
if
|
|
66
|
+
if (
|
|
67
|
+
part.url.startswith(("https://", "http://"))
|
|
68
|
+
and "generativelanguage.googleapis.com" not in part.url
|
|
69
|
+
):
|
|
67
70
|
downloaded_image = io.BytesIO(_load_media(part.url))
|
|
68
71
|
image = PIL.Image.open(downloaded_image)
|
|
69
72
|
media_type = (
|
|
@@ -92,24 +95,15 @@ def convert_message_params(
|
|
|
92
95
|
)
|
|
93
96
|
uri = file_ref.uri
|
|
94
97
|
media_type = file_ref.mime_type
|
|
95
|
-
|
|
96
|
-
converted_content.append(
|
|
97
|
-
PartDict(
|
|
98
|
-
file_data=FileDataDict(
|
|
99
|
-
file_uri=uri, mime_type=media_type
|
|
100
|
-
)
|
|
101
|
-
)
|
|
102
|
-
)
|
|
103
98
|
else:
|
|
104
|
-
media_type = "image/unknown"
|
|
105
99
|
uri = part.url
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
)
|
|
100
|
+
media_type = None
|
|
101
|
+
|
|
102
|
+
converted_content.append(
|
|
103
|
+
PartDict(
|
|
104
|
+
file_data=FileDataDict(file_uri=uri, mime_type=media_type)
|
|
112
105
|
)
|
|
106
|
+
)
|
|
113
107
|
elif part.type == "audio":
|
|
114
108
|
if part.media_type not in [
|
|
115
109
|
"audio/wav",
|
|
@@ -135,9 +129,12 @@ def convert_message_params(
|
|
|
135
129
|
)
|
|
136
130
|
)
|
|
137
131
|
elif part.type == "audio_url":
|
|
138
|
-
if
|
|
139
|
-
|
|
140
|
-
|
|
132
|
+
if (
|
|
133
|
+
part.url.startswith(("https://", "http://"))
|
|
134
|
+
and "generativelanguage.googleapis.com" not in part.url
|
|
135
|
+
):
|
|
136
|
+
downloaded_audio = _load_media(part.url)
|
|
137
|
+
audio_type = get_audio_type(downloaded_audio)
|
|
141
138
|
if audio_type not in [
|
|
142
139
|
"audio/wav",
|
|
143
140
|
"audio/mp3",
|
|
@@ -151,16 +148,23 @@ def convert_message_params(
|
|
|
151
148
|
"Google currently only supports WAV, MP3, AIFF, AAC, OGG, "
|
|
152
149
|
"and FLAC audio file types."
|
|
153
150
|
)
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
151
|
+
if client.vertexai:
|
|
152
|
+
uri = part.url
|
|
153
|
+
else:
|
|
154
|
+
downloaded_audio = io.BytesIO(downloaded_audio)
|
|
155
|
+
downloaded_audio.seek(0)
|
|
156
|
+
file_ref = client.files.upload(
|
|
157
|
+
file=downloaded_audio, config={"mime_type": audio_type}
|
|
158
|
+
)
|
|
159
|
+
uri = file_ref.uri
|
|
160
|
+
media_type = file_ref.mime_type
|
|
157
161
|
else:
|
|
158
|
-
|
|
162
|
+
uri = part.url
|
|
163
|
+
audio_type = None
|
|
164
|
+
|
|
159
165
|
converted_content.append(
|
|
160
166
|
PartDict(
|
|
161
|
-
file_data=FileDataDict(
|
|
162
|
-
file_uri=part.url, mime_type=audio_type
|
|
163
|
-
)
|
|
167
|
+
file_data=FileDataDict(file_uri=uri, mime_type=audio_type)
|
|
164
168
|
)
|
|
165
169
|
)
|
|
166
170
|
else:
|
|
@@ -104,8 +104,14 @@ class GoogleMessageParamConverter(BaseMessageParamConverter):
|
|
|
104
104
|
)
|
|
105
105
|
)
|
|
106
106
|
else:
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
# Since `FileDataDict` handles any file data, we use
|
|
108
|
+
# `ImageURLPart` for unknown mime types
|
|
109
|
+
content_list.append(
|
|
110
|
+
ImageURLPart(
|
|
111
|
+
type="image_url",
|
|
112
|
+
url=cast(str, part.file_data.file_uri),
|
|
113
|
+
detail=None,
|
|
114
|
+
)
|
|
109
115
|
)
|
|
110
116
|
elif part.function_call:
|
|
111
117
|
converted.append(
|
|
@@ -212,10 +212,10 @@ mirascope/core/google/_utils/__init__.py,sha256=5MKOhK3NFseq2AlapU8TtWS82f8Z0ayJ
|
|
|
212
212
|
mirascope/core/google/_utils/_calculate_cost.py,sha256=fUyi6QAEa_NpPhtoAgVdQ7PpUa0QykNghsODrDtAYvw,3069
|
|
213
213
|
mirascope/core/google/_utils/_convert_common_call_params.py,sha256=KA-z6uvRtdD4WydC0eXd3dzQuSh4x4WKNR8PAqFNUVY,1065
|
|
214
214
|
mirascope/core/google/_utils/_convert_finish_reason_to_common_finish_reasons.py,sha256=ig4tb7Zanz-tyZpvc9Ncd47a2FNTOS7-wl1PYBq-4cY,879
|
|
215
|
-
mirascope/core/google/_utils/_convert_message_params.py,sha256=
|
|
215
|
+
mirascope/core/google/_utils/_convert_message_params.py,sha256=h2RfIOw26QSjF5ybdo7W2Ah9u-7qI3rewLzma1sgKQ0,7852
|
|
216
216
|
mirascope/core/google/_utils/_get_json_output.py,sha256=sxDgT0Ra6YJynL5_hhakf0dNJEhZm0DfAgfcvC_DAFU,1596
|
|
217
217
|
mirascope/core/google/_utils/_handle_stream.py,sha256=BxFuheAu1LKPrPsDxxiLWd2KoajkwJyx2_QT1NXwtWE,1212
|
|
218
|
-
mirascope/core/google/_utils/_message_param_converter.py,sha256=
|
|
218
|
+
mirascope/core/google/_utils/_message_param_converter.py,sha256=j-5fLlW2-3vI0kGQs-nVep_1kDr4kYYUBYYS9MV08Ks,6495
|
|
219
219
|
mirascope/core/google/_utils/_setup_call.py,sha256=LAoIrNTTF5EOHNLZroBcN8sNKOjMYKJ07hM49yBaUgE,5791
|
|
220
220
|
mirascope/core/groq/__init__.py,sha256=wo-_txqiLC3iswnXmPX4C6IgsU-_wv1DbBlNDY4rEvo,798
|
|
221
221
|
mirascope/core/groq/_call.py,sha256=gR8VN5IaYWIFXc0csn995q59FM0nBs-xVFjkVycPjMM,2223
|
|
@@ -350,7 +350,7 @@ mirascope/v0/base/ops_utils.py,sha256=1Qq-VIwgHBaYutiZsS2MUQ4OgPC3APyywI5bTiTAmA
|
|
|
350
350
|
mirascope/v0/base/prompts.py,sha256=FM2Yz98cSnDceYogiwPrp4BALf3_F3d4fIOCGAkd-SE,1298
|
|
351
351
|
mirascope/v0/base/types.py,sha256=ZfatJoX0Yl0e3jhv0D_MhiSVHLYUeJsdN3um3iE10zY,352
|
|
352
352
|
mirascope/v0/base/utils.py,sha256=XREPENRQTu8gpMhHU8RC8qH_am3FfGUvY-dJ6x8i-mw,681
|
|
353
|
-
mirascope-1.18.
|
|
354
|
-
mirascope-1.18.
|
|
355
|
-
mirascope-1.18.
|
|
356
|
-
mirascope-1.18.
|
|
353
|
+
mirascope-1.18.2.dist-info/METADATA,sha256=37QK3S0KrXlyR3HrMikdN36fE4cATMWLQfARj56jHoA,8678
|
|
354
|
+
mirascope-1.18.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
355
|
+
mirascope-1.18.2.dist-info/licenses/LICENSE,sha256=LAs5Q8mdawTsVdONpDGukwsoc4KEUBmmonDEL39b23Y,1072
|
|
356
|
+
mirascope-1.18.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|