model-library 0.1.9__py3-none-any.whl → 0.1.10__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.
@@ -58,6 +58,7 @@ from model_library.exceptions import (
58
58
  ImmediateRetryException,
59
59
  InvalidStructuredOutputError,
60
60
  ModelNoOutputError,
61
+ RetryException,
61
62
  )
62
63
  from model_library.providers.google.batch import GoogleBatchMixin
63
64
  from model_library.register_models import register_provider
@@ -195,7 +196,7 @@ class GoogleModel(LLM):
195
196
  # id check
196
197
  new_input.append(
197
198
  Content(
198
- role="function",
199
+ role="user",
199
200
  parts=[
200
201
  Part.from_function_response(
201
202
  name=item.tool_call.name,
@@ -406,10 +407,20 @@ class GoogleModel(LLM):
406
407
  finish_reason = candidates[0].finish_reason
407
408
 
408
409
  if finish_reason != FinishReason.STOP:
409
- self.logger.error(f"Unexpected finish reason: {finish_reason}")
410
+ self.logger.error(
411
+ f"Unexpected finish reason: {finish_reason}, chunks: {chunks}"
412
+ )
413
+
414
+ if finish_reason == FinishReason.MALFORMED_FUNCTION_CALL:
415
+ # gemini handles malformed function calls server side
416
+ # we don't want to return the content that was supposed to have a tool call, without that tool call
417
+ # and since we don't get any info on the params, we throw an error
418
+
419
+ self.logger.error("The function call was malformed")
420
+ raise RetryException("The function call was malformed")
410
421
 
411
422
  if not text and not reasoning and not tool_calls:
412
- self.logger.error(f"Chunks: {chunks}")
423
+ self.logger.error(f"Empty response. Chunks: {chunks}")
413
424
  raise ModelNoOutputError("Model returned empty response")
414
425
 
415
426
  result = QueryResult(
@@ -611,6 +611,12 @@ class OpenAIModel(LLM):
611
611
  if tool_call_chunk.id and (
612
612
  not raw_tool_calls
613
613
  or raw_tool_calls[-1].id != tool_call_chunk.id
614
+ or (
615
+ raw_tool_calls[-1].id == tool_call_chunk.id
616
+ and self.provider == "deepseek"
617
+ and func
618
+ and func.name
619
+ ) # TODO: remove hotfix once deepseek fixes their stuff
614
620
  ):
615
621
  raw_tool_calls.append(
616
622
  ChatCompletionMessageToolCall(
@@ -625,7 +631,7 @@ class OpenAIModel(LLM):
625
631
  )
626
632
  )
627
633
  # accumulate delta
628
- elif func:
634
+ elif func and raw_tool_calls:
629
635
  if func.name:
630
636
  raw_tool_calls[-1].function.name = func.name
631
637
  if func.arguments:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: model-library
3
- Version: 0.1.9
3
+ Version: 0.1.10
4
4
  Summary: Model Library for vals.ai
5
5
  Author-email: "Vals AI, Inc." <contact@vals.ai>
6
6
  License: MIT
@@ -21,7 +21,7 @@ Requires-Dist: mistralai<2.0,>=1.9.10
21
21
  Requires-Dist: xai-sdk<2.0,>=1.0.0
22
22
  Requires-Dist: ai21<5.0,>=4.3.0
23
23
  Requires-Dist: boto3<2.0,>=1.38.27
24
- Requires-Dist: google-genai[aiohttp]>=1.51.0
24
+ Requires-Dist: google-genai[aiohttp]>=1.62.0
25
25
  Requires-Dist: google-cloud-storage>=1.26.0
26
26
  Requires-Dist: pytest-xdist>=3.8.0
27
27
  Dynamic: license-file
@@ -49,7 +49,7 @@ model_library/providers/inception.py,sha256=_UHWd8b3_YbR5tHXOGwPkz5YHEBXVaYM8bP0
49
49
  model_library/providers/kimi.py,sha256=r1K0mbaNY_OUTERLttoItcjWMb9wTu7ghEIP0kXblG0,1362
50
50
  model_library/providers/minimax.py,sha256=VTLzELrya4q_q5pdkmOA61kALbMu6ZkNxMdkuIZSDY8,1361
51
51
  model_library/providers/mistral.py,sha256=SkIHBkeDZuLfNYkvcm7holk63zNIIGJ8KmoXjQi399o,10299
52
- model_library/providers/openai.py,sha256=tDWozNzs8jcbtjQWEoMzYQq0qZObqOb_iK5AD-MVT3k,37618
52
+ model_library/providers/openai.py,sha256=H1QfyXegHQihPeOK1NBw0zE_wX6LfARVGMrsiClIXSE,37982
53
53
  model_library/providers/openrouter.py,sha256=FRKyeUyCSSQFCvoKvVbKzYJ_SL60jEU-Y6wWDyvevYc,962
54
54
  model_library/providers/perplexity.py,sha256=GT7nfu42ATbG7Eu_J8nrIwJMr_BpFpLOaQVOQG4gtRk,961
55
55
  model_library/providers/together.py,sha256=M1xAsbBd-41a3yHj2MDrysrIav9pp7eqGYUo16a4L8s,1911
@@ -60,14 +60,14 @@ model_library/providers/xiaomi.py,sha256=OJKz_dbolWt3lPkllw91Ntx1uoLQL_eM8VOEccN
60
60
  model_library/providers/zai.py,sha256=C-0Q41vEhsb6PIbFIW4kXGSx1-mTuB-czB7Vq1_KBqk,1924
61
61
  model_library/providers/google/__init__.py,sha256=ypuLVL_QJEQ7C3S47FhC9y4wyawYOdGikAViJmACI0U,115
62
62
  model_library/providers/google/batch.py,sha256=kqe9ponDe9Tkrh_-4kWd5-47wYf4V_XSKXZnrFOzAHc,10187
63
- model_library/providers/google/google.py,sha256=mSbzEujS45vexUsDCL7gdRVgv6yZGDqE6-iDt2cGHDI,18766
63
+ model_library/providers/google/google.py,sha256=IrcfygqDcsaHcQAabMVZ65sTgmbpVU8ZarOj3mvWwXI,19304
64
64
  model_library/retriers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
65
65
  model_library/retriers/backoff.py,sha256=vmpzLje51yfvSgAEST_yNrL87_J_0pmI-jwnRek5Ie0,2296
66
66
  model_library/retriers/base.py,sha256=zmiGZq4yvJx7aE0FD8rqZuJxZavhKTXLjt58z5TKJNw,6832
67
67
  model_library/retriers/token.py,sha256=ypHzuJjEORsv931sjEI1lejRO8Ju_ljSrCGV4pgaa34,16794
68
68
  model_library/retriers/utils.py,sha256=fhtQ64aT8mZcwZ8aTXnLRU4HVIf8JQ3CfmArvxZPWvQ,279
69
- model_library-0.1.9.dist-info/licenses/LICENSE,sha256=x6mf4o7U_wHaaqcfxoU-0R6uYJLbqL_TNuoULP3asaA,1070
70
- model_library-0.1.9.dist-info/METADATA,sha256=1mJTenP1YD-twt90UzMzZNEFRKOM4lVQ3dNve34jvs8,7024
71
- model_library-0.1.9.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
72
- model_library-0.1.9.dist-info/top_level.txt,sha256=HtQYxA_7RP8UT35I6VcUw20L6edI0Zf2t5Ys1uDGVjs,14
73
- model_library-0.1.9.dist-info/RECORD,,
69
+ model_library-0.1.10.dist-info/licenses/LICENSE,sha256=x6mf4o7U_wHaaqcfxoU-0R6uYJLbqL_TNuoULP3asaA,1070
70
+ model_library-0.1.10.dist-info/METADATA,sha256=Z9yL5DixUa51LvxWseNBrAzv74zh0Is4HGOpHgI3Xs0,7025
71
+ model_library-0.1.10.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
72
+ model_library-0.1.10.dist-info/top_level.txt,sha256=HtQYxA_7RP8UT35I6VcUw20L6edI0Zf2t5Ys1uDGVjs,14
73
+ model_library-0.1.10.dist-info/RECORD,,