gllm-inference-binary 0.5.65__cp313-cp313-macosx_13_0_arm64.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.
Files changed (140) hide show
  1. gllm_inference/__init__.pyi +0 -0
  2. gllm_inference/builder/__init__.pyi +6 -0
  3. gllm_inference/builder/_build_invoker.pyi +28 -0
  4. gllm_inference/builder/build_em_invoker.pyi +130 -0
  5. gllm_inference/builder/build_lm_invoker.pyi +222 -0
  6. gllm_inference/builder/build_lm_request_processor.pyi +88 -0
  7. gllm_inference/builder/build_output_parser.pyi +29 -0
  8. gllm_inference/catalog/__init__.pyi +4 -0
  9. gllm_inference/catalog/catalog.pyi +121 -0
  10. gllm_inference/catalog/lm_request_processor_catalog.pyi +112 -0
  11. gllm_inference/catalog/prompt_builder_catalog.pyi +82 -0
  12. gllm_inference/constants.pyi +12 -0
  13. gllm_inference/em_invoker/__init__.pyi +12 -0
  14. gllm_inference/em_invoker/azure_openai_em_invoker.pyi +88 -0
  15. gllm_inference/em_invoker/bedrock_em_invoker.pyi +118 -0
  16. gllm_inference/em_invoker/cohere_em_invoker.pyi +127 -0
  17. gllm_inference/em_invoker/em_invoker.pyi +90 -0
  18. gllm_inference/em_invoker/google_em_invoker.pyi +129 -0
  19. gllm_inference/em_invoker/jina_em_invoker.pyi +103 -0
  20. gllm_inference/em_invoker/langchain/__init__.pyi +3 -0
  21. gllm_inference/em_invoker/langchain/em_invoker_embeddings.pyi +84 -0
  22. gllm_inference/em_invoker/langchain_em_invoker.pyi +46 -0
  23. gllm_inference/em_invoker/openai_compatible_em_invoker.pyi +41 -0
  24. gllm_inference/em_invoker/openai_em_invoker.pyi +118 -0
  25. gllm_inference/em_invoker/schema/__init__.pyi +0 -0
  26. gllm_inference/em_invoker/schema/bedrock.pyi +29 -0
  27. gllm_inference/em_invoker/schema/cohere.pyi +20 -0
  28. gllm_inference/em_invoker/schema/google.pyi +9 -0
  29. gllm_inference/em_invoker/schema/jina.pyi +29 -0
  30. gllm_inference/em_invoker/schema/langchain.pyi +5 -0
  31. gllm_inference/em_invoker/schema/openai.pyi +7 -0
  32. gllm_inference/em_invoker/schema/openai_compatible.pyi +7 -0
  33. gllm_inference/em_invoker/schema/twelvelabs.pyi +17 -0
  34. gllm_inference/em_invoker/schema/voyage.pyi +15 -0
  35. gllm_inference/em_invoker/twelevelabs_em_invoker.pyi +101 -0
  36. gllm_inference/em_invoker/voyage_em_invoker.pyi +104 -0
  37. gllm_inference/exceptions/__init__.pyi +4 -0
  38. gllm_inference/exceptions/error_parser.pyi +41 -0
  39. gllm_inference/exceptions/exceptions.pyi +132 -0
  40. gllm_inference/exceptions/provider_error_map.pyi +24 -0
  41. gllm_inference/lm_invoker/__init__.pyi +15 -0
  42. gllm_inference/lm_invoker/anthropic_lm_invoker.pyi +320 -0
  43. gllm_inference/lm_invoker/azure_openai_lm_invoker.pyi +237 -0
  44. gllm_inference/lm_invoker/batch/__init__.pyi +3 -0
  45. gllm_inference/lm_invoker/batch/batch_operations.pyi +128 -0
  46. gllm_inference/lm_invoker/bedrock_lm_invoker.pyi +212 -0
  47. gllm_inference/lm_invoker/datasaur_lm_invoker.pyi +157 -0
  48. gllm_inference/lm_invoker/google_lm_invoker.pyi +421 -0
  49. gllm_inference/lm_invoker/langchain_lm_invoker.pyi +239 -0
  50. gllm_inference/lm_invoker/litellm_lm_invoker.pyi +224 -0
  51. gllm_inference/lm_invoker/lm_invoker.pyi +183 -0
  52. gllm_inference/lm_invoker/openai_chat_completions_lm_invoker.pyi +252 -0
  53. gllm_inference/lm_invoker/openai_compatible_lm_invoker.pyi +52 -0
  54. gllm_inference/lm_invoker/openai_lm_invoker.pyi +437 -0
  55. gllm_inference/lm_invoker/portkey_lm_invoker.pyi +296 -0
  56. gllm_inference/lm_invoker/schema/__init__.pyi +0 -0
  57. gllm_inference/lm_invoker/schema/anthropic.pyi +56 -0
  58. gllm_inference/lm_invoker/schema/bedrock.pyi +53 -0
  59. gllm_inference/lm_invoker/schema/datasaur.pyi +14 -0
  60. gllm_inference/lm_invoker/schema/google.pyi +36 -0
  61. gllm_inference/lm_invoker/schema/langchain.pyi +23 -0
  62. gllm_inference/lm_invoker/schema/openai.pyi +109 -0
  63. gllm_inference/lm_invoker/schema/openai_chat_completions.pyi +62 -0
  64. gllm_inference/lm_invoker/schema/portkey.pyi +31 -0
  65. gllm_inference/lm_invoker/schema/xai.pyi +31 -0
  66. gllm_inference/lm_invoker/sea_lion_lm_invoker.pyi +48 -0
  67. gllm_inference/lm_invoker/xai_lm_invoker.pyi +252 -0
  68. gllm_inference/model/__init__.pyi +13 -0
  69. gllm_inference/model/em/__init__.pyi +0 -0
  70. gllm_inference/model/em/cohere_em.pyi +17 -0
  71. gllm_inference/model/em/google_em.pyi +16 -0
  72. gllm_inference/model/em/jina_em.pyi +22 -0
  73. gllm_inference/model/em/openai_em.pyi +15 -0
  74. gllm_inference/model/em/twelvelabs_em.pyi +13 -0
  75. gllm_inference/model/em/voyage_em.pyi +20 -0
  76. gllm_inference/model/lm/__init__.pyi +0 -0
  77. gllm_inference/model/lm/anthropic_lm.pyi +22 -0
  78. gllm_inference/model/lm/google_lm.pyi +18 -0
  79. gllm_inference/model/lm/openai_lm.pyi +27 -0
  80. gllm_inference/model/lm/sea_lion_lm.pyi +16 -0
  81. gllm_inference/model/lm/xai_lm.pyi +19 -0
  82. gllm_inference/output_parser/__init__.pyi +3 -0
  83. gllm_inference/output_parser/json_output_parser.pyi +60 -0
  84. gllm_inference/output_parser/output_parser.pyi +27 -0
  85. gllm_inference/prompt_builder/__init__.pyi +3 -0
  86. gllm_inference/prompt_builder/format_strategy/__init__.pyi +4 -0
  87. gllm_inference/prompt_builder/format_strategy/format_strategy.pyi +55 -0
  88. gllm_inference/prompt_builder/format_strategy/jinja_format_strategy.pyi +45 -0
  89. gllm_inference/prompt_builder/format_strategy/string_format_strategy.pyi +20 -0
  90. gllm_inference/prompt_builder/prompt_builder.pyi +73 -0
  91. gllm_inference/prompt_formatter/__init__.pyi +7 -0
  92. gllm_inference/prompt_formatter/agnostic_prompt_formatter.pyi +49 -0
  93. gllm_inference/prompt_formatter/huggingface_prompt_formatter.pyi +55 -0
  94. gllm_inference/prompt_formatter/llama_prompt_formatter.pyi +59 -0
  95. gllm_inference/prompt_formatter/mistral_prompt_formatter.pyi +53 -0
  96. gllm_inference/prompt_formatter/openai_prompt_formatter.pyi +35 -0
  97. gllm_inference/prompt_formatter/prompt_formatter.pyi +30 -0
  98. gllm_inference/realtime_chat/__init__.pyi +3 -0
  99. gllm_inference/realtime_chat/google_realtime_chat.pyi +205 -0
  100. gllm_inference/realtime_chat/input_streamer/__init__.pyi +4 -0
  101. gllm_inference/realtime_chat/input_streamer/input_streamer.pyi +36 -0
  102. gllm_inference/realtime_chat/input_streamer/keyboard_input_streamer.pyi +27 -0
  103. gllm_inference/realtime_chat/input_streamer/linux_mic_input_streamer.pyi +36 -0
  104. gllm_inference/realtime_chat/output_streamer/__init__.pyi +4 -0
  105. gllm_inference/realtime_chat/output_streamer/console_output_streamer.pyi +21 -0
  106. gllm_inference/realtime_chat/output_streamer/linux_speaker_output_streamer.pyi +42 -0
  107. gllm_inference/realtime_chat/output_streamer/output_streamer.pyi +33 -0
  108. gllm_inference/realtime_chat/realtime_chat.pyi +28 -0
  109. gllm_inference/request_processor/__init__.pyi +4 -0
  110. gllm_inference/request_processor/lm_request_processor.pyi +101 -0
  111. gllm_inference/request_processor/uses_lm_mixin.pyi +130 -0
  112. gllm_inference/schema/__init__.pyi +19 -0
  113. gllm_inference/schema/activity.pyi +64 -0
  114. gllm_inference/schema/attachment.pyi +102 -0
  115. gllm_inference/schema/code_exec_result.pyi +14 -0
  116. gllm_inference/schema/config.pyi +15 -0
  117. gllm_inference/schema/enums.pyi +82 -0
  118. gllm_inference/schema/events.pyi +105 -0
  119. gllm_inference/schema/formatter.pyi +31 -0
  120. gllm_inference/schema/lm_input.pyi +4 -0
  121. gllm_inference/schema/lm_output.pyi +266 -0
  122. gllm_inference/schema/mcp.pyi +31 -0
  123. gllm_inference/schema/message.pyi +52 -0
  124. gllm_inference/schema/model_id.pyi +176 -0
  125. gllm_inference/schema/reasoning.pyi +15 -0
  126. gllm_inference/schema/token_usage.pyi +75 -0
  127. gllm_inference/schema/tool_call.pyi +14 -0
  128. gllm_inference/schema/tool_result.pyi +11 -0
  129. gllm_inference/schema/type_alias.pyi +11 -0
  130. gllm_inference/utils/__init__.pyi +5 -0
  131. gllm_inference/utils/io_utils.pyi +26 -0
  132. gllm_inference/utils/langchain.pyi +30 -0
  133. gllm_inference/utils/validation.pyi +15 -0
  134. gllm_inference.build/.gitignore +1 -0
  135. gllm_inference.cpython-313-darwin.so +0 -0
  136. gllm_inference.pyi +156 -0
  137. gllm_inference_binary-0.5.65.dist-info/METADATA +138 -0
  138. gllm_inference_binary-0.5.65.dist-info/RECORD +140 -0
  139. gllm_inference_binary-0.5.65.dist-info/WHEEL +5 -0
  140. gllm_inference_binary-0.5.65.dist-info/top_level.txt +1 -0
