gllm-inference-binary 0.5.17__cp313-cp313-macosx_13_0_x86_64.whl → 0.5.18__cp313-cp313-macosx_13_0_x86_64.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.

Potentially problematic release.


This version of gllm-inference-binary might be problematic. Click here for more details.

@@ -1,14 +1,23 @@
1
1
  from gllm_inference.em_invoker.em_invoker import BaseEMInvoker as BaseEMInvoker
2
- from gllm_inference.schema import Vector as Vector
2
+ from gllm_inference.schema import Attachment as Attachment, Vector as Vector
3
+ from gllm_inference.utils.io_utils import DEFAULT_BASE64_ALLOWED_MIMETYPES as DEFAULT_BASE64_ALLOWED_MIMETYPES, base64_to_bytes as base64_to_bytes
3
4
  from langchain_core.embeddings import Embeddings
4
5
  from pydantic import BaseModel
5
6
  from typing import Any
6
7
 
7
8
  class EMInvokerEmbeddings(BaseModel, Embeddings, arbitrary_types_allowed=True):
8
- """An adapter class that enables an `EMInvoker` to be used as a LangChain `Embeddings`.
9
+ '''An adapter class that enables an `EMInvoker` to be used as a LangChain `Embeddings`.
9
10
 
10
11
  Attributes:
11
12
  em_invoker (BaseEMInvoker): The `EMInvoker` instance to be interacted with.
13
+ use_base64 (bool):
14
+ Whether to apply strict base64 encoding to the input.
15
+ 1, If `True`, only inputs with specific MIME types (e.g. images,
16
+ audio, and video) will be converted into base64 strings before being sent.
17
+ 2. If `False`, each input is treated as a raw string.
18
+
19
+ This ensures "strict" handling: base64 encoding is not applied
20
+ universally, but only when required for those MIME types.
12
21
 
13
22
  Usage example:
14
23
  ```python
@@ -18,8 +27,9 @@ class EMInvokerEmbeddings(BaseModel, Embeddings, arbitrary_types_allowed=True):
18
27
  em_invoker = OpenAIEMInvoker(...)
19
28
  embeddings = EMInvokerEmbeddings(em_invoker=em_invoker)
20
29
  ```
21
- """
30
+ '''
22
31
  em_invoker: BaseEMInvoker
32
+ use_base64: bool
23
33
  async def aembed_documents(self, texts: list[str], **kwargs: Any) -> list[Vector]:
24
34
  """Asynchronously embed documents using the `EMInvoker`.
25
35
 
@@ -29,6 +39,9 @@ class EMInvokerEmbeddings(BaseModel, Embeddings, arbitrary_types_allowed=True):
29
39
 
30
40
  Returns:
31
41
  list[Vector]: List of embeddings, one for each text.
42
+
43
+ Raises:
44
+ ValueError: If `texts` is not a list of strings.
32
45
  """
33
46
  async def aembed_query(self, text: str, **kwargs: Any) -> Vector:
34
47
  """Asynchronously embed query using the `EMInvoker`.
@@ -39,6 +52,9 @@ class EMInvokerEmbeddings(BaseModel, Embeddings, arbitrary_types_allowed=True):
39
52
 
40
53
  Returns:
41
54
  Vector: Embeddings for the text.
55
+
56
+ Raises:
57
+ ValueError: If `text` is not a string.
42
58
  """
43
59
  def embed_documents(self, texts: list[str], **kwargs: Any) -> list[Vector]:
44
60
  """Embed documents using the `EMInvoker`.
@@ -49,6 +65,9 @@ class EMInvokerEmbeddings(BaseModel, Embeddings, arbitrary_types_allowed=True):
49
65
 
50
66
  Returns:
51
67
  list[Vector]: List of embeddings, one for each text.
68
+
69
+ Raises:
70
+ ValueError: If `texts` is not a list of strings.
52
71
  """
53
72
  def embed_query(self, text: str, **kwargs: Any) -> Vector:
54
73
  """Embed query using the `EMInvoker`.
@@ -59,4 +78,7 @@ class EMInvokerEmbeddings(BaseModel, Embeddings, arbitrary_types_allowed=True):
59
78
 
60
79
  Returns:
61
80
  Vector: Embeddings for the text.
81
+
82
+ Raises:
83
+ ValueError: If `text` is not a string.
62
84
  """
@@ -1,4 +1,5 @@
1
+ from gllm_inference.utils.io_utils import base64_to_bytes as base64_to_bytes
1
2
  from gllm_inference.utils.langchain import load_langchain_model as load_langchain_model, parse_model_data as parse_model_data
2
3
  from gllm_inference.utils.validation import validate_string_enum as validate_string_enum
3
4
 
4
- __all__ = ['load_langchain_model', 'parse_model_data', 'validate_string_enum']
5
+ __all__ = ['base64_to_bytes', 'load_langchain_model', 'parse_model_data', 'validate_string_enum']
@@ -0,0 +1,26 @@
1
+ from _typeshed import Incomplete
2
+
3
+ logger: Incomplete
4
+ DEFAULT_BASE64_ALLOWED_MIMETYPES: Incomplete
5
+
6
+ def base64_to_bytes(value: str, *, allowed_mimetypes: tuple[str, ...] | None = ...) -> str | bytes:
7
+ '''Decode a base64 string to bytes based on allowed MIME type.
8
+
9
+ The conversion steps are as follows:
10
+ 1. The function first attempts to decode the given string from base64.
11
+ 2. If decoding succeeds, it checks the MIME type of the decoded content.
12
+ 3. When the MIME type matches one of the allowed patterns (e.g., ``"image/*"``),
13
+ the raw bytes are returned. Otherwise, the original string is returned unchanged.
14
+
15
+ Args:
16
+ value (str): Input data to decode.
17
+ allowed_mimetypes (tuple[str, ...], optional): MIME type prefixes that are allowed
18
+ to be decoded into bytes. Defaults to ("image/*", "audio/*", "video/*").
19
+
20
+ Returns:
21
+ str | bytes: Base64-encoded string or raw bytes if MIME type is allowed;
22
+ otherwise returns original string.
23
+
24
+ Raises:
25
+ ValueError: If the input is not a string.
26
+ '''
Binary file
gllm_inference.pyi CHANGED
@@ -117,4 +117,6 @@ import pathlib
117
117
  import pathlib.Path
118
118
  import filetype
119
119
  import magic
120
+ import binascii
121
+ import fnmatch
120
122
  import importlib
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gllm-inference-binary
3
- Version: 0.5.17
3
+ Version: 0.5.18
4
4
  Summary: A library containing components related to model inferences in Gen AI applications.
5
5
  Author: Henry Wicaksono
6
6
  Author-email: henry.wicaksono@gdplabs.id
@@ -15,7 +15,7 @@ gllm_inference/em_invoker/bedrock_em_invoker.pyi,sha256=KdX1PMWPfrmFIrSbf8Y6jkDu
15
15
  gllm_inference/em_invoker/em_invoker.pyi,sha256=dgIeAIetQcBmohwYwgo1vNw7YNO_3DQCobUaabBtf7g,5043
16
16
  gllm_inference/em_invoker/google_em_invoker.pyi,sha256=oDS4dXBcLg59ePeiLTwdl09927oJNZ_ykIe0n6Ba8gU,6557
17
17
  gllm_inference/em_invoker/langchain/__init__.pyi,sha256=VYGKE5OgU0my1RlhgzkU_A7-GLGnUDDnNFuctuRwILE,148
18
- gllm_inference/em_invoker/langchain/em_invoker_embeddings.pyi,sha256=6nASLqi0FXCpqyYPl7kM3g7hAW-xS5ZwsS3GFudns98,2347
18
+ gllm_inference/em_invoker/langchain/em_invoker_embeddings.pyi,sha256=VU3-Vhb9BCDhJo8PPdWHe2rBEOCs_HMXT6ZaWwjUzZE,3304
19
19
  gllm_inference/em_invoker/langchain_em_invoker.pyi,sha256=HuQD5Do4jwqKoMMgMjgZkic2L21n2ayJewIce09bZ3M,3163
20
20
  gllm_inference/em_invoker/openai_compatible_em_invoker.pyi,sha256=GudWfL7QCAKLInMw94jTNogbyELlD9tDbrDErHB4RRI,5360
21
21
  gllm_inference/em_invoker/openai_em_invoker.pyi,sha256=vsfEmDNvwrlBhDxqsCKyMpMZbl_FaQUWHEgQc9yeo14,4656
@@ -91,12 +91,13 @@ gllm_inference/schema/token_usage.pyi,sha256=1GTQVORV0dBNmD_jix8aVaUqxMKFF04KpLP
91
91
  gllm_inference/schema/tool_call.pyi,sha256=zQaVxCnkVxOfOEhBidqohU85gb4PRwnwBiygKaunamk,389
92
92
  gllm_inference/schema/tool_result.pyi,sha256=cAG7TVtB4IWJPt8XBBbB92cuY1ZsX9M276bN9aqjcvM,276
93
93
  gllm_inference/schema/type_alias.pyi,sha256=cQRlLT5vz9YV50n9x5BmufgqUz0UByInpmAvHSv2WTY,719
94
- gllm_inference/utils/__init__.pyi,sha256=npmBmmlBv7cPHMg1hdL3S2_RelD6vk_LhCsGELhN_7s,295
94
+ gllm_inference/utils/__init__.pyi,sha256=mDJ2gLSeQzm-79Tov5-dhrMNaDqgcD1VVzDYAWvIRqA,391
95
+ gllm_inference/utils/io_utils.pyi,sha256=7kUTacHAVRYoemFUOjCH7-Qmw-YsQGd6rGYxjf_qmtw,1094
95
96
  gllm_inference/utils/langchain.pyi,sha256=VluQiHkGigDdqLUbhB6vnXiISCP5hHqV0qokYY6dC1A,1164
96
97
  gllm_inference/utils/validation.pyi,sha256=toxBtRp-VItC_X7sNi-GDd7sjibBdWMrR0q01OI2D7k,385
97
98
  gllm_inference.build/.gitignore,sha256=aEiIwOuxfzdCmLZe4oB1JsBmCUxwG8x-u-HBCV9JT8E,1
98
- gllm_inference.cpython-313-darwin.so,sha256=z2SVGeHahBPIH7z1PGOu8ZGK9YQrzgcEdvvjzRqr9cg,4152112
99
- gllm_inference.pyi,sha256=BVwSps0XHsSJ4zwbhDLQ-R5gar7s7oQD9o4FVN-Z1x0,3605
100
- gllm_inference_binary-0.5.17.dist-info/METADATA,sha256=XT6EE6ZK5-7X1bv4wjRjo93u_EvxAXd0cZKnin-Y54A,4608
101
- gllm_inference_binary-0.5.17.dist-info/WHEEL,sha256=PCOZcL_jcbAVhuFR5ylE4Mr-7HPGHAcfJk9OpuMh7RQ,107
102
- gllm_inference_binary-0.5.17.dist-info/RECORD,,
99
+ gllm_inference.cpython-313-darwin.so,sha256=KSsTBbpELj6uU0DXWlgq-KpEzG-i5rpnYNjjuNmQI-k,4190792
100
+ gllm_inference.pyi,sha256=uxl1voKdn19LurAHKEZLWbq9ryPO4UkJ1Nk1MM8IL34,3636
101
+ gllm_inference_binary-0.5.18.dist-info/METADATA,sha256=Heo4b0XS1gQgOtbWPzIYPTic4-esBmsLMJ2LO68SP3U,4608
102
+ gllm_inference_binary-0.5.18.dist-info/WHEEL,sha256=PCOZcL_jcbAVhuFR5ylE4Mr-7HPGHAcfJk9OpuMh7RQ,107
103
+ gllm_inference_binary-0.5.18.dist-info/RECORD,,