gllm-inference-binary 0.5.14__cp311-cp311-manylinux_2_31_x86_64.whl → 0.5.15__cp311-cp311-manylinux_2_31_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.
- gllm_inference/builder/build_em_invoker.pyi +16 -1
- gllm_inference/em_invoker/__init__.pyi +2 -1
- gllm_inference/em_invoker/bedrock_em_invoker.pyi +101 -0
- gllm_inference/em_invoker/schema/bedrock.pyi +20 -0
- gllm_inference.cpython-311-x86_64-linux-gnu.so +0 -0
- gllm_inference.pyi +5 -4
- {gllm_inference_binary-0.5.14.dist-info → gllm_inference_binary-0.5.15.dist-info}/METADATA +1 -1
- {gllm_inference_binary-0.5.14.dist-info → gllm_inference_binary-0.5.15.dist-info}/RECORD +9 -7
- {gllm_inference_binary-0.5.14.dist-info → gllm_inference_binary-0.5.15.dist-info}/WHEEL +0 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
from _typeshed import Incomplete
|
2
|
-
from gllm_inference.em_invoker import AzureOpenAIEMInvoker as AzureOpenAIEMInvoker, GoogleEMInvoker as GoogleEMInvoker, LangChainEMInvoker as LangChainEMInvoker, OpenAICompatibleEMInvoker as OpenAICompatibleEMInvoker, OpenAIEMInvoker as OpenAIEMInvoker, TwelveLabsEMInvoker as TwelveLabsEMInvoker, VoyageEMInvoker as VoyageEMInvoker
|
2
|
+
from gllm_inference.em_invoker import AzureOpenAIEMInvoker as AzureOpenAIEMInvoker, BedrockEMInvoker as BedrockEMInvoker, GoogleEMInvoker as GoogleEMInvoker, LangChainEMInvoker as LangChainEMInvoker, OpenAICompatibleEMInvoker as OpenAICompatibleEMInvoker, OpenAIEMInvoker as OpenAIEMInvoker, TwelveLabsEMInvoker as TwelveLabsEMInvoker, VoyageEMInvoker as VoyageEMInvoker
|
3
3
|
from gllm_inference.em_invoker.em_invoker import BaseEMInvoker as BaseEMInvoker
|
4
4
|
from gllm_inference.schema.model_id import ModelId as ModelId, ModelProvider as ModelProvider
|
5
5
|
from typing import Any
|
@@ -9,6 +9,7 @@ logger: Incomplete
|
|
9
9
|
|
10
10
|
class Key:
|
11
11
|
"""Defines valid keys in the config."""
|
12
|
+
ACCESS_KEY_ID: str
|
12
13
|
API_KEY: str
|
13
14
|
AZURE_DEPLOYMENT: str
|
14
15
|
AZURE_ENDPOINT: str
|
@@ -17,6 +18,7 @@ class Key:
|
|
17
18
|
MODEL_KWARGS: str
|
18
19
|
MODEL_NAME: str
|
19
20
|
MODEL_CLASS_PATH: str
|
21
|
+
SECRET_ACCESS_KEY: str
|
20
22
|
|
21
23
|
def build_em_invoker(model_id: str | ModelId, credentials: str | dict[str, Any] | None = None, config: dict[str, Any] | None = None) -> BaseEMInvoker:
|
22
24
|
'''Build an embedding model invoker based on the provided configurations.
|
@@ -41,6 +43,19 @@ def build_em_invoker(model_id: str | ModelId, credentials: str | dict[str, Any]
|
|
41
43
|
ValueError: If the provider is invalid.
|
42
44
|
|
43
45
|
Usage examples:
|
46
|
+
# Using Bedrock
|
47
|
+
```python
|
48
|
+
em_invoker = build_em_invoker(
|
49
|
+
model_id="bedrock/cohere.embed-english-v3",
|
50
|
+
credentials={
|
51
|
+
"access_key_id": "Abc123...",
|
52
|
+
"secret_access_key": "Xyz123...",
|
53
|
+
},
|
54
|
+
)
|
55
|
+
```
|
56
|
+
The credentials can also be provided through the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`
|
57
|
+
environment variables.
|
58
|
+
|
44
59
|
# Using Google Gen AI (via API key)
|
45
60
|
```python
|
46
61
|
em_invoker = build_em_invoker(
|
@@ -1,4 +1,5 @@
|
|
1
1
|
from gllm_inference.em_invoker.azure_openai_em_invoker import AzureOpenAIEMInvoker as AzureOpenAIEMInvoker
|
2
|
+
from gllm_inference.em_invoker.bedrock_em_invoker import BedrockEMInvoker as BedrockEMInvoker
|
2
3
|
from gllm_inference.em_invoker.google_em_invoker import GoogleEMInvoker as GoogleEMInvoker
|
3
4
|
from gllm_inference.em_invoker.langchain_em_invoker import LangChainEMInvoker as LangChainEMInvoker
|
4
5
|
from gllm_inference.em_invoker.openai_compatible_em_invoker import OpenAICompatibleEMInvoker as OpenAICompatibleEMInvoker
|
@@ -6,4 +7,4 @@ from gllm_inference.em_invoker.openai_em_invoker import OpenAIEMInvoker as OpenA
|
|
6
7
|
from gllm_inference.em_invoker.twelevelabs_em_invoker import TwelveLabsEMInvoker as TwelveLabsEMInvoker
|
7
8
|
from gllm_inference.em_invoker.voyage_em_invoker import VoyageEMInvoker as VoyageEMInvoker
|
8
9
|
|
9
|
-
__all__ = ['AzureOpenAIEMInvoker', 'GoogleEMInvoker', 'LangChainEMInvoker', 'OpenAIEMInvoker', 'OpenAICompatibleEMInvoker', 'TwelveLabsEMInvoker', 'VoyageEMInvoker']
|
10
|
+
__all__ = ['AzureOpenAIEMInvoker', 'BedrockEMInvoker', 'GoogleEMInvoker', 'LangChainEMInvoker', 'OpenAIEMInvoker', 'OpenAICompatibleEMInvoker', 'TwelveLabsEMInvoker', 'VoyageEMInvoker']
|
@@ -0,0 +1,101 @@
|
|
1
|
+
from _typeshed import Incomplete
|
2
|
+
from enum import StrEnum
|
3
|
+
from gllm_core.utils.retry import RetryConfig as RetryConfig
|
4
|
+
from gllm_inference.em_invoker.em_invoker import BaseEMInvoker as BaseEMInvoker
|
5
|
+
from gllm_inference.em_invoker.schema.bedrock import InputType as InputType, Key as Key, OutputType as OutputType
|
6
|
+
from gllm_inference.schema import ModelId as ModelId, ModelProvider as ModelProvider, Vector as Vector
|
7
|
+
from typing import Any
|
8
|
+
|
9
|
+
class ModelType(StrEnum):
|
10
|
+
"""Defines the type of the Bedrock embedding model."""
|
11
|
+
COHERE = 'cohere'
|
12
|
+
TITAN = 'titan'
|
13
|
+
|
14
|
+
SUPPORTED_ATTACHMENTS: Incomplete
|
15
|
+
|
16
|
+
class BedrockEMInvoker(BaseEMInvoker):
|
17
|
+
'''An embedding model invoker to interact with AWS Bedrock embedding models.
|
18
|
+
|
19
|
+
Attributes:
|
20
|
+
model_id (str): The model ID of the embedding model.
|
21
|
+
model_provider (str): The provider of the embedding model.
|
22
|
+
model_name (str): The name of the embedding model.
|
23
|
+
session (Session): The Bedrock client session.
|
24
|
+
client_kwargs (dict[str, Any]): The Bedrock client kwargs.
|
25
|
+
default_hyperparameters (dict[str, Any]): Default hyperparameters for invoking the embedding model.
|
26
|
+
retry_config (RetryConfig): The retry configuration for the embedding model.
|
27
|
+
|
28
|
+
Input types:
|
29
|
+
The `BedrockEMInvoker` only supports text inputs.
|
30
|
+
|
31
|
+
Output format:
|
32
|
+
The `BedrockEMInvoker` can embed either:
|
33
|
+
1. A single content.
|
34
|
+
1. A single content is a single text.
|
35
|
+
2. The output will be a `Vector`, representing the embedding of the content.
|
36
|
+
|
37
|
+
# Example 1: Embedding a text content.
|
38
|
+
```python
|
39
|
+
text = "This is a text"
|
40
|
+
result = await em_invoker.invoke(text)
|
41
|
+
```
|
42
|
+
|
43
|
+
The above examples will return a `Vector` with a size of (embedding_size,).
|
44
|
+
|
45
|
+
2. A list of contents.
|
46
|
+
1. A list of contents is a list of texts.
|
47
|
+
2. The output will be a `list[Vector]`, where each element is a `Vector` representing the
|
48
|
+
embedding of each single content.
|
49
|
+
|
50
|
+
# Example: Embedding a list of contents.
|
51
|
+
```python
|
52
|
+
text1 = "This is a text"
|
53
|
+
text2 = "This is another text"
|
54
|
+
text3 = "This is yet another text"
|
55
|
+
result = await em_invoker.invoke([text1, text2, text3])
|
56
|
+
```
|
57
|
+
|
58
|
+
The above examples will return a `list[Vector]` with a size of (3, embedding_size).
|
59
|
+
|
60
|
+
Retry and timeout:
|
61
|
+
The `BedrockEMInvoker` supports retry and timeout configuration.
|
62
|
+
By default, the max retries is set to 0 and the timeout is set to 30.0 seconds.
|
63
|
+
They can be customized by providing a custom `RetryConfig` object to the `retry_config` parameter.
|
64
|
+
|
65
|
+
Retry config examples:
|
66
|
+
```python
|
67
|
+
retry_config = RetryConfig(max_retries=0, timeout=0.0) # No retry, no timeout
|
68
|
+
retry_config = RetryConfig(max_retries=0, timeout=10.0) # No retry, 10.0 seconds timeout
|
69
|
+
retry_config = RetryConfig(max_retries=5, timeout=0.0) # 5 max retries, no timeout
|
70
|
+
retry_config = RetryConfig(max_retries=5, timeout=10.0) # 5 max retries, 10.0 seconds timeout
|
71
|
+
```
|
72
|
+
|
73
|
+
Usage example:
|
74
|
+
```python
|
75
|
+
em_invoker = BedrockEMInvoker(..., retry_config=retry_config)
|
76
|
+
```
|
77
|
+
'''
|
78
|
+
session: Incomplete
|
79
|
+
client_kwargs: Incomplete
|
80
|
+
def __init__(self, model_name: str, access_key_id: str | None = None, secret_access_key: str | None = None, region_name: str = 'us-east-1', model_kwargs: dict[str, Any] | None = None, default_hyperparameters: dict[str, Any] | None = None, retry_config: RetryConfig | None = None) -> None:
|
81
|
+
'''Initializes a new instance of the BedrockEMInvoker class.
|
82
|
+
|
83
|
+
Args:
|
84
|
+
model_name (str): The name of the Bedrock embedding model to be used.
|
85
|
+
access_key_id (str | None, optional): The AWS access key ID. Defaults to None, in which case
|
86
|
+
the `AWS_ACCESS_KEY_ID` environment variable will be used.
|
87
|
+
secret_access_key (str | None, optional): The AWS secret access key. Defaults to None, in which case
|
88
|
+
the `AWS_SECRET_ACCESS_KEY` environment variable will be used.
|
89
|
+
region_name (str, optional): The AWS region name. Defaults to "us-east-1".
|
90
|
+
model_kwargs (dict[str, Any] | None, optional): Additional keyword arguments for the Bedrock client.
|
91
|
+
Defaults to None.
|
92
|
+
default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the model.
|
93
|
+
Defaults to None.
|
94
|
+
retry_config (RetryConfig | None, optional): The retry configuration for the embedding model.
|
95
|
+
Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used.
|
96
|
+
|
97
|
+
Raises:
|
98
|
+
ValueError: If the model name is not supported.
|
99
|
+
ValueError: If `access_key_id` or `secret_access_key` is neither provided nor set in the
|
100
|
+
`AWS_ACCESS_KEY_ID` or `AWS_SECRET_ACCESS_KEY` environment variables, respectively.
|
101
|
+
'''
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Key:
|
2
|
+
"""Defines valid keys in Bedrock."""
|
3
|
+
ACCEPT: str
|
4
|
+
CONTENT_TYPE: str
|
5
|
+
INPUT_TEXT: str
|
6
|
+
INPUT_TYPE: str
|
7
|
+
MODEL_ID: str
|
8
|
+
TEXTS: str
|
9
|
+
|
10
|
+
class InputType:
|
11
|
+
"""Defines valid input types in Bedrock."""
|
12
|
+
APPLICATION_JSON: str
|
13
|
+
SEARCH_DOCUMENT: str
|
14
|
+
SEARCH_QUERY: str
|
15
|
+
|
16
|
+
class OutputType:
|
17
|
+
"""Defines valid output types in Bedrock."""
|
18
|
+
BODY: str
|
19
|
+
EMBEDDING: str
|
20
|
+
EMBEDDINGS: str
|
Binary file
|
gllm_inference.pyi
CHANGED
@@ -13,6 +13,7 @@ import typing
|
|
13
13
|
import gllm_core
|
14
14
|
import gllm_core.utils
|
15
15
|
import gllm_inference.em_invoker.AzureOpenAIEMInvoker
|
16
|
+
import gllm_inference.em_invoker.BedrockEMInvoker
|
16
17
|
import gllm_inference.em_invoker.GoogleEMInvoker
|
17
18
|
import gllm_inference.em_invoker.LangChainEMInvoker
|
18
19
|
import gllm_inference.em_invoker.OpenAICompatibleEMInvoker
|
@@ -42,16 +43,18 @@ import gllm_core.utils.imports
|
|
42
43
|
import gllm_inference.schema.ModelId
|
43
44
|
import gllm_inference.schema.ModelProvider
|
44
45
|
import openai
|
46
|
+
import asyncio
|
47
|
+
import enum
|
48
|
+
import gllm_inference.schema.Vector
|
49
|
+
import aioboto3
|
45
50
|
import gllm_inference.exceptions.parse_error_message
|
46
51
|
import gllm_inference.schema.Attachment
|
47
52
|
import gllm_inference.schema.AttachmentType
|
48
53
|
import gllm_inference.schema.EMContent
|
49
|
-
import gllm_inference.schema.Vector
|
50
54
|
import google
|
51
55
|
import google.auth
|
52
56
|
import google.genai
|
53
57
|
import google.genai.types
|
54
|
-
import asyncio
|
55
58
|
import concurrent
|
56
59
|
import concurrent.futures
|
57
60
|
import concurrent.futures.ThreadPoolExecutor
|
@@ -68,7 +71,6 @@ import voyageai
|
|
68
71
|
import voyageai.client_async
|
69
72
|
import asyncio.CancelledError
|
70
73
|
import asyncio.TimeoutError
|
71
|
-
import enum
|
72
74
|
import http
|
73
75
|
import http.HTTPStatus
|
74
76
|
import aiohttp
|
@@ -88,7 +90,6 @@ import gllm_inference.schema.TokenUsage
|
|
88
90
|
import gllm_inference.schema.ToolCall
|
89
91
|
import gllm_inference.schema.ToolResult
|
90
92
|
import anthropic
|
91
|
-
import aioboto3
|
92
93
|
import gllm_inference.schema.MessageRole
|
93
94
|
import langchain_core.language_models
|
94
95
|
import langchain_core.messages
|
@@ -1,6 +1,6 @@
|
|
1
1
|
gllm_inference/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
gllm_inference/builder/__init__.pyi,sha256=usz2lvfwO4Yk-ZGKXbCWG1cEr3nlQXxMNDNC-2yc1NM,500
|
3
|
-
gllm_inference/builder/build_em_invoker.pyi,sha256=
|
3
|
+
gllm_inference/builder/build_em_invoker.pyi,sha256=7JTt8XpfqLQdv5cltIyi1r6Sf8MAUKgornHn5z57raA,5873
|
4
4
|
gllm_inference/builder/build_lm_invoker.pyi,sha256=igJdLnWiY5QcdT4EClvgxFGSVZjARpq5hz2FYcBHWEQ,6876
|
5
5
|
gllm_inference/builder/build_lm_request_processor.pyi,sha256=33Gi3onftl-V2e_mkJios5zmXRKSoAVPX3UK7YBExjk,4491
|
6
6
|
gllm_inference/builder/build_output_parser.pyi,sha256=_Lrq-bh1oPsb_Nwkkr_zyEUwIOMysRFZkvEtEM29LZM,936
|
@@ -9,8 +9,9 @@ gllm_inference/catalog/catalog.pyi,sha256=a4RNG1lKv51GxQpOqh47tz-PAROMPaeP2o5XNL
|
|
9
9
|
gllm_inference/catalog/lm_request_processor_catalog.pyi,sha256=ranHMbG9--DZj9FJRhIUa6U8e-L-Tm-_hSBpzJ6DDs4,5428
|
10
10
|
gllm_inference/catalog/prompt_builder_catalog.pyi,sha256=OU8k_4HbqjZEzHZlzSM3uzGQZJmM2uGD76Csqom0CEQ,3197
|
11
11
|
gllm_inference/constants.pyi,sha256=KDzHmjVYjd0uTHqLgIzgHhLZx99D8jGBIg74eO8KQv0,314
|
12
|
-
gllm_inference/em_invoker/__init__.pyi,sha256=
|
12
|
+
gllm_inference/em_invoker/__init__.pyi,sha256=83QVCkMjS2-jMKdAvmZska4LuJ-un755lAxjuVSLZ9o,987
|
13
13
|
gllm_inference/em_invoker/azure_openai_em_invoker.pyi,sha256=OEkVu5nv92ITqdhDtgDg4MiLSDRWDmLSnAhYtXpCn6E,4602
|
14
|
+
gllm_inference/em_invoker/bedrock_em_invoker.pyi,sha256=CI469UX5YyPxgFokCA-Y9xw-x1wkI0Moa6bailME3kU,5075
|
14
15
|
gllm_inference/em_invoker/em_invoker.pyi,sha256=hiH8FB5R-KxhI8Ds2htF3cjRcIcH92yHPcOdpgc4FDo,4341
|
15
16
|
gllm_inference/em_invoker/google_em_invoker.pyi,sha256=vj0KAX5b2rhvqqbpjFZYLmk84RHuNw0pXkhx3bbHmM4,6182
|
16
17
|
gllm_inference/em_invoker/langchain/__init__.pyi,sha256=VYGKE5OgU0my1RlhgzkU_A7-GLGnUDDnNFuctuRwILE,148
|
@@ -19,6 +20,7 @@ gllm_inference/em_invoker/langchain_em_invoker.pyi,sha256=lXiTTGcNOIwurZx3_6vWLE
|
|
19
20
|
gllm_inference/em_invoker/openai_compatible_em_invoker.pyi,sha256=Qz2Qx1KRKhzXr8IseDWcF_6yC-SNtfsXvQuGuKnqVe8,4978
|
20
21
|
gllm_inference/em_invoker/openai_em_invoker.pyi,sha256=SFuS2DsvMHcibxFnpQOOchlZUyNRRlI2uMhVEUfifas,4235
|
21
22
|
gllm_inference/em_invoker/schema/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
23
|
+
gllm_inference/em_invoker/schema/bedrock.pyi,sha256=sqPHG0jBc09K4V1aSpybqhqIdYfZQTB2VD_nJ9j_ttQ,423
|
22
24
|
gllm_inference/em_invoker/schema/google.pyi,sha256=MUmgtjMmjSpzmzaAOx6JGZbcdRxgMUhOpvcVQIo-oGs,146
|
23
25
|
gllm_inference/em_invoker/schema/langchain.pyi,sha256=onpZutqa2xw2g8rdJTdycy3ub58lkPBVB3KvVVPpyds,92
|
24
26
|
gllm_inference/em_invoker/schema/openai.pyi,sha256=Q_dsEcodkOXYXPdrkOkW0LnuLhfeq8tEbtZAGMz2ajA,139
|
@@ -92,8 +94,8 @@ gllm_inference/utils/__init__.pyi,sha256=npmBmmlBv7cPHMg1hdL3S2_RelD6vk_LhCsGELh
|
|
92
94
|
gllm_inference/utils/langchain.pyi,sha256=VluQiHkGigDdqLUbhB6vnXiISCP5hHqV0qokYY6dC1A,1164
|
93
95
|
gllm_inference/utils/validation.pyi,sha256=toxBtRp-VItC_X7sNi-GDd7sjibBdWMrR0q01OI2D7k,385
|
94
96
|
gllm_inference.build/.gitignore,sha256=aEiIwOuxfzdCmLZe4oB1JsBmCUxwG8x-u-HBCV9JT8E,1
|
95
|
-
gllm_inference.cpython-311-x86_64-linux-gnu.so,sha256=
|
96
|
-
gllm_inference.pyi,sha256=
|
97
|
-
gllm_inference_binary-0.5.
|
98
|
-
gllm_inference_binary-0.5.
|
99
|
-
gllm_inference_binary-0.5.
|
97
|
+
gllm_inference.cpython-311-x86_64-linux-gnu.so,sha256=NO94MCu0SWvYhzGikJnCRUCjPW0cMuZnnP5aYHMsgCY,4076704
|
98
|
+
gllm_inference.pyi,sha256=YGR7XxIbifZDVu3Ghk4SlqF8mb2UPWoR7pEXwJEloik,3570
|
99
|
+
gllm_inference_binary-0.5.15.dist-info/METADATA,sha256=XkQGzgIhVc0VbsLTeDbn4Q1uVo8V1L_47CZC4kjNgyo,4608
|
100
|
+
gllm_inference_binary-0.5.15.dist-info/WHEEL,sha256=IFe_ZNdNTT_i6vUiBlaFC_vwJqKup8CcDJ489_L8YrY,110
|
101
|
+
gllm_inference_binary-0.5.15.dist-info/RECORD,,
|
File without changes
|