mirascope 1.22.1__py3-none-any.whl → 1.22.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.
@@ -1,8 +1,6 @@
1
1
  from typing import cast
2
2
 
3
- from google.genai.types import (
4
- GenerationConfigDict,
5
- )
3
+ from google.genai.types import GenerateContentConfig
6
4
 
7
5
  from ...base.call_params import CommonCallParams
8
6
  from ..call_params import GoogleCallParams
@@ -17,23 +15,24 @@ GOOGLE_PARAM_MAPPING = {
17
15
 
18
16
  def convert_common_call_params(common_params: CommonCallParams) -> GoogleCallParams:
19
17
  """Convert CommonCallParams to Google parameters."""
20
- generation_config = {}
18
+ config = GenerateContentConfig()
21
19
 
22
20
  for key, value in common_params.items():
23
21
  if key not in GOOGLE_PARAM_MAPPING or value is None:
24
22
  continue
25
23
 
26
24
  if key == "stop":
27
- generation_config["stop_sequences"] = (
28
- [value] if isinstance(value, str) else value
29
- )
25
+ # Google API expects a list of strings for stop sequences
26
+ if isinstance(value, str):
27
+ config.stop_sequences = [value]
28
+ elif isinstance(value, list):
29
+ config.stop_sequences = value
30
30
  else:
31
- generation_config[GOOGLE_PARAM_MAPPING[key]] = value
31
+ target_attr = GOOGLE_PARAM_MAPPING[key]
32
+ setattr(config, target_attr, value)
32
33
 
33
- if not generation_config:
34
+ default_config = GenerateContentConfig()
35
+ if config == default_config:
34
36
  return cast(GoogleCallParams, {})
35
37
 
36
- return cast(
37
- GoogleCallParams,
38
- {"generation_config": cast(GenerationConfigDict, generation_config)},
39
- )
38
+ return cast(GoogleCallParams, {"config": config})
@@ -138,10 +138,12 @@ def setup_call(
138
138
 
139
139
  if messages[0] and messages[0].get("role") == "system":
140
140
  with _generate_content_config_context(call_kwargs) as config:
141
- config.system_instruction = [
142
- Part.model_validate(part)
143
- for part in (messages.pop(0).get("parts") or [])
144
- ]
141
+ system_message = messages.pop(0)
142
+ message_parts = system_message.get("parts", [])
143
+ if message_parts:
144
+ config.system_instruction = [
145
+ Part.model_validate(part) for part in message_parts
146
+ ]
145
147
 
146
148
  if json_mode:
147
149
  with _generate_content_config_context(call_kwargs) as config:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mirascope
3
- Version: 1.22.1
3
+ Version: 1.22.2
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
@@ -219,13 +219,13 @@ mirascope/core/google/dynamic_config.py,sha256=O6j8F0fLVFuuNwURneu5OpPuu_bMEtbDE
219
219
  mirascope/core/google/stream.py,sha256=bTxB8OUrKXxzmcX0C7_-LqtBfaAAazA5HjKZGSxxtLw,4466
220
220
  mirascope/core/google/tool.py,sha256=61a9Ejdxz41pwaab9VE2yvP_J1Aebua3BeRPJ_GJSnE,5138
221
221
  mirascope/core/google/_utils/__init__.py,sha256=vL0hx6WKW5lqpUcFTFCFGvmwtR-pts0JzWgCXhaUVrI,388
222
- mirascope/core/google/_utils/_convert_common_call_params.py,sha256=KA-z6uvRtdD4WydC0eXd3dzQuSh4x4WKNR8PAqFNUVY,1065
222
+ mirascope/core/google/_utils/_convert_common_call_params.py,sha256=TF7GWBHcpfzb7XmrxKp3gnaONITYF93lqr4XkSVz_uU,1195
223
223
  mirascope/core/google/_utils/_convert_finish_reason_to_common_finish_reasons.py,sha256=ig4tb7Zanz-tyZpvc9Ncd47a2FNTOS7-wl1PYBq-4cY,879
224
224
  mirascope/core/google/_utils/_convert_message_params.py,sha256=5FcMqK20OISCr00HP33w8219B1cNoy1AXkUmOeaIdkU,8079
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
227
  mirascope/core/google/_utils/_message_param_converter.py,sha256=eucmZl-zfU3cQiH5VVLs8_fJWf8zLg4-Q8KKChYFez4,6579
228
- mirascope/core/google/_utils/_setup_call.py,sha256=2t3yRly_I4l2jtJ8pJwi2f2crq7PF4d1Gh4EAaWgZcU,6361
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
231
231
  mirascope/core/groq/_call.py,sha256=gR8VN5IaYWIFXc0csn995q59FM0nBs-xVFjkVycPjMM,2223
@@ -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.1.dist-info/METADATA,sha256=YoitXID5GPP9Aj5JURQaBvSk07JHTnbA6s0PuDv37C8,8783
375
- mirascope-1.22.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
376
- mirascope-1.22.1.dist-info/licenses/LICENSE,sha256=LAs5Q8mdawTsVdONpDGukwsoc4KEUBmmonDEL39b23Y,1072
377
- mirascope-1.22.1.dist-info/RECORD,,
374
+ mirascope-1.22.2.dist-info/METADATA,sha256=RGtzNaKCz-5bjqHy3h1eR096sS2IWiDa1kSv6LWK9B4,8783
375
+ mirascope-1.22.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
376
+ mirascope-1.22.2.dist-info/licenses/LICENSE,sha256=LAs5Q8mdawTsVdONpDGukwsoc4KEUBmmonDEL39b23Y,1072
377
+ mirascope-1.22.2.dist-info/RECORD,,