@@ -0,0 +1,17 @@
1
+ class Key:
2
+ """Defines valid keys in TwelveLabs."""
3
+ INPUT_KEY: str
4
+ MAX_RETRIES: str
5
+ OUTPUT_KEY: str
6
+ TIMEOUT: str
7
+ VALUE: str
8
+
9
+ class InputType:
10
+ """Defines valid input types in TwelveLabs."""
11
+ FILE_SUFFIX: str
12
+ TEXT: str
13
+
14
+ class OutputType:
15
+ """Defines valid output types in TwelveLabs."""
16
+ EMBEDDING_SUFFIX: str
17
+ TEXT_EMBEDDING: str
@@ -0,0 +1,15 @@
1
+ class Key:
2
+ """Defines valid keys in Voyage."""
3
+ API_KEY: str
4
+ CONTENT: str
5
+ IMAGE_BASE64: str
6
+ MAX_RETRIES: str
7
+ MODEL: str
8
+ TEXT: str
9
+ TIMEOUT: str
10
+ TYPE: str
11
+
12
+ class InputType:
13
+ """Defines valid input types in Voyage."""
14
+ IMAGE_BASE64: str
15
+ TEXT: str
@@ -0,0 +1,101 @@
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.twelvelabs import InputType as InputType, Key as Key, OutputType as OutputType
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 typing import Any
7
+
8
+ SUPPORTED_ATTACHMENTS: Incomplete
9
+
10
+ class TwelveLabsEMInvoker(BaseEMInvoker):
11
+ '''An embedding model invoker to interact with TwelveLabs embedding models.
12
+
13
+ Attributes:
14
+ model_id (str): The model ID of the embedding model.
15
+ model_provider (str): The provider of the embedding model.
16
+ model_name (str): The name of the embedding model.
17
+ client (Client): The client for the TwelveLabs API.
18
+ default_hyperparameters (dict[str, Any]): Default hyperparameters for invoking the embedding model.
19
+ retry_config (RetryConfig): The retry configuration for the embedding model.
20
+ truncation_config (TruncationConfig | None): The truncation configuration for the embedding model.
21
+
22
+ Input types:
23
+ The `TwelveLabsEMInvoker` supports the following input types: text, audio, and image.
24
+ Non-text inputs must be passed as a `Attachment` object.
25
+
26
+ Output format:
27
+ The `TwelveLabsEMInvoker` can embed either:
28
+ 1. A single content.
29
+ 1. A single content is either a text, an audio, or an image.
30
+ 2. The output will be a `Vector`, representing the embedding of the content.
31
+
32
+ # Example 1: Embedding a text content.
33
+ ```python
34
+ text = "What animal is in this image?"
35
+ result = await em_invoker.invoke(text)
36
+ ```
37
+
38
+ # Example 2: Embedding an audio content.
39
+ ```python
40
+ audio = Attachment.from_path("path/to/local/audio.mp3")
41
+ result = await em_invoker.invoke(audio)
42
+ ```
43
+
44
+ # Example 3: Embedding an image content.
45
+ ```python
46
+ image = Attachment.from_path("path/to/local/image.png")
47
+ result = await em_invoker.invoke(image)
48
+ ```
49
+
50
+ The above examples will return a `Vector` with a size of (embedding_size,).
51
+
52
+ 2. A list of contents.
53
+ 1. A list of contents is a list that consists of any of the above single contents.
54
+ 2. The output will be a `list[Vector]`, where each element is a `Vector` representing the
55
+ embedding of each single content.
56
+
57
+ # Example: Embedding a list of contents.
58
+ ```python
59
+ text = "What animal is in this image?"
60
+ audio = Attachment.from_path("path/to/local/audio.mp3")
61
+ image = Attachment.from_path("path/to/local/image.png")
62
+ result = await em_invoker.invoke([text, audio, image])
63
+ ```
64
+
65
+ The above examples will return a `list[Vector]` with a size of (3, embedding_size).
66
+
67
+ Retry and timeout:
68
+ The `TwelveLabsEMInvoker` supports retry and timeout configuration.
69
+ By default, the max retries is set to 0 and the timeout is set to 30.0 seconds.
70
+ They can be customized by providing a custom `RetryConfig` object to the `retry_config` parameter.
71
+
72
+ Retry config examples:
73
+ ```python
74
+ retry_config = RetryConfig(max_retries=0, timeout=None) # No retry, no timeout
75
+ retry_config = RetryConfig(max_retries=0, timeout=10.0) # No retry, 10.0 seconds timeout
76
+ retry_config = RetryConfig(max_retries=5, timeout=None) # 5 max retries, no timeout
77
+ retry_config = RetryConfig(max_retries=5, timeout=10.0) # 5 max retries, 10.0 seconds timeout
78
+ ```
79
+
80
+ Usage example:
81
+ ```python
82
+ em_invoker = TwelveLabsEMInvoker(..., retry_config=retry_config)
83
+ ```
84
+ '''
85
+ client: Incomplete
86
+ def __init__(self, model_name: str, api_key: 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) -> None:
87
+ """Initializes a new instance of the TwelveLabsEMInvoker class.
88
+
89
+ Args:
90
+ model_name (str): The name of the TwelveLabs embedding model to be used.
91
+ api_key (str | None, optional): The API key for the TwelveLabs API. Defaults to None, in which
92
+ case the `TWELVELABS_API_KEY` environment variable will be used.
93
+ model_kwargs (dict[str, Any] | None, optional): Additional keyword arguments for the TwelveLabs client.
94
+ Defaults to None.
95
+ default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the model.
96
+ Defaults to None.
97
+ retry_config (RetryConfig | None, optional): The retry configuration for the embedding model.
98
+ Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used.
99
+ truncation_config (TruncationConfig | None, optional): Configuration for text truncation behavior.
100
+ Defaults to None, in which case no truncation is applied.
101
+ """
@@ -0,0 +1,104 @@
1
+ from _typeshed import Incomplete
2
+ from gllm_core.utils.retry import RetryConfig as RetryConfig
3
+ from gllm_inference.constants import INVOKER_PROPAGATED_MAX_RETRIES as INVOKER_PROPAGATED_MAX_RETRIES
4
+ from gllm_inference.em_invoker.em_invoker import BaseEMInvoker as BaseEMInvoker
5
+ from gllm_inference.em_invoker.schema.voyage import InputType as InputType, Key as Key
6
+ 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
7
+ from typing import Any
8
+
9
+ SUPPORTED_ATTACHMENTS: Incomplete
10
+ MAX_PYTHON_MINOR_VERSION: int
11
+
12
+ class VoyageEMInvoker(BaseEMInvoker):
13
+ '''An embedding model invoker to interact with Voyage 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.
18
+ model_name (str): The name of the embedding model.
19
+ client (Client): The client for the Voyage 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
+
24
+ Input types:
25
+ The `VoyageEMInvoker` supports the following input types: text, image, and a tuple containing text and image.
26
+ Non-text inputs must be passed as a `Attachment` object.
27
+
28
+ Output format:
29
+ The `VoyageEMInvoker` can embed either:
30
+ 1. A single content.
31
+ 1. A single content is either a text, an image, or a tuple containing a text and an image.
32
+ 2. The output will be a `Vector`, representing the embedding of the content.
33
+
34
+ # Example 1: Embedding a text content.
35
+ ```python
36
+ text = "What animal is in this image?"
37
+ result = await em_invoker.invoke(text)
38
+ ```
39
+
40
+ # Example 2: Embedding an image content.
41
+ ```python
42
+ image = Attachment.from_path("path/to/local/image.png")
43
+ result = await em_invoker.invoke(image)
44
+ ```
45
+
46
+ # Example 3: Embedding a tuple containing a text and an image.
47
+ ```python
48
+ text = "What animal is in this image?"
49
+ image = Attachment.from_path("path/to/local/image.png")
50
+ result = await em_invoker.invoke((text, image))
51
+ ```
52
+
53
+ The above examples will return a `Vector` with a size of (embedding_size,).
54
+
55
+ 2. A list of contents.
56
+ 1. A list of contents is a list that consists of any of the above single contents.
57
+ 2. The output will be a `list[Vector]`, where each element is a `Vector` representing the
58
+ embedding of each single content.
59
+
60
+ # Example: Embedding a list of contents.
61
+ ```python
62
+ text = "What animal is in this image?"
63
+ image = Attachment.from_path("path/to/local/image.png")
64
+ mix_content = (text, image)
65
+ result = await em_invoker.invoke([text, image, mix_content])
66
+ ```
67
+
68
+ The above examples will return a `list[Vector]` with a size of (3, embedding_size).
69
+
70
+ Retry and timeout:
71
+ The `VoyageEMInvoker` supports retry and timeout configuration.
72
+ By default, the max retries is set to 0 and the timeout is set to 30.0 seconds.
73
+ They can be customized by providing a custom `RetryConfig` object to the `retry_config` parameter.
74
+
75
+ Retry config examples:
76
+ ```python
77
+ retry_config = RetryConfig(max_retries=0, timeout=None) # No retry, no timeout
78
+ retry_config = RetryConfig(max_retries=0, timeout=10.0) # No retry, 10.0 seconds timeout
79
+ retry_config = RetryConfig(max_retries=5, timeout=None) # 5 max retries, no timeout
80
+ retry_config = RetryConfig(max_retries=5, timeout=10.0) # 5 max retries, 10.0 seconds timeout
81
+ ```
82
+
83
+ Usage example:
84
+ ```python
85
+ em_invoker = VoyageEMInvoker(..., retry_config=retry_config)
86
+ ```
87
+ '''
88
+ client: Incomplete
89
+ def __init__(self, model_name: str, api_key: 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) -> None:
90
+ """Initializes a new instance of the VoyageEMInvoker class.
91
+
92
+ Args:
93
+ model_name (str): The name of the Voyage embedding model to be used.
94
+ api_key (str | None, optional): The API key for the Voyage API. Defaults to None, in which
95
+ case the `VOYAGE_API_KEY` environment variable will be used.
96
+ model_kwargs (dict[str, Any] | None, optional): Additional keyword arguments for the Voyage client.
97
+ Defaults to None.
98
+ default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the model.
99
+ Defaults to None.
100
+ retry_config (RetryConfig | None, optional): The retry configuration for the embedding model.
101
+ Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used.
102
+ truncation_config (TruncationConfig | None, optional): Configuration for text truncation behavior.
103
+ Defaults to None, in which case no truncation is applied.
104
+ """
@@ -0,0 +1,4 @@
1
+ from gllm_inference.exceptions.error_parser import _get_exception_key as _get_exception_key, build_debug_info as build_debug_info, convert_http_status_to_base_invoker_error as convert_http_status_to_base_invoker_error, convert_to_base_invoker_error as convert_to_base_invoker_error
2
+ from gllm_inference.exceptions.exceptions import APIConnectionError as APIConnectionError, APITimeoutError as APITimeoutError, BaseInvokerError as BaseInvokerError, InvokerRuntimeError as InvokerRuntimeError, ModelNotFoundError as ModelNotFoundError, ProviderAuthError as ProviderAuthError, ProviderConflictError as ProviderConflictError, ProviderInternalError as ProviderInternalError, ProviderInvalidArgsError as ProviderInvalidArgsError, ProviderOverloadedError as ProviderOverloadedError, ProviderRateLimitError as ProviderRateLimitError
3
+
4
+ __all__ = ['_get_exception_key', 'APIConnectionError', 'APITimeoutError', 'BaseInvokerError', 'InvokerRuntimeError', 'ModelNotFoundError', 'ProviderAuthError', 'ProviderConflictError', 'ProviderInternalError', 'ProviderInvalidArgsError', 'ProviderOverloadedError', 'ProviderRateLimitError', 'build_debug_info', 'convert_http_status_to_base_invoker_error', 'convert_to_base_invoker_error']
@@ -0,0 +1,41 @@
1
+ from gllm_inference.exceptions.exceptions import BaseInvokerError as BaseInvokerError, InvokerRuntimeError as InvokerRuntimeError
2
+ from gllm_inference.exceptions.provider_error_map import ALL_PROVIDER_ERROR_MAPPINGS as ALL_PROVIDER_ERROR_MAPPINGS, HTTP_STATUS_TO_EXCEPTION_MAP as HTTP_STATUS_TO_EXCEPTION_MAP
3
+ from typing import Any
4
+
5
+ def build_debug_info(error: Any, class_name: str) -> dict[str, Any]:
6
+ """Build debug information for an error.
7
+
8
+ Args:
9
+ error (Any): The error to extract debug information from.
10
+ class_name (str): The name of the class that raised the error.
11
+
12
+ Returns:
13
+ dict[str, Any]: A dictionary containing debug information about the error.
14
+ """
15
+ def convert_http_status_to_base_invoker_error(error: Exception, invoker: BaseEMInvoker | BaseLMInvoker, status_code_extractor: callable = None, provider_error_mapping: dict[str, type[BaseInvokerError]] = ...) -> BaseInvokerError:
16
+ """Extract provider error with HTTP status code fallback pattern.
17
+
18
+ This function implements the common pattern used by Bedrock and Google invokers
19
+ where they first try to extract HTTP status codes, then fall back to provider-specific
20
+ error mappings based on exception keys.
21
+
22
+ Args:
23
+ error (Exception): The error to convert.
24
+ invoker (BaseEMInvoker | BaseLMInvoker): The invoker instance that raised the error.
25
+ status_code_extractor (callable): Function to extract status code from error.
26
+ provider_error_mapping (dict): Provider-specific error mapping dictionary.
27
+
28
+ Returns:
29
+ BaseInvokerError: The converted error.
30
+ """
31
+ def convert_to_base_invoker_error(error: Exception, invoker: BaseEMInvoker | BaseLMInvoker) -> BaseInvokerError:
32
+ """Convert provider error into BaseInvokerError.
33
+
34
+ Args:
35
+ error (Exception): The error to convert.
36
+ invoker (BaseEMInvoker | BaseLMInvoker): The invoker instance that raised the error.
37
+
38
+ Returns:
39
+ BaseInvokerError: The converted error.
40
+
41
+ """
@@ -0,0 +1,132 @@
1
+ from _typeshed import Incomplete
2
+ from typing import Any
3
+
4
+ class BaseInvokerError(Exception):
5
+ """Base exception class for all gllm_inference invoker errors."""
6
+ debug_info: Incomplete
7
+ class_name: Incomplete
8
+ def __init__(self, class_name: str, message: str, debug_info: dict[str, Any] | None = None) -> None:
9
+ """Initialize the base exception.
10
+
11
+ Args:
12
+ class_name (str): The name of the class that raised the error.
13
+ message (str): The error message.
14
+ debug_info (dict[str, Any] | None, optional): Additional debug information for developers.
15
+ Defaults to None.
16
+ """
17
+ def verbose(self) -> str:
18
+ """Verbose error message with debug information.
19
+
20
+ Returns:
21
+ str: The verbose error message with debug information.
22
+ """
23
+
24
+ class ProviderInvalidArgsError(BaseInvokerError):
25
+ """Exception for bad or malformed requests, invalid parameters or structure."""
26
+ def __init__(self, class_name: str, debug_info: dict[str, Any] | None = None) -> None:
27
+ """Initialize ProviderInvalidArgsError.
28
+
29
+ Args:
30
+ class_name (str): The name of the class that raised the error.
31
+ debug_info (dict[str, Any] | None, optional): Additional debug information for developers.
32
+ Defaults to None.
33
+ """
34
+
35
+ class ProviderAuthError(BaseInvokerError):
36
+ """Exception for authorization failures due to API key issues."""
37
+ def __init__(self, class_name: str, debug_info: dict[str, Any] | None = None) -> None:
38
+ """Initialize ProviderAuthError.
39
+
40
+ Args:
41
+ class_name (str): The name of the class that raised the error.
42
+ debug_info (dict[str, Any] | None, optional): Additional debug information for developers.
43
+ Defaults to None.
44
+ """
45
+
46
+ class ProviderRateLimitError(BaseInvokerError):
47
+ """Exception for rate limit violations."""
48
+ def __init__(self, class_name: str, debug_info: dict[str, Any] | None = None) -> None:
49
+ """Initialize ProviderRateLimitError.
50
+
51
+ Args:
52
+ class_name (str): The name of the class that raised the error.
53
+ debug_info (dict[str, Any] | None, optional): Additional debug information for developers.
54
+ Defaults to None.
55
+ """
56
+
57
+ class ProviderInternalError(BaseInvokerError):
58
+ """Exception for unexpected server-side errors."""
59
+ def __init__(self, class_name: str, debug_info: dict[str, Any] | None = None) -> None:
60
+ """Initialize ProviderInternalError.
61
+
62
+ Args:
63
+ class_name (str): The name of the class that raised the error.
64
+ debug_info (dict[str, Any] | None, optional): Additional debug information for developers.
65
+ Defaults to None.
66
+ """
67
+
68
+ class ProviderOverloadedError(BaseInvokerError):
69
+ """Exception for when the engine is currently overloaded."""
70
+ def __init__(self, class_name: str, debug_info: dict[str, Any] | None = None) -> None:
71
+ """Initialize ProviderOverloadedError.
72
+
73
+ Args:
74
+ class_name (str): The name of the class that raised the error.
75
+ debug_info (dict[str, Any] | None, optional): Additional debug information for developers.
76
+ Defaults to None.
77
+ """
78
+
79
+ class ModelNotFoundError(BaseInvokerError):
80
+ """Exception for model not found errors."""
81
+ def __init__(self, class_name: str, debug_info: dict[str, Any] | None = None) -> None:
82
+ """Initialize ModelNotFoundError.
83
+
84
+ Args:
85
+ class_name (str): The name of the class that raised the error.
86
+ debug_info (dict[str, Any] | None, optional): Additional debug information for developers.
87
+ Defaults to None.
88
+ """
89
+
90
+ class APIConnectionError(BaseInvokerError):
91
+ """Exception for when the client fails to connect to the model provider."""
92
+ def __init__(self, class_name: str, debug_info: dict[str, Any] | None = None) -> None:
93
+ """Initialize APIConnectionError.
94
+
95
+ Args:
96
+ class_name (str): The name of the class that raised the error.
97
+ debug_info (dict[str, Any] | None, optional): Additional debug information for developers.
98
+ Defaults to None.
99
+ """
100
+
101
+ class APITimeoutError(BaseInvokerError):
102
+ """Exception for when the request to the model provider times out."""
103
+ def __init__(self, class_name: str, debug_info: dict[str, Any] | None = None) -> None:
104
+ """Initialize APITimeoutError.
105
+
106
+ Args:
107
+ class_name (str): The name of the class that raised the error.
108
+ debug_info (dict[str, Any] | None, optional): Additional debug information for developers.
109
+ Defaults to None.
110
+ """
111
+
112
+ class ProviderConflictError(BaseInvokerError):
113
+ """Exception for when the request to the model provider conflicts."""
114
+ def __init__(self, class_name: str, debug_info: dict[str, Any] | None = None) -> None:
115
+ """Initialize ProviderConflictError.
116
+
117
+ Args:
118
+ class_name (str): The name of the class that raised the error.
119
+ debug_info (dict[str, Any] | None, optional): Additional debug information for developers.
120
+ Defaults to None.
121
+ """
122
+
123
+ class InvokerRuntimeError(BaseInvokerError):
124
+ """Exception for runtime errors that occur during the invocation of the model."""
125
+ def __init__(self, class_name: str, debug_info: dict[str, Any] | None = None) -> None:
126
+ """Initialize the InvokerRuntimeError.
127
+
128
+ Args:
129
+ class_name (str): The name of the class that raised the error.
130
+ debug_info (dict[str, Any] | None, optional): Additional debug information for developers.
131
+ Defaults to None.
132
+ """
@@ -0,0 +1,24 @@
1
+ from _typeshed import Incomplete
2
+ from enum import IntEnum
3
+ from gllm_inference.exceptions.exceptions import APIConnectionError as APIConnectionError, APITimeoutError as APITimeoutError, BaseInvokerError as BaseInvokerError, ModelNotFoundError as ModelNotFoundError, ProviderAuthError as ProviderAuthError, ProviderConflictError as ProviderConflictError, ProviderInternalError as ProviderInternalError, ProviderInvalidArgsError as ProviderInvalidArgsError, ProviderOverloadedError as ProviderOverloadedError, ProviderRateLimitError as ProviderRateLimitError
4
+
5
+ class ExtendedHTTPStatus(IntEnum):
6
+ """HTTP status codes outside of the standard HTTPStatus enum.
7
+
8
+ Attributes:
9
+ SERVICE_OVERLOADED (int): HTTP status code for service overloaded.
10
+ """
11
+ SERVICE_OVERLOADED = 529
12
+
13
+ HTTP_STATUS_TO_EXCEPTION_MAP: dict[int, type[BaseInvokerError]]
14
+ ANTHROPIC_ERROR_MAPPING: Incomplete
15
+ BEDROCK_ERROR_MAPPING: Incomplete
16
+ COHERE_ERROR_MAPPING: Incomplete
17
+ GOOGLE_ERROR_MAPPING: Incomplete
18
+ LANGCHAIN_ERROR_CODE_MAPPING: Incomplete
19
+ LITELLM_ERROR_MAPPING: Incomplete
20
+ OPENAI_ERROR_MAPPING: Incomplete
21
+ TWELVELABS_ERROR_MAPPING: Incomplete
22
+ VOYAGE_ERROR_MAPPING: Incomplete
23
+ GRPC_STATUS_CODE_MAPPING: Incomplete
24
+ ALL_PROVIDER_ERROR_MAPPINGS: Incomplete
@@ -0,0 +1,15 @@
1
+ from gllm_inference.lm_invoker.anthropic_lm_invoker import AnthropicLMInvoker as AnthropicLMInvoker
2
+ from gllm_inference.lm_invoker.azure_openai_lm_invoker import AzureOpenAILMInvoker as AzureOpenAILMInvoker
3
+ from gllm_inference.lm_invoker.bedrock_lm_invoker import BedrockLMInvoker as BedrockLMInvoker
4
+ from gllm_inference.lm_invoker.datasaur_lm_invoker import DatasaurLMInvoker as DatasaurLMInvoker
5
+ from gllm_inference.lm_invoker.google_lm_invoker import GoogleLMInvoker as GoogleLMInvoker
6
+ from gllm_inference.lm_invoker.langchain_lm_invoker import LangChainLMInvoker as LangChainLMInvoker
7
+ from gllm_inference.lm_invoker.litellm_lm_invoker import LiteLLMLMInvoker as LiteLLMLMInvoker
8
+ from gllm_inference.lm_invoker.openai_chat_completions_lm_invoker import OpenAIChatCompletionsLMInvoker as OpenAIChatCompletionsLMInvoker
9
+ from gllm_inference.lm_invoker.openai_compatible_lm_invoker import OpenAICompatibleLMInvoker as OpenAICompatibleLMInvoker
10
+ from gllm_inference.lm_invoker.openai_lm_invoker import OpenAILMInvoker as OpenAILMInvoker
11
+ from gllm_inference.lm_invoker.portkey_lm_invoker import PortkeyLMInvoker as PortkeyLMInvoker
12
+ from gllm_inference.lm_invoker.sea_lion_lm_invoker import SeaLionLMInvoker as SeaLionLMInvoker
13
+ from gllm_inference.lm_invoker.xai_lm_invoker import XAILMInvoker as XAILMInvoker
14
+
15
+ __all__ = ['AnthropicLMInvoker', 'AzureOpenAILMInvoker', 'BedrockLMInvoker', 'DatasaurLMInvoker', 'GoogleLMInvoker', 'LangChainLMInvoker', 'LiteLLMLMInvoker', 'OpenAIChatCompletionsLMInvoker', 'OpenAICompatibleLMInvoker', 'OpenAILMInvoker', 'PortkeyLMInvoker', 'SeaLionLMInvoker', 'XAILMInvoker']