gllm-inference-binary 0.5.41__cp312-cp312-win_amd64.whl → 0.5.43__cp312-cp312-win_amd64.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.
- gllm_inference/builder/build_em_invoker.pyi +13 -2
- gllm_inference/constants.pyi +4 -2
- gllm_inference/em_invoker/__init__.pyi +3 -1
- gllm_inference/em_invoker/cohere_em_invoker.pyi +128 -0
- gllm_inference/em_invoker/jina_em_invoker.pyi +103 -0
- gllm_inference/em_invoker/schema/cohere.pyi +20 -0
- gllm_inference/em_invoker/schema/jina.pyi +28 -0
- gllm_inference/exceptions/provider_error_map.pyi +1 -0
- gllm_inference/schema/model_id.pyi +15 -0
- gllm_inference.cp312-win_amd64.pyd +0 -0
- gllm_inference.pyi +9 -5
- {gllm_inference_binary-0.5.41.dist-info → gllm_inference_binary-0.5.43.dist-info}/METADATA +3 -1
- {gllm_inference_binary-0.5.41.dist-info → gllm_inference_binary-0.5.43.dist-info}/RECORD +15 -11
- {gllm_inference_binary-0.5.41.dist-info → gllm_inference_binary-0.5.43.dist-info}/WHEEL +0 -0
- {gllm_inference_binary-0.5.41.dist-info → gllm_inference_binary-0.5.43.dist-info}/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from _typeshed import Incomplete
|
|
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
|
|
2
|
+
from gllm_inference.em_invoker import AzureOpenAIEMInvoker as AzureOpenAIEMInvoker, BedrockEMInvoker as BedrockEMInvoker, CohereEMInvoker as CohereEMInvoker, GoogleEMInvoker as GoogleEMInvoker, JinaEMInvoker as JinaEMInvoker, 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
|
-
from gllm_inference.schema.model_id import ModelId as ModelId, ModelProvider as ModelProvider
|
|
4
|
+
from gllm_inference.schema.model_id import ModelId as ModelId, ModelProvider as ModelProvider, OPTIONAL_PATH_PROVIDERS as OPTIONAL_PATH_PROVIDERS
|
|
5
5
|
from typing import Any
|
|
6
6
|
|
|
7
7
|
PROVIDER_TO_EM_INVOKER_MAP: dict[str, type[BaseEMInvoker]]
|
|
@@ -71,6 +71,16 @@ def build_em_invoker(model_id: str | ModelId, credentials: str | dict[str, Any]
|
|
|
71
71
|
```
|
|
72
72
|
Providing credentials through environment variable is not supported for Google Vertex AI.
|
|
73
73
|
|
|
74
|
+
# Using Jina
|
|
75
|
+
```python
|
|
76
|
+
em_invoker = build_em_invoker(
|
|
77
|
+
model_id="jina/jina-embeddings-v2-large",
|
|
78
|
+
credentials="jina-api-key"
|
|
79
|
+
)
|
|
80
|
+
```
|
|
81
|
+
The credentials can also be provided through the `JINA_API_KEY` environment variable. For the list of supported
|
|
82
|
+
models, please refer to the following page: https://jina.ai/models
|
|
83
|
+
|
|
74
84
|
# Using OpenAI
|
|
75
85
|
```python
|
|
76
86
|
em_invoker = build_em_invoker(
|
|
@@ -128,6 +138,7 @@ def build_em_invoker(model_id: str | ModelId, credentials: str | dict[str, Any]
|
|
|
128
138
|
variables credentials, please refer to the following page:
|
|
129
139
|
https://python.langchain.com/docs/integrations/text_embedding/
|
|
130
140
|
|
|
141
|
+
|
|
131
142
|
Security warning:
|
|
132
143
|
Please provide the EM invoker credentials ONLY to the `credentials` parameter. Do not put any kind of
|
|
133
144
|
credentials in the `config` parameter as the content of the `config` parameter will be logged.
|
gllm_inference/constants.pyi
CHANGED
|
@@ -2,10 +2,12 @@ from _typeshed import Incomplete
|
|
|
2
2
|
|
|
3
3
|
AZURE_OPENAI_URL_SUFFIX: str
|
|
4
4
|
DOCUMENT_MIME_TYPES: Incomplete
|
|
5
|
+
EMBEDDING_ENDPOINT: str
|
|
5
6
|
GOOGLE_SCOPES: Incomplete
|
|
6
7
|
GRPC_ENABLE_RETRIES_KEY: str
|
|
7
|
-
INVOKER_PROPAGATED_MAX_RETRIES: int
|
|
8
|
-
INVOKER_DEFAULT_TIMEOUT: float
|
|
9
8
|
HEX_REPR_LENGTH: int
|
|
9
|
+
INVOKER_DEFAULT_TIMEOUT: float
|
|
10
|
+
INVOKER_PROPAGATED_MAX_RETRIES: int
|
|
11
|
+
JINA_DEFAULT_URL: str
|
|
10
12
|
OPENAI_DEFAULT_URL: str
|
|
11
13
|
SECONDS_TO_MILLISECONDS: int
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
from gllm_inference.em_invoker.azure_openai_em_invoker import AzureOpenAIEMInvoker as AzureOpenAIEMInvoker
|
|
2
2
|
from gllm_inference.em_invoker.bedrock_em_invoker import BedrockEMInvoker as BedrockEMInvoker
|
|
3
|
+
from gllm_inference.em_invoker.cohere_em_invoker import CohereEMInvoker as CohereEMInvoker
|
|
3
4
|
from gllm_inference.em_invoker.google_em_invoker import GoogleEMInvoker as GoogleEMInvoker
|
|
5
|
+
from gllm_inference.em_invoker.jina_em_invoker import JinaEMInvoker as JinaEMInvoker
|
|
4
6
|
from gllm_inference.em_invoker.langchain_em_invoker import LangChainEMInvoker as LangChainEMInvoker
|
|
5
7
|
from gllm_inference.em_invoker.openai_compatible_em_invoker import OpenAICompatibleEMInvoker as OpenAICompatibleEMInvoker
|
|
6
8
|
from gllm_inference.em_invoker.openai_em_invoker import OpenAIEMInvoker as OpenAIEMInvoker
|
|
7
9
|
from gllm_inference.em_invoker.twelevelabs_em_invoker import TwelveLabsEMInvoker as TwelveLabsEMInvoker
|
|
8
10
|
from gllm_inference.em_invoker.voyage_em_invoker import VoyageEMInvoker as VoyageEMInvoker
|
|
9
11
|
|
|
10
|
-
__all__ = ['AzureOpenAIEMInvoker', 'BedrockEMInvoker', 'GoogleEMInvoker', 'LangChainEMInvoker', 'OpenAIEMInvoker', 'OpenAICompatibleEMInvoker', 'TwelveLabsEMInvoker', 'VoyageEMInvoker']
|
|
12
|
+
__all__ = ['AzureOpenAIEMInvoker', 'BedrockEMInvoker', 'CohereEMInvoker', 'GoogleEMInvoker', 'JinaEMInvoker', 'LangChainEMInvoker', 'OpenAIEMInvoker', 'OpenAICompatibleEMInvoker', 'TwelveLabsEMInvoker', 'VoyageEMInvoker']
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
from _typeshed import Incomplete
|
|
2
|
+
from gllm_core.utils.retry import RetryConfig as RetryConfig
|
|
3
|
+
from gllm_inference.em_invoker.em_invoker import BaseEMInvoker as BaseEMInvoker
|
|
4
|
+
from gllm_inference.em_invoker.schema.cohere import CohereInputType as CohereInputType, Key as Key
|
|
5
|
+
from gllm_inference.schema import Attachment as Attachment, AttachmentType as AttachmentType, EMContent as EMContent, ModelId as ModelId, ModelProvider as ModelProvider, TruncationConfig as TruncationConfig, Vector as Vector
|
|
6
|
+
from gllm_inference.utils import validate_string_enum as validate_string_enum
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
SUPPORTED_ATTACHMENTS: Incomplete
|
|
10
|
+
MULTIMODAL_MODEL_VERSION: Incomplete
|
|
11
|
+
|
|
12
|
+
class CohereEMInvoker(BaseEMInvoker):
|
|
13
|
+
'''An embedding model invoker to interact with Cohere embedding models.
|
|
14
|
+
|
|
15
|
+
Attributes:
|
|
16
|
+
model_id (str): The model ID of the embedding model.
|
|
17
|
+
model_provider (str): The provider of the embedding model (Cohere).
|
|
18
|
+
model_name (str): The name of the Cohere embedding model.
|
|
19
|
+
client (AsyncClient): The asynchronous client for the Cohere API.
|
|
20
|
+
default_hyperparameters (dict[str, Any]): Default hyperparameters for invoking the embedding model.
|
|
21
|
+
retry_config (RetryConfig): The retry configuration for the embedding model.
|
|
22
|
+
truncation_config (TruncationConfig | None): The truncation configuration for the embedding model.
|
|
23
|
+
input_type (CohereInputType): The input type for the embedding model. Supported values include:
|
|
24
|
+
1. `CohereInputType.SEARCH_DOCUMENT`,
|
|
25
|
+
2. `CohereInputType.SEARCH_QUERY`,
|
|
26
|
+
3. `CohereInputType.CLASSIFICATION`,
|
|
27
|
+
4. `CohereInputType.CLUSTERING`,
|
|
28
|
+
5. `CohereInputType.IMAGE`.
|
|
29
|
+
|
|
30
|
+
Initialization:
|
|
31
|
+
You can initialize the `CohereEMInvoker` as follows:
|
|
32
|
+
```python
|
|
33
|
+
em_invoker = CohereEMInvoker(
|
|
34
|
+
model_name="embed-english-v4.0",
|
|
35
|
+
input_type="search_document"
|
|
36
|
+
)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Note: The `input_type` parameter can be one of the following:
|
|
40
|
+
1. "search_document"
|
|
41
|
+
2. "search_query"
|
|
42
|
+
3. "classification"
|
|
43
|
+
4. "clustering"
|
|
44
|
+
5. "image"
|
|
45
|
+
|
|
46
|
+
This parameter is optional and defaults to "search_document". For more information about
|
|
47
|
+
input_type, please refer to https://docs.cohere.com/docs/embeddings#the-input_type-parameter.
|
|
48
|
+
|
|
49
|
+
Input types:
|
|
50
|
+
The `CohereEMInvoker` supports the following input types: text and image.
|
|
51
|
+
Non-text inputs must be passed as an `Attachment` object.
|
|
52
|
+
|
|
53
|
+
Output format:
|
|
54
|
+
The `CohereEMInvoker` can embed either:
|
|
55
|
+
1. A single content.
|
|
56
|
+
1. A single content is either a text or an image.
|
|
57
|
+
2. The output will be a `Vector`, representing the embedding of the content.
|
|
58
|
+
|
|
59
|
+
# Example 1: Embedding a text content.
|
|
60
|
+
```python
|
|
61
|
+
text = "What animal is in this image?"
|
|
62
|
+
result = await em_invoker.invoke(text)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
# Example 2: Embedding an image content.
|
|
66
|
+
```python
|
|
67
|
+
image = Attachment.from_path("path/to/local/image.png")
|
|
68
|
+
result = await em_invoker.invoke(image)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The above examples will return a `Vector` with a size of (embedding_size,).
|
|
72
|
+
|
|
73
|
+
2. A list of contents.
|
|
74
|
+
1. A list of contents is a list that consists of any of the above single contents.
|
|
75
|
+
2. The output will be a `list[Vector]`, where each element is a `Vector` representing the
|
|
76
|
+
embedding of each single content.
|
|
77
|
+
|
|
78
|
+
# Example: Embedding a list of contents.
|
|
79
|
+
```python
|
|
80
|
+
text = "What animal is in this image?"
|
|
81
|
+
image = Attachment.from_path("path/to/local/image.png")
|
|
82
|
+
result = await em_invoker.invoke([text, image])
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The above examples will return a `list[Vector]` with a size of (2, embedding_size).
|
|
86
|
+
|
|
87
|
+
Retry and timeout:
|
|
88
|
+
The `CohereEMInvoker` supports retry and timeout configuration.
|
|
89
|
+
By default, the max retries is set to 0 and the timeout is set to 30.0 seconds.
|
|
90
|
+
They can be customized by providing a custom `RetryConfig` object to the `retry_config` parameter.
|
|
91
|
+
|
|
92
|
+
Retry config examples:
|
|
93
|
+
```python
|
|
94
|
+
retry_config = RetryConfig(max_retries=0, timeout=None) # No retry, no timeout
|
|
95
|
+
retry_config = RetryConfig(max_retries=0, timeout=10.0) # No retry, 10.0 seconds timeout
|
|
96
|
+
retry_config = RetryConfig(max_retries=5, timeout=None) # 5 max retries, no timeout
|
|
97
|
+
retry_config = RetryConfig(max_retries=5, timeout=10.0) # 5 max retries, 10.0 seconds timeout
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Usage example:
|
|
101
|
+
```python
|
|
102
|
+
em_invoker = CohereEMInvoker(..., retry_config=retry_config)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
'''
|
|
106
|
+
input_type: Incomplete
|
|
107
|
+
client: Incomplete
|
|
108
|
+
def __init__(self, model_name: str, api_key: str | None = None, base_url: str | None = None, model_kwargs: dict[str, Any] | None = None, default_hyperparameters: dict[str, Any] | None = None, retry_config: RetryConfig | None = None, truncation_config: TruncationConfig | None = None, input_type: CohereInputType = ...) -> None:
|
|
109
|
+
'''Initializes a new instance of the CohereEMInvoker class.
|
|
110
|
+
|
|
111
|
+
Args:
|
|
112
|
+
model_name (str): The name of the Cohere embedding model to be used.
|
|
113
|
+
api_key (str | None, optional): The API key for authenticating with Cohere. Defaults to None, in which
|
|
114
|
+
case the `COHERE_API_KEY` environment variable will be used.
|
|
115
|
+
base_url (str | None, optional): The base URL for a custom Cohere-compatible endpoint.
|
|
116
|
+
Defaults to None, in which case Cohere\'s default URL will be used.
|
|
117
|
+
model_kwargs (dict[str, Any] | None, optional): Additional keyword arguments for the Cohere client.
|
|
118
|
+
Defaults to None.
|
|
119
|
+
default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the model.
|
|
120
|
+
Defaults to None.
|
|
121
|
+
retry_config (RetryConfig | None, optional): The retry configuration for the embedding model.
|
|
122
|
+
Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used.
|
|
123
|
+
truncation_config (TruncationConfig | None, optional): Configuration for text truncation behavior.
|
|
124
|
+
Defaults to None, in which case no truncation is applied.
|
|
125
|
+
input_type (CohereInputType, optional): The input type for the embedding model.
|
|
126
|
+
Defaults to `CohereInputType.SEARCH_DOCUMENT`. Valid values are: "search_document", "search_query",
|
|
127
|
+
"classification", "clustering", and "image".
|
|
128
|
+
'''
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
from _typeshed import Incomplete
|
|
2
|
+
from gllm_core.utils.retry import RetryConfig as RetryConfig
|
|
3
|
+
from gllm_inference.constants import EMBEDDING_ENDPOINT as EMBEDDING_ENDPOINT, JINA_DEFAULT_URL as JINA_DEFAULT_URL
|
|
4
|
+
from gllm_inference.em_invoker.em_invoker import BaseEMInvoker as BaseEMInvoker
|
|
5
|
+
from gllm_inference.em_invoker.schema.jina import InputType as InputType, Key as Key
|
|
6
|
+
from gllm_inference.exceptions import BaseInvokerError as BaseInvokerError, ProviderInternalError as ProviderInternalError
|
|
7
|
+
from gllm_inference.exceptions.error_parser import convert_http_status_to_base_invoker_error as convert_http_status_to_base_invoker_error
|
|
8
|
+
from gllm_inference.schema import Attachment as Attachment, AttachmentType as AttachmentType, EMContent as EMContent, ModelId as ModelId, ModelProvider as ModelProvider, TruncationConfig as TruncationConfig, Vector as Vector
|
|
9
|
+
from typing import Any
|
|
10
|
+
|
|
11
|
+
SUPPORTED_ATTACHMENTS: Incomplete
|
|
12
|
+
MULTIMODAL_MODELS: Incomplete
|
|
13
|
+
|
|
14
|
+
class JinaEMInvoker(BaseEMInvoker):
|
|
15
|
+
'''An embedding model invoker to interact with Jina AI embedding models.
|
|
16
|
+
|
|
17
|
+
Attributes:
|
|
18
|
+
model_id (str): The model ID of the embedding model.
|
|
19
|
+
model_provider (str): The provider of the embedding model.
|
|
20
|
+
model_name (str): The name of the embedding model.
|
|
21
|
+
client (AsyncClient): The client for the Jina AI API.
|
|
22
|
+
default_hyperparameters (dict[str, Any]): Default hyperparameters for invoking the embedding model.
|
|
23
|
+
retry_config (RetryConfig): The retry configuration for the embedding model.
|
|
24
|
+
truncation_config (TruncationConfig | None): The truncation configuration for the embedding model.
|
|
25
|
+
|
|
26
|
+
Input types:
|
|
27
|
+
The `JinaEMInvoker` supports the following input types: text and image.
|
|
28
|
+
Non-text inputs must be passed as a `Attachment` object.
|
|
29
|
+
|
|
30
|
+
Output format:
|
|
31
|
+
The `JinaEMInvoker` can embed either:
|
|
32
|
+
1. A single content.
|
|
33
|
+
1. A single content is either a text or an image.
|
|
34
|
+
2. The output will be a `Vector`, representing the embedding of the content.
|
|
35
|
+
|
|
36
|
+
# Example 1: Embedding a text content.
|
|
37
|
+
```python
|
|
38
|
+
text = "What animal is in this image?"
|
|
39
|
+
result = await em_invoker.invoke(text)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
# Example 2: Embedding an image content.
|
|
43
|
+
```python
|
|
44
|
+
image = Attachment.from_path("path/to/local/image.png")
|
|
45
|
+
result = await em_invoker.invoke(image)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The above examples will return a `Vector` with a size of (embedding_size,).
|
|
49
|
+
|
|
50
|
+
2. A list of contents.
|
|
51
|
+
1. A list of contents is a list that consists of any of the above single contents.
|
|
52
|
+
2. The output will be a `list[Vector]`, where each element is a `Vector` representing the
|
|
53
|
+
embedding of each single content.
|
|
54
|
+
|
|
55
|
+
# Example: Embedding a list of contents.
|
|
56
|
+
```python
|
|
57
|
+
text = "What animal is in this image?"
|
|
58
|
+
image = Attachment.from_path("path/to/local/image.png")
|
|
59
|
+
result = await em_invoker.invoke([text, image])
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The above examples will return a `list[Vector]` with a size of (2, embedding_size).
|
|
63
|
+
|
|
64
|
+
Retry and timeout:
|
|
65
|
+
The `JinaEMInvoker` supports retry and timeout configuration.
|
|
66
|
+
By default, the max retries is set to 0 and the timeout is set to 30.0 seconds.
|
|
67
|
+
They can be customized by providing a custom `RetryConfig` object to the `retry_config` parameter.
|
|
68
|
+
|
|
69
|
+
Retry config examples:
|
|
70
|
+
```python
|
|
71
|
+
retry_config = RetryConfig(max_retries=0, timeout=None) # No retry, no timeout
|
|
72
|
+
retry_config = RetryConfig(max_retries=0, timeout=10.0) # No retry, 10.0 seconds timeout
|
|
73
|
+
retry_config = RetryConfig(max_retries=5, timeout=None) # 5 max retries, no timeout
|
|
74
|
+
retry_config = RetryConfig(max_retries=5, timeout=10.0) # 5 max retries, 10.0 seconds timeout
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Usage example:
|
|
78
|
+
```python
|
|
79
|
+
em_invoker = JinaEMInvoker(..., retry_config=retry_config)
|
|
80
|
+
```
|
|
81
|
+
'''
|
|
82
|
+
client: Incomplete
|
|
83
|
+
model_kwargs: Incomplete
|
|
84
|
+
def __init__(self, model_name: str, api_key: str | None = None, base_url: str = ..., model_kwargs: dict[str, Any] | None = None, default_hyperparameters: dict[str, Any] | None = None, retry_config: RetryConfig | None = None, truncation_config: TruncationConfig | None = None) -> None:
|
|
85
|
+
'''Initializes a new instance of the JinaEMInvoker class.
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
model_name (str): The name of the Jina embedding model to be used.
|
|
89
|
+
api_key (str | None, optional): The API key for authenticating with Jina AI.
|
|
90
|
+
Defaults to None, in which case the `JINA_API_KEY` environment variable will be used.
|
|
91
|
+
base_url (str, optional): The base URL for the Jina AI API. Defaults to "https://api.jina.ai/v1".
|
|
92
|
+
model_kwargs (dict[str, Any] | None, optional): Additional keyword arguments for the HTTP client.
|
|
93
|
+
Defaults to None.
|
|
94
|
+
default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the model.
|
|
95
|
+
Defaults to None.
|
|
96
|
+
retry_config (RetryConfig | None, optional): The retry configuration for the embedding model.
|
|
97
|
+
Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used.
|
|
98
|
+
truncation_config (TruncationConfig | None, optional): Configuration for text truncation behavior.
|
|
99
|
+
Defaults to None, in which case no truncation is applied.
|
|
100
|
+
|
|
101
|
+
Raises:
|
|
102
|
+
ValueError: If neither `api_key` nor `JINA_API_KEY` environment variable is provided.
|
|
103
|
+
'''
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
|
|
3
|
+
class Key(StrEnum):
|
|
4
|
+
"""Defines valid keys in Cohere."""
|
|
5
|
+
BASE_URL = 'base_url'
|
|
6
|
+
IMAGE_URL = 'image_url'
|
|
7
|
+
INPUT_TYPE = 'input_type'
|
|
8
|
+
MAX_RETRIES = 'max_retries'
|
|
9
|
+
MODEL = 'model'
|
|
10
|
+
TIMEOUT = 'timeout'
|
|
11
|
+
TYPE = 'type'
|
|
12
|
+
URL = 'url'
|
|
13
|
+
|
|
14
|
+
class CohereInputType(StrEnum):
|
|
15
|
+
"""Defines valid embedding input types for Cohere embedding API."""
|
|
16
|
+
CLASSIFICATION = 'classification'
|
|
17
|
+
CLUSTERING = 'clustering'
|
|
18
|
+
IMAGE = 'image'
|
|
19
|
+
SEARCH_DOCUMENT = 'search_document'
|
|
20
|
+
SEARCH_QUERY = 'search_query'
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
|
|
3
|
+
class InputType(StrEnum):
|
|
4
|
+
"""Defines the supported input types for the Jina AI embedding API."""
|
|
5
|
+
IMAGE_URL = 'image_url'
|
|
6
|
+
TEXT = 'text'
|
|
7
|
+
|
|
8
|
+
class Key(StrEnum):
|
|
9
|
+
"""Defines key constants used in the Jina AI API payloads."""
|
|
10
|
+
DATA = 'data'
|
|
11
|
+
EMBEDDING = 'embedding'
|
|
12
|
+
ERROR = 'error'
|
|
13
|
+
IMAGE_URL = 'image_url'
|
|
14
|
+
INPUT = 'input'
|
|
15
|
+
JSON = 'json'
|
|
16
|
+
MESSAGE = 'message'
|
|
17
|
+
MODEL = 'model'
|
|
18
|
+
RESPONSE = 'response'
|
|
19
|
+
STATUS = 'status'
|
|
20
|
+
TASK = 'task'
|
|
21
|
+
TEXT = 'text'
|
|
22
|
+
TYPE = 'type'
|
|
23
|
+
URL = 'url'
|
|
24
|
+
|
|
25
|
+
class OutputType(StrEnum):
|
|
26
|
+
"""Defines the expected output types returned by the Jina AI embedding API."""
|
|
27
|
+
DATA = 'data'
|
|
28
|
+
EMBEDDING = 'embedding'
|
|
@@ -13,6 +13,7 @@ class ExtendedHTTPStatus(IntEnum):
|
|
|
13
13
|
HTTP_STATUS_TO_EXCEPTION_MAP: dict[int, type[BaseInvokerError]]
|
|
14
14
|
ANTHROPIC_ERROR_MAPPING: Incomplete
|
|
15
15
|
BEDROCK_ERROR_MAPPING: Incomplete
|
|
16
|
+
COHERE_ERROR_MAPPING: Incomplete
|
|
16
17
|
GOOGLE_ERROR_MAPPING: Incomplete
|
|
17
18
|
LANGCHAIN_ERROR_CODE_MAPPING: Incomplete
|
|
18
19
|
LITELLM_ERROR_MAPPING: Incomplete
|
|
@@ -12,8 +12,10 @@ class ModelProvider(StrEnum):
|
|
|
12
12
|
ANTHROPIC = 'anthropic'
|
|
13
13
|
AZURE_OPENAI = 'azure-openai'
|
|
14
14
|
BEDROCK = 'bedrock'
|
|
15
|
+
COHERE = 'cohere'
|
|
15
16
|
DATASAUR = 'datasaur'
|
|
16
17
|
GOOGLE = 'google'
|
|
18
|
+
JINA = 'jina'
|
|
17
19
|
LANGCHAIN = 'langchain'
|
|
18
20
|
LITELLM = 'litellm'
|
|
19
21
|
OPENAI = 'openai'
|
|
@@ -45,6 +47,11 @@ class ModelId(BaseModel):
|
|
|
45
47
|
model_id = ModelId.from_string("bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0")
|
|
46
48
|
```
|
|
47
49
|
|
|
50
|
+
# Using Cohere
|
|
51
|
+
```python
|
|
52
|
+
model_id = ModelId.from_string("cohere/embed-english-v3.0")
|
|
53
|
+
```
|
|
54
|
+
|
|
48
55
|
# Using Datasaur
|
|
49
56
|
```python
|
|
50
57
|
model_id = ModelId.from_string("datasaur/https://deployment.datasaur.ai/api/deployment/teamId/deploymentId/")
|
|
@@ -55,6 +62,13 @@ class ModelId(BaseModel):
|
|
|
55
62
|
model_id = ModelId.from_string("google/gemini-2.5-flash-lite")
|
|
56
63
|
```
|
|
57
64
|
|
|
65
|
+
# Using Jina
|
|
66
|
+
```python
|
|
67
|
+
model_id = ModelId.from_string("jina/jina-embeddings-v2-large")
|
|
68
|
+
```
|
|
69
|
+
For the list of supported models, please refer to the following page:
|
|
70
|
+
https://jina.ai/models
|
|
71
|
+
|
|
58
72
|
# Using OpenAI
|
|
59
73
|
```python
|
|
60
74
|
model_id = ModelId.from_string("openai/gpt-5-nano")
|
|
@@ -94,6 +108,7 @@ class ModelId(BaseModel):
|
|
|
94
108
|
```python
|
|
95
109
|
model_id = ModelId.from_string("langchain/langchain_openai.ChatOpenAI:gpt-4o-mini")
|
|
96
110
|
```
|
|
111
|
+
|
|
97
112
|
For the list of supported providers, please refer to the following table:
|
|
98
113
|
https://python.langchain.com/docs/integrations/chat/#featured-providers
|
|
99
114
|
|
|
Binary file
|
gllm_inference.pyi
CHANGED
|
@@ -14,7 +14,9 @@ import gllm_core
|
|
|
14
14
|
import gllm_core.utils
|
|
15
15
|
import gllm_inference.em_invoker.AzureOpenAIEMInvoker
|
|
16
16
|
import gllm_inference.em_invoker.BedrockEMInvoker
|
|
17
|
+
import gllm_inference.em_invoker.CohereEMInvoker
|
|
17
18
|
import gllm_inference.em_invoker.GoogleEMInvoker
|
|
19
|
+
import gllm_inference.em_invoker.JinaEMInvoker
|
|
18
20
|
import gllm_inference.em_invoker.LangChainEMInvoker
|
|
19
21
|
import gllm_inference.em_invoker.OpenAICompatibleEMInvoker
|
|
20
22
|
import gllm_inference.em_invoker.OpenAIEMInvoker
|
|
@@ -50,16 +52,21 @@ import gllm_inference.exceptions.BaseInvokerError
|
|
|
50
52
|
import gllm_inference.exceptions.convert_http_status_to_base_invoker_error
|
|
51
53
|
import gllm_inference.schema.Vector
|
|
52
54
|
import aioboto3
|
|
53
|
-
import
|
|
54
|
-
import gllm_inference.exceptions.convert_to_base_invoker_error
|
|
55
|
+
import base64
|
|
55
56
|
import gllm_inference.schema.Attachment
|
|
56
57
|
import gllm_inference.schema.AttachmentType
|
|
57
58
|
import gllm_inference.schema.EMContent
|
|
59
|
+
import gllm_inference.utils.validate_string_enum
|
|
60
|
+
import cohere
|
|
61
|
+
import asyncio.CancelledError
|
|
62
|
+
import gllm_inference.exceptions.convert_to_base_invoker_error
|
|
58
63
|
import gllm_inference.schema.TruncateSide
|
|
59
64
|
import google
|
|
60
65
|
import google.auth
|
|
61
66
|
import google.genai
|
|
62
67
|
import google.genai.types
|
|
68
|
+
import httpx
|
|
69
|
+
import gllm_inference.exceptions.ProviderInternalError
|
|
63
70
|
import concurrent
|
|
64
71
|
import concurrent.futures
|
|
65
72
|
import concurrent.futures.ThreadPoolExecutor
|
|
@@ -71,9 +78,7 @@ import gllm_inference.utils.load_langchain_model
|
|
|
71
78
|
import gllm_inference.utils.parse_model_data
|
|
72
79
|
import openai
|
|
73
80
|
import io
|
|
74
|
-
import httpx
|
|
75
81
|
import twelvelabs
|
|
76
|
-
import base64
|
|
77
82
|
import sys
|
|
78
83
|
import voyageai
|
|
79
84
|
import voyageai.client_async
|
|
@@ -111,7 +116,6 @@ import jsonschema
|
|
|
111
116
|
import gllm_inference.lm_invoker.batch.BatchOperations
|
|
112
117
|
import gllm_inference.schema.Activity
|
|
113
118
|
import gllm_inference.schema.MessageContent
|
|
114
|
-
import gllm_inference.utils.validate_string_enum
|
|
115
119
|
import __future__
|
|
116
120
|
import gllm_inference.schema.ActivityEvent
|
|
117
121
|
import gllm_inference.schema.CodeEvent
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: gllm-inference-binary
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.43
|
|
4
4
|
Summary: A library containing components related to model inferences in Gen AI applications.
|
|
5
5
|
Author-email: Henry Wicaksono <henry.wicaksono@gdplabs.id>, Resti Febrina <resti.febrina@gdplabs.id>
|
|
6
6
|
Requires-Python: <3.14,>=3.11
|
|
@@ -30,6 +30,8 @@ Provides-Extra: anthropic
|
|
|
30
30
|
Requires-Dist: anthropic<0.61.0,>=0.60.0; extra == "anthropic"
|
|
31
31
|
Provides-Extra: bedrock
|
|
32
32
|
Requires-Dist: aioboto3<16.0.0,>=15.0.0; extra == "bedrock"
|
|
33
|
+
Provides-Extra: cohere
|
|
34
|
+
Requires-Dist: cohere<6.0.0,>=5.18.0; extra == "cohere"
|
|
33
35
|
Provides-Extra: datasaur
|
|
34
36
|
Requires-Dist: openai<2.0.0,>=1.98.0; extra == "datasaur"
|
|
35
37
|
Provides-Extra: google
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
gllm_inference.cp312-win_amd64.pyd,sha256=
|
|
2
|
-
gllm_inference.pyi,sha256=
|
|
1
|
+
gllm_inference.cp312-win_amd64.pyd,sha256=Et6ulynj_7yTnrrXTnC3AIRPICtHzdu88PaV9mG2Si8,3666432
|
|
2
|
+
gllm_inference.pyi,sha256=UnIa-vKp_jdcRFotiLrenBgWL9JAugy4DMJjwIN6Nd4,4895
|
|
3
3
|
gllm_inference/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
gllm_inference/constants.pyi,sha256=
|
|
4
|
+
gllm_inference/constants.pyi,sha256=PncjVw-mkzcJ3ln1ohvVZGdJ-TD-VZy1Ygn4Va8Z7i0,350
|
|
5
5
|
gllm_inference/builder/__init__.pyi,sha256=-bw1uDx7CAM7pkvjvb1ZXku9zXlQ7aEAyC83KIn3bz8,506
|
|
6
|
-
gllm_inference/builder/build_em_invoker.pyi,sha256=
|
|
6
|
+
gllm_inference/builder/build_em_invoker.pyi,sha256=3vO_pLokR4BAZflOMu6qzXoKx6vibT16uwJETH5Y_yc,6283
|
|
7
7
|
gllm_inference/builder/build_lm_invoker.pyi,sha256=HvQICF-qvOTzfXZUqhi7rlwcpkMZpxaC-8QZmhnXKzI,7466
|
|
8
8
|
gllm_inference/builder/build_lm_request_processor.pyi,sha256=H7Rg88e7PTTCtuyY64r333moTmh4-ypOwgnG10gkEdY,4232
|
|
9
9
|
gllm_inference/builder/build_output_parser.pyi,sha256=sgSTrzUmSRxPzUUum0fDU7A3NXYoYhpi6bEx4Q2XMnA,965
|
|
@@ -11,11 +11,13 @@ gllm_inference/catalog/__init__.pyi,sha256=HWgPKWIzprpMHRKe_qN9BZSIQhVhrqiyjLjIX
|
|
|
11
11
|
gllm_inference/catalog/catalog.pyi,sha256=eWPqgQKi-SJGHabi_XOTEKpAj96OSRypKsb5ZEC1VWU,4911
|
|
12
12
|
gllm_inference/catalog/lm_request_processor_catalog.pyi,sha256=FiveqPDkV58XbDO2znXL-Ix5tFbZwNiVnitlEa90YOY,5536
|
|
13
13
|
gllm_inference/catalog/prompt_builder_catalog.pyi,sha256=iViWB4SaezzjQY4UY1YxeoXUNxqxa2cTJGaD9JSx4Q8,3279
|
|
14
|
-
gllm_inference/em_invoker/__init__.pyi,sha256=
|
|
14
|
+
gllm_inference/em_invoker/__init__.pyi,sha256=uCWfCjh5a5DciRFcUdbHndewokM3J5hp3mbhmM5wQC8,1211
|
|
15
15
|
gllm_inference/em_invoker/azure_openai_em_invoker.pyi,sha256=TXC5Kgf1eZqK2FHKAyeG3LB1SEsSEStnbk9bI1mjC5k,5049
|
|
16
16
|
gllm_inference/em_invoker/bedrock_em_invoker.pyi,sha256=kQETh2r-WR_H3APtt4QavmfwGOR3KB4k6USNYvFateY,5831
|
|
17
|
+
gllm_inference/em_invoker/cohere_em_invoker.pyi,sha256=4eLqeKLoK8vJB61bGdttfWUUvNDBToBqNA6KQYBMT8s,6793
|
|
17
18
|
gllm_inference/em_invoker/em_invoker.pyi,sha256=YDYJ8TGScsz5Gg-OBnEENN1tI1RYvwoddypxUr6SAWw,5191
|
|
18
19
|
gllm_inference/em_invoker/google_em_invoker.pyi,sha256=zZYjeLp9ncwIVM4UHqDJSVOFn1eXiaz9Ba24-_fCF2c,6953
|
|
20
|
+
gllm_inference/em_invoker/jina_em_invoker.pyi,sha256=wrivFiPFRWBSw-TEAkaQKBvBRhlzN6CBaZkc0HOslRw,5754
|
|
19
21
|
gllm_inference/em_invoker/langchain_em_invoker.pyi,sha256=nhX6LynrjhfySEt_44OlLoSBd15hoz3giWyNM9CYLKY,3544
|
|
20
22
|
gllm_inference/em_invoker/openai_compatible_em_invoker.pyi,sha256=SbvCbOhdpkq6IyPhGd_IlxD8hbXDZID2rIehY6mJOIs,2923
|
|
21
23
|
gllm_inference/em_invoker/openai_em_invoker.pyi,sha256=dwZr9rjrjm060HEnyaPR9-jFJpxSi7fWx7i9ZB4aEY4,6313
|
|
@@ -25,7 +27,9 @@ gllm_inference/em_invoker/langchain/__init__.pyi,sha256=aOTlRvS9aG1tBErjsmhe75s4
|
|
|
25
27
|
gllm_inference/em_invoker/langchain/em_invoker_embeddings.pyi,sha256=BBSDazMOckO9Aw17tC3LGUTPqLb01my1xUZLtKZlwJY,3388
|
|
26
28
|
gllm_inference/em_invoker/schema/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
29
|
gllm_inference/em_invoker/schema/bedrock.pyi,sha256=HoNgVi0T21aFd1JrCnSLu4yryv8k8RnYdR3-tIdHFgA,498
|
|
30
|
+
gllm_inference/em_invoker/schema/cohere.pyi,sha256=Wio6h0sbY93GygqETtflRaaucFzYSeLZRg7jyxMDK0s,567
|
|
28
31
|
gllm_inference/em_invoker/schema/google.pyi,sha256=bzdtu4DFH2kATLybIeNl_Lznj99H-6u2Fvx3Zx52oZg,190
|
|
32
|
+
gllm_inference/em_invoker/schema/jina.pyi,sha256=EFo4d8HuzPEZDV5F0PwUIkYPrCTEiCqHq17ICzYxKeg,739
|
|
29
33
|
gllm_inference/em_invoker/schema/langchain.pyi,sha256=SZ13HDcvAOGmDTi2b72H6Y1J5GePR21JdnM6gYrwcGs,117
|
|
30
34
|
gllm_inference/em_invoker/schema/openai.pyi,sha256=rNRqN62y5wHOKlr4T0n0m41ikAnSrD72CTnoHxo6kEM,146
|
|
31
35
|
gllm_inference/em_invoker/schema/openai_compatible.pyi,sha256=A9MOeBhI-IPuvewOk4YYOAGtgyKohERx6-9cEYtbwvs,157
|
|
@@ -34,7 +38,7 @@ gllm_inference/em_invoker/schema/voyage.pyi,sha256=Aqvu6mhFkNb01aXAI5mChLKIgEnFn
|
|
|
34
38
|
gllm_inference/exceptions/__init__.pyi,sha256=nXOqwsuwUgsnBcJEANVuxbZ1nDfcJ6-pKUfKeZwltkk,1218
|
|
35
39
|
gllm_inference/exceptions/error_parser.pyi,sha256=4aiJZhBzBOqlhdmpvaCvildGy7_XxlJzQpe3PzGt8eE,2040
|
|
36
40
|
gllm_inference/exceptions/exceptions.pyi,sha256=6y3ECgHAStqMGgQv8Dv-Ui-5PDD07mSj6qaRZeSWea4,5857
|
|
37
|
-
gllm_inference/exceptions/provider_error_map.pyi,sha256=
|
|
41
|
+
gllm_inference/exceptions/provider_error_map.pyi,sha256=vWa4ZIHn7qIghECGvO-dS2KzOmf3c10GRWKZ4YDPnSQ,1267
|
|
38
42
|
gllm_inference/lm_invoker/__init__.pyi,sha256=jG1xc5fTOeIgeKKVYSnsMzQThKk9kTW38yO_MYtv540,1387
|
|
39
43
|
gllm_inference/lm_invoker/anthropic_lm_invoker.pyi,sha256=JSgKUk9d1ZHlitv_ZjHlAk2hIW-J7u6yslVHflIeUro,16726
|
|
40
44
|
gllm_inference/lm_invoker/azure_openai_lm_invoker.pyi,sha256=FYfRNPG-oD4wIfitjTHnGib1uMZL7Pid0gbrRsymAHU,14601
|
|
@@ -106,7 +110,7 @@ gllm_inference/schema/lm_input.pyi,sha256=HxQiZgY7zcXh_Dw8nK8LSeBTZEHMPZVwmPmnfg
|
|
|
106
110
|
gllm_inference/schema/lm_output.pyi,sha256=DIV8BiIOPaSnMKxzKzH_Mp7j7-MScWCvmllegJDLqFg,2479
|
|
107
111
|
gllm_inference/schema/mcp.pyi,sha256=4SgQ83pEowfWm2p-w9lupV4NayqqVBOy7SuYxIFeWRs,1045
|
|
108
112
|
gllm_inference/schema/message.pyi,sha256=jJV6A0ihEcun2OhzyMtNkiHnf7d6v5R-GdpTBGfJ0AQ,2272
|
|
109
|
-
gllm_inference/schema/model_id.pyi,sha256=
|
|
113
|
+
gllm_inference/schema/model_id.pyi,sha256=3PeAHrCyMAZJPCa7CfaArmOHdh2oDdUu6lkyx9mKG9g,5819
|
|
110
114
|
gllm_inference/schema/reasoning.pyi,sha256=jbPxkDRHt0Vt-zdcc8lTT1l2hIE1Jm3HIHeNd0hfXGo,577
|
|
111
115
|
gllm_inference/schema/token_usage.pyi,sha256=WJiGQyz5qatzBK2b-sABLCyTRLCBbAvxCRcqSJOzu-8,3025
|
|
112
116
|
gllm_inference/schema/tool_call.pyi,sha256=OWT9LUqs_xfUcOkPG0aokAAqzLYYDkfnjTa0zOWvugk,403
|
|
@@ -117,7 +121,7 @@ gllm_inference/utils/io_utils.pyi,sha256=Eg7dvHWdXslTKdjh1j3dG50i7r35XG2zTmJ9XXv
|
|
|
117
121
|
gllm_inference/utils/langchain.pyi,sha256=4AwFiVAO0ZpdgmqeC4Pb5NJwBt8vVr0MSUqLeCdTscc,1194
|
|
118
122
|
gllm_inference/utils/validation.pyi,sha256=-RdMmb8afH7F7q4Ao7x6FbwaDfxUHn3hA3WiOgzB-3s,397
|
|
119
123
|
gllm_inference.build/.gitignore,sha256=aEiIwOuxfzdCmLZe4oB1JsBmCUxwG8x-u-HBCV9JT8E,1
|
|
120
|
-
gllm_inference_binary-0.5.
|
|
121
|
-
gllm_inference_binary-0.5.
|
|
122
|
-
gllm_inference_binary-0.5.
|
|
123
|
-
gllm_inference_binary-0.5.
|
|
124
|
+
gllm_inference_binary-0.5.43.dist-info/METADATA,sha256=j6Vv5yVz4dPzbuM8DunV5vgKTdrKrnobNAyv4oJxVaI,5851
|
|
125
|
+
gllm_inference_binary-0.5.43.dist-info/WHEEL,sha256=x5rgv--I0NI0IT1Lh9tN1VG2cI637p3deednwYLKnxc,96
|
|
126
|
+
gllm_inference_binary-0.5.43.dist-info/top_level.txt,sha256=FpOjtN80F-qVNgbScXSEyqa0w09FYn6301iq6qt69IQ,15
|
|
127
|
+
gllm_inference_binary-0.5.43.dist-info/RECORD,,
|
|
File without changes
|
{gllm_inference_binary-0.5.41.dist-info → gllm_inference_binary-0.5.43.dist-info}/top_level.txt
RENAMED
|
File without changes
|