gllm-inference-binary 0.5.40__cp311-cp311-win_amd64.whl → 0.5.66__cp311-cp311-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.
Files changed (57) hide show
  1. gllm_inference/builder/_build_invoker.pyi +28 -0
  2. gllm_inference/builder/build_em_invoker.pyi +12 -16
  3. gllm_inference/builder/build_lm_invoker.pyi +65 -17
  4. gllm_inference/constants.pyi +3 -2
  5. gllm_inference/em_invoker/__init__.pyi +3 -1
  6. gllm_inference/em_invoker/bedrock_em_invoker.pyi +16 -4
  7. gllm_inference/em_invoker/cohere_em_invoker.pyi +127 -0
  8. gllm_inference/em_invoker/jina_em_invoker.pyi +103 -0
  9. gllm_inference/em_invoker/schema/bedrock.pyi +7 -0
  10. gllm_inference/em_invoker/schema/cohere.pyi +20 -0
  11. gllm_inference/em_invoker/schema/jina.pyi +29 -0
  12. gllm_inference/exceptions/provider_error_map.pyi +1 -0
  13. gllm_inference/lm_invoker/__init__.pyi +3 -1
  14. gllm_inference/lm_invoker/anthropic_lm_invoker.pyi +95 -109
  15. gllm_inference/lm_invoker/azure_openai_lm_invoker.pyi +92 -109
  16. gllm_inference/lm_invoker/batch/batch_operations.pyi +2 -1
  17. gllm_inference/lm_invoker/bedrock_lm_invoker.pyi +52 -65
  18. gllm_inference/lm_invoker/datasaur_lm_invoker.pyi +36 -36
  19. gllm_inference/lm_invoker/google_lm_invoker.pyi +195 -110
  20. gllm_inference/lm_invoker/langchain_lm_invoker.pyi +52 -64
  21. gllm_inference/lm_invoker/litellm_lm_invoker.pyi +86 -106
  22. gllm_inference/lm_invoker/lm_invoker.pyi +20 -1
  23. gllm_inference/lm_invoker/openai_chat_completions_lm_invoker.pyi +87 -107
  24. gllm_inference/lm_invoker/openai_lm_invoker.pyi +237 -186
  25. gllm_inference/lm_invoker/portkey_lm_invoker.pyi +296 -0
  26. gllm_inference/lm_invoker/schema/google.pyi +12 -0
  27. gllm_inference/lm_invoker/schema/openai.pyi +22 -0
  28. gllm_inference/lm_invoker/schema/portkey.pyi +31 -0
  29. gllm_inference/lm_invoker/sea_lion_lm_invoker.pyi +48 -0
  30. gllm_inference/lm_invoker/xai_lm_invoker.pyi +94 -131
  31. gllm_inference/model/__init__.pyi +5 -1
  32. gllm_inference/model/em/cohere_em.pyi +17 -0
  33. gllm_inference/model/em/jina_em.pyi +22 -0
  34. gllm_inference/model/lm/anthropic_lm.pyi +2 -0
  35. gllm_inference/model/lm/google_lm.pyi +1 -0
  36. gllm_inference/model/lm/sea_lion_lm.pyi +16 -0
  37. gllm_inference/model/lm/xai_lm.pyi +19 -0
  38. gllm_inference/prompt_builder/format_strategy/__init__.pyi +4 -0
  39. gllm_inference/prompt_builder/format_strategy/format_strategy.pyi +55 -0
  40. gllm_inference/prompt_builder/format_strategy/jinja_format_strategy.pyi +45 -0
  41. gllm_inference/prompt_builder/format_strategy/string_format_strategy.pyi +20 -0
  42. gllm_inference/prompt_builder/prompt_builder.pyi +23 -6
  43. gllm_inference/schema/__init__.pyi +4 -3
  44. gllm_inference/schema/activity.pyi +13 -11
  45. gllm_inference/schema/attachment.pyi +20 -6
  46. gllm_inference/schema/enums.pyi +30 -1
  47. gllm_inference/schema/events.pyi +69 -73
  48. gllm_inference/schema/formatter.pyi +31 -0
  49. gllm_inference/schema/lm_output.pyi +245 -23
  50. gllm_inference/schema/model_id.pyi +27 -3
  51. gllm_inference/utils/validation.pyi +3 -0
  52. gllm_inference.cp311-win_amd64.pyd +0 -0
  53. gllm_inference.pyi +23 -13
  54. {gllm_inference_binary-0.5.40.dist-info → gllm_inference_binary-0.5.66.dist-info}/METADATA +10 -6
  55. {gllm_inference_binary-0.5.40.dist-info → gllm_inference_binary-0.5.66.dist-info}/RECORD +57 -40
  56. {gllm_inference_binary-0.5.40.dist-info → gllm_inference_binary-0.5.66.dist-info}/WHEEL +0 -0
  57. {gllm_inference_binary-0.5.40.dist-info → gllm_inference_binary-0.5.66.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,296 @@
1
+ from _typeshed import Incomplete
2
+ from gllm_core.event import EventEmitter as EventEmitter
3
+ from gllm_core.schema.tool import Tool as Tool
4
+ from gllm_core.utils.retry import RetryConfig as RetryConfig
5
+ from gllm_inference.constants import SECONDS_TO_MILLISECONDS as SECONDS_TO_MILLISECONDS
6
+ from gllm_inference.lm_invoker.openai_chat_completions_lm_invoker import OpenAIChatCompletionsLMInvoker as OpenAIChatCompletionsLMInvoker
7
+ from gllm_inference.lm_invoker.schema.portkey import InputType as InputType, Key as Key
8
+ from gllm_inference.schema import AttachmentType as AttachmentType, LMOutput as LMOutput, ModelId as ModelId, ModelProvider as ModelProvider, ResponseSchema as ResponseSchema
9
+ from langchain_core.tools import Tool as LangChainTool
10
+ from typing import Any
11
+
12
+ MIN_THINKING_BUDGET: int
13
+ SUPPORTED_ATTACHMENTS: Incomplete
14
+ VALID_AUTH_METHODS: str
15
+ logger: Incomplete
16
+
17
+ class PortkeyLMInvoker(OpenAIChatCompletionsLMInvoker):
18
+ '''A language model invoker to interact with Portkey\'s Universal API.
19
+
20
+ This class provides support for Portkey’s Universal AI Gateway, which enables unified access to
21
+ multiple providers (e.g., OpenAI, Anthropic, Google, Cohere, Bedrock) via a single API key.
22
+ The `PortkeyLMInvoker` is compatible with all Portkey model routing configurations, including
23
+ model catalog entries, direct providers, and pre-defined configs.
24
+
25
+ Attributes:
26
+ model_id (str): The model ID of the language model.
27
+ model_provider (str): The provider of the language model.
28
+ model_name (str): The catalog name of the language model.
29
+ client_kwargs (dict[str, Any]): The keyword arguments for the Portkey client.
30
+ default_hyperparameters (dict[str, Any]): Default hyperparameters for invoking the model.
31
+ tools (list[Tool]): The list of tools provided to the model to enable tool calling.
32
+ response_schema (ResponseSchema | None): The schema of the response. If provided, the model will output a
33
+ structured response as defined by the schema. Supports both Pydantic BaseModel and JSON schema dictionary.
34
+ output_analytics (bool): Whether to output the invocation analytics.
35
+ retry_config (RetryConfig): The retry configuration for the language model.
36
+ thinking (bool): Whether to enable thinking mode for supported models.
37
+ thinking_budget (int): The maximum reasoning token budget for thinking mode.
38
+
39
+ Basic usage:
40
+ The `PortkeyLMInvoker` supports multiple authentication methods with strict precedence order.
41
+ Authentication methods are mutually exclusive and cannot be combined.
42
+
43
+ **Authentication Precedence (Highest to Lowest):**
44
+ 1. **Config ID Authentication (Highest precedence)**
45
+ Use a pre-configured routing setup from Portkey’s dashboard.
46
+ ```python
47
+ lm_invoker = PortkeyLMInvoker(
48
+ portkey_api_key="<your-portkey-api-key>",
49
+ config="pc-openai-4f6905",
50
+ )
51
+ ```
52
+
53
+ 2. **Model Catalog Authentication**
54
+ Provider name must match the provider name set in the model catalog.
55
+ More details to set up the model catalog can be found in https://portkey.ai/docs/product/model-catalog#model-catalog.
56
+ There are two ways to specify the model name:
57
+
58
+ 2.1. Using Combined Model Name Format
59
+ Specify the `model_name` in \'@provider-name/model-name\' format.
60
+ ```python
61
+ lm_invoker = PortkeyLMInvoker(
62
+ portkey_api_key="<your-portkey-api-key>",
63
+ model_name="@openai-custom/gpt-4o"
64
+ )
65
+ ```
66
+
67
+ 2.2. Using Separate Provider and Model Name Parameters
68
+ Specify the `provider` in \'@provider-name\' format and `model_name` separately.
69
+ ```python
70
+ lm_invoker = PortkeyLMInvoker(
71
+ portkey_api_key="<your-portkey-api-key>",
72
+ provider="@openai-custom",
73
+ model_name="gpt-4o",
74
+ )
75
+ ```
76
+
77
+ 3. **Direct Provider Authentication**
78
+ Use the `provider` in \'provider-name\' format and `model_name` parameters.
79
+ ```python
80
+ lm_invoker = PortkeyLMInvoker(
81
+ portkey_api_key="<your-portkey-api-key>",
82
+ provider="openai",
83
+ model_name="gpt-4o",
84
+ api_key="sk-...",
85
+ )
86
+ ```
87
+
88
+ Custom Host:
89
+ You can also use the `custom_host` parameter to override the default host. This is available
90
+ for all authentication methods except for Config ID authentication.
91
+ ```python
92
+ lm_invoker = PortkeyLMInvoker(..., custom_host="https://your-custom-endpoint.com")
93
+ ```
94
+
95
+ Input types:
96
+ The `PortkeyLMInvoker` supports text, image, document, and audio inputs.
97
+ Non-text inputs can be passed as an `Attachment` object with the `user` role.
98
+
99
+ ```python
100
+ text = "What animal is in this image?"
101
+ image = Attachment.from_path("path/to/image.png")
102
+ result = await lm_invoker.invoke([text, image])
103
+ ```
104
+
105
+ Text output:
106
+ The `PortkeyLMInvoker` generates text outputs by default.
107
+ Text outputs are stored in the `outputs` attribute of the `LMOutput` object and can be accessed
108
+ via the `texts` (all text outputs) or `text` (first text output) properties.
109
+
110
+ Output example:
111
+ ```python
112
+ LMOutput(outputs=[LMOutputItem(type="text", output="Hello, there!")])
113
+ ```
114
+
115
+ Structured output:
116
+ The `PortkeyLMInvoker` can be configured to generate structured outputs.
117
+ This feature can be enabled by providing a schema to the `response_schema` parameter.
118
+
119
+ Structured outputs are stored in the `outputs` attribute of the `LMOutput` object and can be accessed
120
+ via the `structureds` (all structured outputs) or `structured` (first structured output) properties.
121
+
122
+ The schema must either be one of the following:
123
+ 1. A Pydantic BaseModel class
124
+ The structured output will be a Pydantic model.
125
+ 2. A JSON schema dictionary
126
+ JSON dictionary schema must be compatible with Pydantic\'s JSON schema, especially for complex schemas.
127
+ Thus, it is recommended to create the JSON schema using Pydantic\'s `model_json_schema` method.
128
+ The structured output will be a dictionary.
129
+
130
+ Usage example:
131
+ ```python
132
+ class Animal(BaseModel):
133
+ name: str
134
+ color: str
135
+
136
+ json_schema = Animal.model_json_schema()
137
+
138
+ lm_invoker = PortkeyLMInvoker(..., response_schema=Animal) # Using Pydantic BaseModel class
139
+ lm_invoker = PortkeyLMInvoker(..., response_schema=json_schema) # Using JSON schema dictionary
140
+ ```
141
+
142
+ Output example:
143
+ ```python
144
+ # Using Pydantic BaseModel class outputs a Pydantic model
145
+ LMOutput(outputs=[LMOutputItem(type="structured", output=Animal(name="dog", color="white"))])
146
+
147
+ # Using JSON schema dictionary outputs a dictionary
148
+ LMOutput(outputs=[LMOutputItem(type="structured", output={"name": "dog", "color": "white"})])
149
+ ```
150
+
151
+ When structured output is enabled, streaming is disabled.
152
+
153
+ Tool calling:
154
+ The `PortkeyLMInvoker` can be configured to call tools to perform certain tasks.
155
+ This feature can be enabled by providing a list of `Tool` objects to the `tools` parameter.
156
+
157
+ Tool calls outputs are stored in the `outputs` attribute of the `LMOutput` object and
158
+ can be accessed via the `tool_calls` property.
159
+
160
+ Usage example:
161
+ ```python
162
+ lm_invoker = PortkeyLMInvoker(..., tools=[tool_1, tool_2])
163
+ ```
164
+
165
+ Output example:
166
+ ```python
167
+ LMOutput(
168
+ outputs=[
169
+ LMOutputItem(type="text", output="I\'m using tools..."),
170
+ LMOutputItem(type="tool_call", output=ToolCall(id="123", name="tool_1", args={"key": "value"})),
171
+ LMOutputItem(type="tool_call", output=ToolCall(id="456", name="tool_2", args={"key": "value"})),
172
+ ]
173
+ )
174
+ ```
175
+
176
+ Thinking:
177
+ The `PortkeyLMInvoker` can be configured to perform step-by-step thinking process before answering.
178
+ This feature can be enabled by setting the `thinking` parameter to `True`.
179
+
180
+ Thinking outputs are stored in the `outputs` attribute of the `LMOutput` object
181
+ and can be accessed via the `thinkings` property.
182
+
183
+ Usage example:
184
+ ```python
185
+ lm_invoker = PortkeyLMInvoker(..., thinking=True, thinking_budget=1024)
186
+ ```
187
+
188
+ Output example:
189
+ ```python
190
+ LMOutput(
191
+ outputs=[
192
+ LMOutputItem(type="thinking", output=Reasoning(type="thinking", reasoning="I\'m thinking...", ...)),
193
+ LMOutputItem(type="text", output="Golden retriever is a good dog breed."),
194
+ ]
195
+ )
196
+ ```
197
+
198
+ Streaming output example:
199
+ ```python
200
+ {"type": "thinking_start", "value": "", ...}
201
+ {"type": "thinking", "value": "I\'m ", ...}
202
+ {"type": "thinking", "value": "thinking...", ...}
203
+ {"type": "thinking_end", "value": "", ...}
204
+ {"type": "response", "value": "Golden retriever ", ...}
205
+ {"type": "response", "value": "is a good dog breed.", ...}
206
+ ```
207
+ Note: By default, the thinking token will be streamed with the legacy `EventType.DATA` event type.
208
+ To use the new simplified streamed event format, set the `simplify_events` parameter to `True` during
209
+ LM invoker initialization. The legacy event format support will be removed in v0.6.
210
+
211
+ The amount of tokens allocated for the thinking process can be set via the `thinking_budget` parameter.
212
+ For more information, please refer to the following documentation:
213
+ https://portkey.ai/docs/product/ai-gateway/multimodal-capabilities/thinking-mode.
214
+
215
+ Thinking is only available for certain models depending on capabilities
216
+
217
+ Analytics tracking:
218
+ The `PortkeyLMInvoker` can be configured to output additional information about the invocation.
219
+ This feature can be enabled by setting the `output_analytics` parameter to `True`.
220
+
221
+ When enabled, the following attributes will be stored in the output:
222
+ 1. `token_usage`: The token usage.
223
+ 2. `duration`: The duration in seconds.
224
+ 3. `finish_details`: The details about how the generation finished.
225
+
226
+ Output example:
227
+ ```python
228
+ LMOutput(
229
+ outputs=[...],
230
+ token_usage=TokenUsage(input_tokens=100, output_tokens=50),
231
+ duration=0.729,
232
+ finish_details={"stop_reason": "end_turn"},
233
+ )
234
+ ```
235
+
236
+ When streaming is enabled, token usage is not supported.
237
+
238
+ Retry and timeout:
239
+ The `PortkeyLMInvoker` supports retry and timeout configuration.
240
+ By default, the max retries is set to 0 and the timeout is set to 30.0 seconds.
241
+ They can be customized by providing a custom `RetryConfig` object to the `retry_config` parameter.
242
+
243
+ Retry config examples:
244
+ ```python
245
+ retry_config = RetryConfig(max_retries=0, timeout=None) # No retry, no timeout
246
+ retry_config = RetryConfig(max_retries=5, timeout=10.0) # 5 max retries, 10.0 seconds timeout
247
+ ```
248
+
249
+ Usage example:
250
+ ```python
251
+ lm_invoker = PortkeyLMInvoker(..., retry_config=retry_config)
252
+ ```
253
+ '''
254
+ model_kwargs: Incomplete
255
+ thinking: Incomplete
256
+ thinking_budget: Incomplete
257
+ client_kwargs: Incomplete
258
+ client: Incomplete
259
+ def __init__(self, model_name: str | None = None, portkey_api_key: str | None = None, provider: str | None = None, api_key: str | None = None, config: str | None = None, custom_host: str | None = None, model_kwargs: dict[str, Any] | None = None, default_hyperparameters: dict[str, Any] | None = None, tools: list[Tool | LangChainTool] | None = None, response_schema: ResponseSchema | None = None, output_analytics: bool = False, retry_config: RetryConfig | None = None, thinking: bool | None = None, thinking_budget: int | None = None, simplify_events: bool = False) -> None:
260
+ """Initializes a new instance of the PortkeyLMInvoker class.
261
+
262
+ Args:
263
+ model_name (str | None, optional): The name of the model to use. Acceptable formats:
264
+ 1. 'model' for direct authentication,
265
+ 2. '@provider-slug/model' for model catalog authentication.
266
+ Defaults to None.
267
+ portkey_api_key (str | None, optional): The Portkey API key. Defaults to None, in which
268
+ case the `PORTKEY_API_KEY` environment variable will be used.
269
+ provider (str | None, optional): Provider name or catalog slug. Acceptable formats:
270
+ 1. '@provider-slug' for model catalog authentication (no api_key needed),
271
+ 2. 'provider' for direct authentication (requires api_key).
272
+ Will be combined with model_name if model name is not in the format '@provider-slug/model'.
273
+ Defaults to None.
274
+ api_key (str | None, optional): Provider's API key for direct authentication.
275
+ Must be used with 'provider' parameter (without '@' prefix). Not needed for catalog providers.
276
+ Defaults to None.
277
+ config (str | None, optional): Portkey config ID for complex routing configurations,
278
+ load balancing, or fallback scenarios. Defaults to None.
279
+ custom_host (str | None, optional): Custom host URL for self-hosted or custom endpoints.
280
+ Can be combined with catalog providers. Defaults to None.
281
+ model_kwargs (dict[str, Any] | None, optional): Additional model parameters and authentication.
282
+ Defaults to None.
283
+ default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for model
284
+ invocation (temperature, max_tokens, etc.). Defaults to None.
285
+ tools (list[Tool | LangChainTool] | None, optional): Tools for enabling tool calling functionality.
286
+ Defaults to None.
287
+ response_schema (ResponseSchema | None, optional): Schema for structured output generation.
288
+ Defaults to None.
289
+ output_analytics (bool, optional): Whether to output detailed invocation analytics including
290
+ token usage and timing. Defaults to False.
291
+ retry_config (RetryConfig | None, optional): Configuration for retry behavior on failures.
292
+ Defaults to None.
293
+ thinking (bool | None, optional): Whether to enable thinking mode. Defaults to None.
294
+ thinking_budget (int | None, optional): Thinking budget in tokens. Defaults to None.
295
+ simplify_events (bool, optional): Whether to use simplified event schemas. Defaults to False.
296
+ """
@@ -7,8 +7,10 @@ class Key:
7
7
  FUNCTION: str
8
8
  FUNCTION_CALL: str
9
9
  HTTP_OPTIONS: str
10
+ ID: str
10
11
  NAME: str
11
12
  RETRY_OPTIONS: str
13
+ STATUS: str
12
14
  SYSTEM_INSTRUCTION: str
13
15
  THINKING_CONFIG: str
14
16
  TIMEOUT: str
@@ -16,9 +18,19 @@ class Key:
16
18
  RESPONSE_SCHEMA: str
17
19
  RESPONSE_MIME_TYPE: str
18
20
  VERTEXAI: str
21
+ CUSTOM_REQUEST_IDS: str
19
22
 
20
23
  class InputType:
21
24
  """Defines valid input types in Google."""
22
25
  APPLICATION_JSON: str
23
26
  MODEL: str
24
27
  USER: str
28
+
29
+ class JobState:
30
+ """Defines valid output types in Google."""
31
+ JOB_STATE_CANCELLED: str
32
+ JOB_STATE_EXPIRED: str
33
+ JOB_STATE_FAILED: str
34
+ JOB_STATE_PENDING: str
35
+ JOB_STATE_RUNNING: str
36
+ JOB_STATE_SUCCEEDED: str
@@ -7,9 +7,11 @@ class Key:
7
7
  ARGS: str
8
8
  ARGUMENTS: str
9
9
  BASE_URL: str
10
+ BODY: str
10
11
  CALL_ID: str
11
12
  CONTAINER: str
12
13
  CONTENT: str
14
+ CUSTOM_ID: str
13
15
  DEFAULT: str
14
16
  DEFS: str
15
17
  DESCRIPTION: str
@@ -18,17 +20,24 @@ class Key:
18
20
  FILENAME: str
19
21
  FORMAT: str
20
22
  ID: str
23
+ IMAGE_GENERATION_CALL: str
21
24
  IMAGE_URL: str
22
25
  INCLUDE: str
23
26
  INCOMPLETE_DETAILS: str
27
+ INPUT: str
24
28
  INSTRUCTIONS: str
25
29
  JSON_SCHEMA: str
26
30
  MAX_RETRIES: str
31
+ METHOD: str
32
+ METHOD_POST: str
33
+ MODEL: str
27
34
  NAME: str
28
35
  OUTPUT: str
36
+ OUTPUTS: str
29
37
  PARAMETERS: str
30
38
  REASON: str
31
39
  REASONING: str
40
+ REFUSAL: str
32
41
  ROLE: str
33
42
  SCHEMA: str
34
43
  REQUIRE_APPROVAL: str
@@ -45,6 +54,8 @@ class Key:
45
54
  TOOL_NAME: str
46
55
  TOOLS: str
47
56
  TYPE: str
57
+ URL: str
58
+ USAGE: str
48
59
 
49
60
  class InputType:
50
61
  """Defines valid input types in OpenAI."""
@@ -54,6 +65,7 @@ class InputType:
54
65
  FUNCTION: str
55
66
  FUNCTION_CALL: str
56
67
  FUNCTION_CALL_OUTPUT: str
68
+ IMAGE_GENERATION: str
57
69
  INPUT_FILE: str
58
70
  INPUT_IMAGE: str
59
71
  INPUT_TEXT: str
@@ -69,21 +81,30 @@ class InputType:
69
81
 
70
82
  class OutputType:
71
83
  """Defines valid output types in OpenAI."""
84
+ CANCELLED: str
85
+ CANCELLING: str
72
86
  CODE_INTERPRETER_CALL: str
73
87
  CODE_INTERPRETER_CALL_DELTA: str
74
88
  CODE_INTERPRETER_CALL_DONE: str
75
89
  CODE_INTERPRETER_CALL_IN_PROGRESS: str
76
90
  COMPLETED: str
91
+ COMPLETED_BATCH: str
77
92
  CONTAINER_FILE_CITATION: str
93
+ EXPIRED: str
94
+ FAILED: str
95
+ FINALIZING: str
78
96
  FIND_IN_PAGE: str
79
97
  FUNCTION_CALL: str
80
98
  IMAGE: str
99
+ IMAGE_GENERATION_CALL: str
81
100
  INCOMPLETE: str
101
+ IN_PROGRESS: str
82
102
  ITEM_DONE: str
83
103
  MCP_CALL: str
84
104
  MCP_LIST_TOOLS: str
85
105
  MESSAGE: str
86
106
  OPEN_PAGE: str
107
+ PROCESSED: str
87
108
  REASONING: str
88
109
  REASONING_ADDED: str
89
110
  REASONING_DELTA: str
@@ -91,6 +112,7 @@ class OutputType:
91
112
  REFUSAL: str
92
113
  SEARCH: str
93
114
  TEXT_DELTA: str
115
+ VALIDATING: str
94
116
  WEB_SEARCH_CALL: str
95
117
 
96
118
  class ReasoningEffort(StrEnum):
@@ -0,0 +1,31 @@
1
+ class Key:
2
+ """Valid keys in Portkey."""
3
+ AUTHORIZATION: str
4
+ BUDGET_TOKENS: str
5
+ CONFIG: str
6
+ CONTENT: str
7
+ CONTENT_BLOCKS: str
8
+ CUSTOM_HOST: str
9
+ DELTA: str
10
+ MAX_RETRIES: str
11
+ MODEL: str
12
+ PROVIDER: str
13
+ PROVIDER_MODEL: str
14
+ REQUEST_TIMEOUT: str
15
+ RESPONSE_FORMAT: str
16
+ STRICT_OPEN_AI_COMPLIANCE: str
17
+ THINKING: str
18
+ TOOLS: str
19
+ TYPE: str
20
+ USAGE: str
21
+
22
+ class InputType:
23
+ """Valid input types in Portkey."""
24
+ ENABLED: str
25
+
26
+ class AuthConfig:
27
+ """Authentication configuration keys."""
28
+ CONFIG: str
29
+ MODEL: str
30
+ PROVIDER_AUTH: str
31
+ PROVIDER_CUSTOM_HOST: str
@@ -0,0 +1,48 @@
1
+ from _typeshed import Incomplete
2
+ from gllm_core.schema.tool import Tool as Tool
3
+ from gllm_core.utils import RetryConfig as RetryConfig
4
+ from gllm_inference.constants import INVOKER_PROPAGATED_MAX_RETRIES as INVOKER_PROPAGATED_MAX_RETRIES
5
+ from gllm_inference.lm_invoker.openai_chat_completions_lm_invoker import OpenAIChatCompletionsLMInvoker as OpenAIChatCompletionsLMInvoker
6
+ from gllm_inference.lm_invoker.schema.openai_chat_completions import Key as Key
7
+ from gllm_inference.schema import ModelId as ModelId, ModelProvider as ModelProvider, ResponseSchema as ResponseSchema
8
+ from langchain_core.tools import Tool as LangChainTool
9
+ from typing import Any
10
+
11
+ SEA_LION_URL: str
12
+ SUPPORTED_ATTACHMENTS: Incomplete
13
+
14
+ class SeaLionLMInvoker(OpenAIChatCompletionsLMInvoker):
15
+ """A language model invoker to interact with SEA-LION API.
16
+
17
+ Attributes:
18
+ model_id (str): The model ID of the language model.
19
+ model_provider (str): The provider of the language model.
20
+ model_name (str): The name of the language model.
21
+ client_kwargs (dict[str, Any]): The keyword arguments for the OpenAI client.
22
+ default_hyperparameters (dict[str, Any]): Default hyperparameters for invoking the model.
23
+ tools (list[Tool]): The list of tools provided to the model to enable tool calling.
24
+ response_schema (ResponseSchema | None): The schema of the response. If provided, the model will output a
25
+ structured response as defined by the schema. Supports both Pydantic BaseModel and JSON schema dictionary.
26
+ output_analytics (bool): Whether to output the invocation analytics.
27
+ retry_config (RetryConfig | None): The retry configuration for the language model.
28
+ """
29
+ client_kwargs: Incomplete
30
+ 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, tools: list[Tool | LangChainTool] | None = None, response_schema: ResponseSchema | None = None, output_analytics: bool = False, retry_config: RetryConfig | None = None) -> None:
31
+ """Initializes a new instance of the SeaLionLMInvoker class.
32
+
33
+ Args:
34
+ model_name (str): The name of the SEA-LION language model.
35
+ api_key (str | None, optional): The API key for authenticating with the SEA-LION API.
36
+ Defaults to None, in which case the `SEA_LION_API_KEY` environment variable will be used.
37
+ model_kwargs (dict[str, Any] | None, optional): Additional model parameters. Defaults to None.
38
+ default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the model.
39
+ Defaults to None.
40
+ tools (list[Tool | LangChainTool] | None, optional): Tools provided to the model to enable tool calling.
41
+ Defaults to None.
42
+ response_schema (ResponseSchema | None, optional): The schema of the response. If provided, the model will
43
+ output a structured response as defined by the schema. Supports both Pydantic BaseModel and JSON schema
44
+ dictionary. Defaults to None.
45
+ output_analytics (bool, optional): Whether to output the invocation analytics. Defaults to False.
46
+ retry_config (RetryConfig | None, optional): The retry configuration for the language model.
47
+ Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used.
48
+ """