gllm-inference-binary 0.5.51b3__cp311-cp311-macosx_11_0_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of gllm-inference-binary might be problematic. Click here for more details.
- gllm_inference/__init__.pyi +0 -0
- gllm_inference/builder/__init__.pyi +6 -0
- gllm_inference/builder/_build_invoker.pyi +28 -0
- gllm_inference/builder/build_em_invoker.pyi +130 -0
- gllm_inference/builder/build_lm_invoker.pyi +213 -0
- gllm_inference/builder/build_lm_request_processor.pyi +88 -0
- gllm_inference/builder/build_output_parser.pyi +29 -0
- gllm_inference/catalog/__init__.pyi +4 -0
- gllm_inference/catalog/catalog.pyi +121 -0
- gllm_inference/catalog/lm_request_processor_catalog.pyi +112 -0
- gllm_inference/catalog/prompt_builder_catalog.pyi +82 -0
- gllm_inference/constants.pyi +13 -0
- gllm_inference/em_invoker/__init__.pyi +12 -0
- gllm_inference/em_invoker/azure_openai_em_invoker.pyi +88 -0
- gllm_inference/em_invoker/bedrock_em_invoker.pyi +118 -0
- gllm_inference/em_invoker/cohere_em_invoker.pyi +128 -0
- gllm_inference/em_invoker/em_invoker.pyi +90 -0
- gllm_inference/em_invoker/google_em_invoker.pyi +129 -0
- gllm_inference/em_invoker/jina_em_invoker.pyi +103 -0
- gllm_inference/em_invoker/langchain/__init__.pyi +3 -0
- gllm_inference/em_invoker/langchain/em_invoker_embeddings.pyi +84 -0
- gllm_inference/em_invoker/langchain_em_invoker.pyi +46 -0
- gllm_inference/em_invoker/openai_compatible_em_invoker.pyi +41 -0
- gllm_inference/em_invoker/openai_em_invoker.pyi +118 -0
- gllm_inference/em_invoker/schema/__init__.pyi +0 -0
- gllm_inference/em_invoker/schema/bedrock.pyi +29 -0
- gllm_inference/em_invoker/schema/cohere.pyi +20 -0
- gllm_inference/em_invoker/schema/google.pyi +9 -0
- gllm_inference/em_invoker/schema/jina.pyi +29 -0
- gllm_inference/em_invoker/schema/langchain.pyi +5 -0
- gllm_inference/em_invoker/schema/openai.pyi +7 -0
- gllm_inference/em_invoker/schema/openai_compatible.pyi +7 -0
- gllm_inference/em_invoker/schema/twelvelabs.pyi +17 -0
- gllm_inference/em_invoker/schema/voyage.pyi +15 -0
- gllm_inference/em_invoker/twelevelabs_em_invoker.pyi +101 -0
- gllm_inference/em_invoker/voyage_em_invoker.pyi +104 -0
- gllm_inference/exceptions/__init__.pyi +4 -0
- gllm_inference/exceptions/error_parser.pyi +41 -0
- gllm_inference/exceptions/exceptions.pyi +132 -0
- gllm_inference/exceptions/provider_error_map.pyi +24 -0
- gllm_inference/lm_invoker/__init__.pyi +14 -0
- gllm_inference/lm_invoker/anthropic_lm_invoker.pyi +334 -0
- gllm_inference/lm_invoker/azure_openai_lm_invoker.pyi +254 -0
- gllm_inference/lm_invoker/batch/__init__.pyi +3 -0
- gllm_inference/lm_invoker/batch/batch_operations.pyi +127 -0
- gllm_inference/lm_invoker/bedrock_lm_invoker.pyi +226 -0
- gllm_inference/lm_invoker/datasaur_lm_invoker.pyi +157 -0
- gllm_inference/lm_invoker/google_lm_invoker.pyi +336 -0
- gllm_inference/lm_invoker/langchain_lm_invoker.pyi +251 -0
- gllm_inference/lm_invoker/litellm_lm_invoker.pyi +244 -0
- gllm_inference/lm_invoker/lm_invoker.pyi +164 -0
- gllm_inference/lm_invoker/openai_chat_completions_lm_invoker.pyi +272 -0
- gllm_inference/lm_invoker/openai_compatible_lm_invoker.pyi +52 -0
- gllm_inference/lm_invoker/openai_lm_invoker.pyi +433 -0
- gllm_inference/lm_invoker/portkey_lm_invoker.pyi +260 -0
- gllm_inference/lm_invoker/schema/__init__.pyi +0 -0
- gllm_inference/lm_invoker/schema/anthropic.pyi +56 -0
- gllm_inference/lm_invoker/schema/bedrock.pyi +53 -0
- gllm_inference/lm_invoker/schema/datasaur.pyi +14 -0
- gllm_inference/lm_invoker/schema/google.pyi +24 -0
- gllm_inference/lm_invoker/schema/langchain.pyi +23 -0
- gllm_inference/lm_invoker/schema/openai.pyi +106 -0
- gllm_inference/lm_invoker/schema/openai_chat_completions.pyi +62 -0
- gllm_inference/lm_invoker/schema/portkey.pyi +31 -0
- gllm_inference/lm_invoker/schema/xai.pyi +31 -0
- gllm_inference/lm_invoker/xai_lm_invoker.pyi +289 -0
- gllm_inference/model/__init__.pyi +12 -0
- gllm_inference/model/em/__init__.pyi +0 -0
- gllm_inference/model/em/cohere_em.pyi +17 -0
- gllm_inference/model/em/google_em.pyi +16 -0
- gllm_inference/model/em/jina_em.pyi +22 -0
- gllm_inference/model/em/openai_em.pyi +15 -0
- gllm_inference/model/em/twelvelabs_em.pyi +13 -0
- gllm_inference/model/em/voyage_em.pyi +20 -0
- gllm_inference/model/lm/__init__.pyi +0 -0
- gllm_inference/model/lm/anthropic_lm.pyi +22 -0
- gllm_inference/model/lm/google_lm.pyi +18 -0
- gllm_inference/model/lm/openai_lm.pyi +27 -0
- gllm_inference/model/lm/xai_lm.pyi +19 -0
- gllm_inference/output_parser/__init__.pyi +3 -0
- gllm_inference/output_parser/json_output_parser.pyi +60 -0
- gllm_inference/output_parser/output_parser.pyi +27 -0
- gllm_inference/prompt_builder/__init__.pyi +3 -0
- gllm_inference/prompt_builder/format_strategy/__init__.pyi +4 -0
- gllm_inference/prompt_builder/format_strategy/format_strategy.pyi +55 -0
- gllm_inference/prompt_builder/format_strategy/jinja_format_strategy.pyi +45 -0
- gllm_inference/prompt_builder/format_strategy/string_format_strategy.pyi +20 -0
- gllm_inference/prompt_builder/prompt_builder.pyi +69 -0
- gllm_inference/prompt_formatter/__init__.pyi +7 -0
- gllm_inference/prompt_formatter/agnostic_prompt_formatter.pyi +49 -0
- gllm_inference/prompt_formatter/huggingface_prompt_formatter.pyi +55 -0
- gllm_inference/prompt_formatter/llama_prompt_formatter.pyi +59 -0
- gllm_inference/prompt_formatter/mistral_prompt_formatter.pyi +53 -0
- gllm_inference/prompt_formatter/openai_prompt_formatter.pyi +35 -0
- gllm_inference/prompt_formatter/prompt_formatter.pyi +30 -0
- gllm_inference/realtime_chat/__init__.pyi +3 -0
- gllm_inference/realtime_chat/google_realtime_chat.pyi +205 -0
- gllm_inference/realtime_chat/input_streamer/__init__.pyi +4 -0
- gllm_inference/realtime_chat/input_streamer/input_streamer.pyi +36 -0
- gllm_inference/realtime_chat/input_streamer/keyboard_input_streamer.pyi +27 -0
- gllm_inference/realtime_chat/input_streamer/linux_mic_input_streamer.pyi +36 -0
- gllm_inference/realtime_chat/output_streamer/__init__.pyi +4 -0
- gllm_inference/realtime_chat/output_streamer/console_output_streamer.pyi +21 -0
- gllm_inference/realtime_chat/output_streamer/linux_speaker_output_streamer.pyi +42 -0
- gllm_inference/realtime_chat/output_streamer/output_streamer.pyi +33 -0
- gllm_inference/realtime_chat/realtime_chat.pyi +28 -0
- gllm_inference/request_processor/__init__.pyi +4 -0
- gllm_inference/request_processor/lm_request_processor.pyi +101 -0
- gllm_inference/request_processor/uses_lm_mixin.pyi +130 -0
- gllm_inference/schema/__init__.pyi +18 -0
- gllm_inference/schema/activity.pyi +64 -0
- gllm_inference/schema/attachment.pyi +88 -0
- gllm_inference/schema/code_exec_result.pyi +14 -0
- gllm_inference/schema/config.pyi +15 -0
- gllm_inference/schema/enums.pyi +69 -0
- gllm_inference/schema/events.pyi +105 -0
- gllm_inference/schema/lm_input.pyi +4 -0
- gllm_inference/schema/lm_output.pyi +44 -0
- gllm_inference/schema/mcp.pyi +31 -0
- gllm_inference/schema/message.pyi +52 -0
- gllm_inference/schema/model_id.pyi +176 -0
- gllm_inference/schema/reasoning.pyi +15 -0
- gllm_inference/schema/token_usage.pyi +75 -0
- gllm_inference/schema/tool_call.pyi +14 -0
- gllm_inference/schema/tool_result.pyi +11 -0
- gllm_inference/schema/type_alias.pyi +11 -0
- gllm_inference/utils/__init__.pyi +5 -0
- gllm_inference/utils/io_utils.pyi +26 -0
- gllm_inference/utils/langchain.pyi +30 -0
- gllm_inference/utils/validation.pyi +12 -0
- gllm_inference.build/.gitignore +1 -0
- gllm_inference.cpython-311-darwin.so +0 -0
- gllm_inference.pyi +156 -0
- gllm_inference_binary-0.5.51b3.dist-info/METADATA +138 -0
- gllm_inference_binary-0.5.51b3.dist-info/RECORD +137 -0
- gllm_inference_binary-0.5.51b3.dist-info/WHEEL +5 -0
- gllm_inference_binary-0.5.51b3.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,260 @@
|
|
|
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
|
+
Tool calling:
|
|
106
|
+
Tools can be provided via the `tools` parameter to enable tool invocation.
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
lm_invoker = PortkeyLMInvoker(..., tools=[tool_1, tool_2])
|
|
110
|
+
```
|
|
111
|
+
Output example:
|
|
112
|
+
```python
|
|
113
|
+
LMOutput(
|
|
114
|
+
response="Let me call the tools...",
|
|
115
|
+
tool_calls=[
|
|
116
|
+
ToolCall(id="123", name="tool_1", args={"key": "value"}),
|
|
117
|
+
]
|
|
118
|
+
)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Structured output:
|
|
122
|
+
The `response_schema` parameter enables structured responses (Pydantic BaseModel or JSON schema).
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
class Animal(BaseModel):
|
|
126
|
+
name: str
|
|
127
|
+
color: str
|
|
128
|
+
lm_invoker = PortkeyLMInvoker(..., response_schema=Animal)
|
|
129
|
+
```
|
|
130
|
+
Output example:
|
|
131
|
+
```python
|
|
132
|
+
LMOutput(structured_output=Animal(name="Golden retriever", color="Golden"))
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Analytics tracking:
|
|
136
|
+
When `output_analytics=True`, the invoker includes token usage, duration, and finish details.
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
LMOutput(
|
|
140
|
+
response="Golden retriever is a good dog breed.",
|
|
141
|
+
token_usage=TokenUsage(input_tokens=100, output_tokens=50),
|
|
142
|
+
duration=0.729,
|
|
143
|
+
finish_details={"finish_reason": "stop"},
|
|
144
|
+
)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Note:** When streaming is enabled, token usage analytics are not supported and will be `None`.
|
|
148
|
+
|
|
149
|
+
Retry and timeout:
|
|
150
|
+
The `PortkeyLMInvoker` supports retry and timeout configuration.
|
|
151
|
+
By default, the max retries is set to 0 and the timeout is set to 30.0 seconds.
|
|
152
|
+
They can be customized by providing a custom `RetryConfig` object to the `retry_config` parameter.
|
|
153
|
+
|
|
154
|
+
Retry config examples:
|
|
155
|
+
```python
|
|
156
|
+
retry_config = RetryConfig(max_retries=0, timeout=None) # No retry, no timeout
|
|
157
|
+
retry_config = RetryConfig(max_retries=0, timeout=10.0) # No retry, 10.0 seconds timeout
|
|
158
|
+
retry_config = RetryConfig(max_retries=5, timeout=None) # 5 max retries, no timeout
|
|
159
|
+
retry_config = RetryConfig(max_retries=5, timeout=10.0) # 5 max retries, 10.0 seconds timeout
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Usage example:
|
|
163
|
+
```python
|
|
164
|
+
lm_invoker = PortkeyLMInvoker(..., retry_config=retry_config)
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Thinking:
|
|
168
|
+
The `thinking` parameter enables enhanced reasoning capability for supported models.
|
|
169
|
+
Thinking mode allocates additional “reasoning tokens” up to `thinking_budget` (minimum 1024).
|
|
170
|
+
When enabled, the model’s reasoning trace is stored in the `reasoning` attribute.
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
lm_invoker = PortkeyLMInvoker(..., thinking=True, thinking_budget=1024)
|
|
174
|
+
```
|
|
175
|
+
Output example:
|
|
176
|
+
```python
|
|
177
|
+
LMOutput(
|
|
178
|
+
response="Golden retriever is a good dog breed.",
|
|
179
|
+
reasoning=[Reasoning(reasoning="Let me think about it...")],
|
|
180
|
+
)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Streaming output example:
|
|
184
|
+
```python
|
|
185
|
+
{"type": "thinking_start", "value": ""}
|
|
186
|
+
{"type": "thinking", "value": "Let me think "}
|
|
187
|
+
{"type": "thinking", "value": "about it..."}
|
|
188
|
+
{"type": "thinking_end", "value": ""}
|
|
189
|
+
{"type": "response", "value": "Golden retriever "}
|
|
190
|
+
{"type": "response", "value": "is a good dog breed."}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Note: By default, the thinking token will be streamed with the legacy `EventType.DATA` event type.
|
|
194
|
+
To use the new simplified streamed event format, set the `simplify_events` parameter to `True` during
|
|
195
|
+
LM invoker initialization. The legacy event format support will be removed in v0.6.
|
|
196
|
+
|
|
197
|
+
When thinking is enabled, the amount of tokens allocated for the thinking process can be set via the
|
|
198
|
+
`thinking_budget` parameter. The `thinking_budget`:
|
|
199
|
+
1. Must be a positive integer.
|
|
200
|
+
2. Must be at least 1024.
|
|
201
|
+
3. Must be less than or equal to the model\'s maximum context length.
|
|
202
|
+
For more information, please refer to https://portkey.ai/docs/product/ai-gateway/multimodal-capabilities/thinking-mode
|
|
203
|
+
|
|
204
|
+
Setting reasoning-related parameters for non-reasoning models will raise an error.
|
|
205
|
+
|
|
206
|
+
Output types:
|
|
207
|
+
The output of the `PortkeyLMInvoker` can either be:
|
|
208
|
+
1. `str`: A simple text response.
|
|
209
|
+
2. `LMOutput`: A structured response model that may contain:
|
|
210
|
+
2.1. response (str)
|
|
211
|
+
2.2. tool_calls (list[ToolCall])
|
|
212
|
+
2.3. structured_output (dict[str, Any] | BaseModel | None)
|
|
213
|
+
2.4. token_usage (TokenUsage | None)
|
|
214
|
+
2.5. duration (float | None)
|
|
215
|
+
2.6. finish_details (dict[str, Any] | None)
|
|
216
|
+
2.7. reasoning (list[Reasoning])
|
|
217
|
+
'''
|
|
218
|
+
model_kwargs: Incomplete
|
|
219
|
+
thinking: Incomplete
|
|
220
|
+
thinking_budget: Incomplete
|
|
221
|
+
client_kwargs: Incomplete
|
|
222
|
+
client: Incomplete
|
|
223
|
+
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:
|
|
224
|
+
"""Initializes a new instance of the PortkeyLMInvoker class.
|
|
225
|
+
|
|
226
|
+
Args:
|
|
227
|
+
model_name (str | None, optional): The name of the model to use. Acceptable formats:
|
|
228
|
+
1. 'model' for direct authentication,
|
|
229
|
+
2. '@provider-slug/model' for model catalog authentication.
|
|
230
|
+
Defaults to None.
|
|
231
|
+
portkey_api_key (str | None, optional): The Portkey API key. Defaults to None, in which
|
|
232
|
+
case the `PORTKEY_API_KEY` environment variable will be used.
|
|
233
|
+
provider (str | None, optional): Provider name or catalog slug. Acceptable formats:
|
|
234
|
+
1. '@provider-slug' for model catalog authentication (no api_key needed),
|
|
235
|
+
2. 'provider' for direct authentication (requires api_key).
|
|
236
|
+
Will be combined with model_name if model name is not in the format '@provider-slug/model'.
|
|
237
|
+
Defaults to None.
|
|
238
|
+
api_key (str | None, optional): Provider's API key for direct authentication.
|
|
239
|
+
Must be used with 'provider' parameter (without '@' prefix). Not needed for catalog providers.
|
|
240
|
+
Defaults to None.
|
|
241
|
+
config (str | None, optional): Portkey config ID for complex routing configurations,
|
|
242
|
+
load balancing, or fallback scenarios. Defaults to None.
|
|
243
|
+
custom_host (str | None, optional): Custom host URL for self-hosted or custom endpoints.
|
|
244
|
+
Can be combined with catalog providers. Defaults to None.
|
|
245
|
+
model_kwargs (dict[str, Any] | None, optional): Additional model parameters and authentication.
|
|
246
|
+
Defaults to None.
|
|
247
|
+
default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for model
|
|
248
|
+
invocation (temperature, max_tokens, etc.). Defaults to None.
|
|
249
|
+
tools (list[Tool | LangChainTool] | None, optional): Tools for enabling tool calling functionality.
|
|
250
|
+
Defaults to None.
|
|
251
|
+
response_schema (ResponseSchema | None, optional): Schema for structured output generation.
|
|
252
|
+
Defaults to None.
|
|
253
|
+
output_analytics (bool, optional): Whether to output detailed invocation analytics including
|
|
254
|
+
token usage and timing. Defaults to False.
|
|
255
|
+
retry_config (RetryConfig | None, optional): Configuration for retry behavior on failures.
|
|
256
|
+
Defaults to None.
|
|
257
|
+
thinking (bool | None, optional): Whether to enable thinking mode. Defaults to None.
|
|
258
|
+
thinking_budget (int | None, optional): Thinking budget in tokens. Defaults to None.
|
|
259
|
+
simplify_events (bool, optional): Whether to use simplified event schemas. Defaults to False.
|
|
260
|
+
"""
|
|
File without changes
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
class Key:
|
|
2
|
+
"""Defines valid keys in Anthropic."""
|
|
3
|
+
BUDGET_TOKENS: str
|
|
4
|
+
CONTENT: str
|
|
5
|
+
DATA: str
|
|
6
|
+
DESCRIPTION: str
|
|
7
|
+
ID: str
|
|
8
|
+
INPUT: str
|
|
9
|
+
INPUT_SCHEMA: str
|
|
10
|
+
MAX_RETRIES: str
|
|
11
|
+
MEDIA_TYPE: str
|
|
12
|
+
MAX_TOKENS: str
|
|
13
|
+
NAME: str
|
|
14
|
+
PARAMETERS: str
|
|
15
|
+
ROLE: str
|
|
16
|
+
SIGNATURE: str
|
|
17
|
+
SOURCE: str
|
|
18
|
+
STATUS: str
|
|
19
|
+
STOP_REASON: str
|
|
20
|
+
SYSTEM: str
|
|
21
|
+
TIMEOUT: str
|
|
22
|
+
THINKING: str
|
|
23
|
+
TOOLS: str
|
|
24
|
+
TOOL_CHOICE: str
|
|
25
|
+
TOOL_USE_ID: str
|
|
26
|
+
TEXT: str
|
|
27
|
+
TYPE: str
|
|
28
|
+
|
|
29
|
+
class InputType:
|
|
30
|
+
"""Defines valid input types in Anthropic."""
|
|
31
|
+
BASE64: str
|
|
32
|
+
ENABLED: str
|
|
33
|
+
REDACTED_THINKING: str
|
|
34
|
+
TEXT: str
|
|
35
|
+
THINKING: str
|
|
36
|
+
TOOL: str
|
|
37
|
+
TOOL_RESULT: str
|
|
38
|
+
TOOL_USE: str
|
|
39
|
+
|
|
40
|
+
class OutputType:
|
|
41
|
+
"""Defines valid output types in Anthropic."""
|
|
42
|
+
CANCELING: str
|
|
43
|
+
CONTENT_BLOCK_DELTA: str
|
|
44
|
+
CONTENT_BLOCK_START: str
|
|
45
|
+
CONTENT_BLOCK_STOP: str
|
|
46
|
+
ENDED: str
|
|
47
|
+
ERRORED: str
|
|
48
|
+
IN_PROGRESS: str
|
|
49
|
+
MESSAGE_STOP: str
|
|
50
|
+
REDACTED_THINKING: str
|
|
51
|
+
SUCCEEDED: str
|
|
52
|
+
TEXT: str
|
|
53
|
+
TEXT_DELTA: str
|
|
54
|
+
THINKING: str
|
|
55
|
+
THINKING_DELTA: str
|
|
56
|
+
TOOL_USE: str
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
class Key:
|
|
2
|
+
"""Defines valid keys in Bedrock."""
|
|
3
|
+
BYTES: str
|
|
4
|
+
CONTENT: str
|
|
5
|
+
CONTENT_BLOCK_INDEX: str
|
|
6
|
+
DELTA: str
|
|
7
|
+
DESCRIPTION: str
|
|
8
|
+
ERROR: str
|
|
9
|
+
CODE: str
|
|
10
|
+
FORMAT: str
|
|
11
|
+
FUNCTION: str
|
|
12
|
+
HTTP_STATUS_CODE: str
|
|
13
|
+
INFERENCE_CONFIG: str
|
|
14
|
+
INPUT: str
|
|
15
|
+
INPUT_SCHEMA: str
|
|
16
|
+
INPUT_TOKENS: str
|
|
17
|
+
JSON: str
|
|
18
|
+
MESSAGE: str
|
|
19
|
+
NAME: str
|
|
20
|
+
RESPONSE: str
|
|
21
|
+
OUTPUT: str
|
|
22
|
+
OUTPUT_TOKENS: str
|
|
23
|
+
PARAMETERS: str
|
|
24
|
+
RESPONSE_METADATA: str
|
|
25
|
+
ROLE: str
|
|
26
|
+
SOURCE: str
|
|
27
|
+
START: str
|
|
28
|
+
STOP_REASON: str
|
|
29
|
+
STREAM: str
|
|
30
|
+
SYSTEM: str
|
|
31
|
+
TEXT: str
|
|
32
|
+
TOOL: str
|
|
33
|
+
TOOLS: str
|
|
34
|
+
TOOL_CHOICE: str
|
|
35
|
+
TOOL_CONFIG: str
|
|
36
|
+
TOOL_SPEC: str
|
|
37
|
+
TOOL_USE_ID: str
|
|
38
|
+
USAGE: str
|
|
39
|
+
|
|
40
|
+
class InputType:
|
|
41
|
+
"""Defines valid input types in Bedrock."""
|
|
42
|
+
TEXT: str
|
|
43
|
+
TOOL_RESULT: str
|
|
44
|
+
TOOL_USE: str
|
|
45
|
+
|
|
46
|
+
class OutputType:
|
|
47
|
+
"""Defines valid output types in Bedrock."""
|
|
48
|
+
CONTENT_BLOCK_START: str
|
|
49
|
+
CONTENT_BLOCK_DELTA: str
|
|
50
|
+
MESSAGE_STOP: str
|
|
51
|
+
METADATA: str
|
|
52
|
+
TEXT: str
|
|
53
|
+
TOOL_USE: str
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
class Key:
|
|
2
|
+
"""Defines valid keys in Google."""
|
|
3
|
+
ARGS: str
|
|
4
|
+
CONTENT: str
|
|
5
|
+
FINISH_MESSAGE: str
|
|
6
|
+
FINISH_REASON: str
|
|
7
|
+
FUNCTION: str
|
|
8
|
+
FUNCTION_CALL: str
|
|
9
|
+
HTTP_OPTIONS: str
|
|
10
|
+
NAME: str
|
|
11
|
+
RETRY_OPTIONS: str
|
|
12
|
+
SYSTEM_INSTRUCTION: str
|
|
13
|
+
THINKING_CONFIG: str
|
|
14
|
+
TIMEOUT: str
|
|
15
|
+
TOOLS: str
|
|
16
|
+
RESPONSE_SCHEMA: str
|
|
17
|
+
RESPONSE_MIME_TYPE: str
|
|
18
|
+
VERTEXAI: str
|
|
19
|
+
|
|
20
|
+
class InputType:
|
|
21
|
+
"""Defines valid input types in Google."""
|
|
22
|
+
APPLICATION_JSON: str
|
|
23
|
+
MODEL: str
|
|
24
|
+
USER: str
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
class Key:
|
|
2
|
+
"""Defines valid keys in LangChain."""
|
|
3
|
+
ARGS: str
|
|
4
|
+
ERROR_CODE: str
|
|
5
|
+
FINISH_REASON: str
|
|
6
|
+
ID: str
|
|
7
|
+
IMAGE_URL: str
|
|
8
|
+
INPUT_TOKENS: str
|
|
9
|
+
MAX_RETRIES: str
|
|
10
|
+
NAME: str
|
|
11
|
+
OUTPUT_TOKENS: str
|
|
12
|
+
PARSED: str
|
|
13
|
+
RAW: str
|
|
14
|
+
TEXT: str
|
|
15
|
+
TIMEOUT: str
|
|
16
|
+
TYPE: str
|
|
17
|
+
URL: str
|
|
18
|
+
|
|
19
|
+
class InputType:
|
|
20
|
+
"""Defines valid input types in LangChain."""
|
|
21
|
+
IMAGE_URL: str
|
|
22
|
+
TEXT: str
|
|
23
|
+
TOOL_CALL: str
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
|
|
3
|
+
class Key:
|
|
4
|
+
"""Defines valid keys in OpenAI."""
|
|
5
|
+
ALLOWED_TOOLS: str
|
|
6
|
+
API_KEY: str
|
|
7
|
+
ARGS: str
|
|
8
|
+
ARGUMENTS: str
|
|
9
|
+
BASE_URL: str
|
|
10
|
+
CALL_ID: str
|
|
11
|
+
CONTAINER: str
|
|
12
|
+
CONTENT: str
|
|
13
|
+
DEFAULT: str
|
|
14
|
+
DEFS: str
|
|
15
|
+
DESCRIPTION: str
|
|
16
|
+
EFFORT: str
|
|
17
|
+
FILE_DATA: str
|
|
18
|
+
FILENAME: str
|
|
19
|
+
FORMAT: str
|
|
20
|
+
ID: str
|
|
21
|
+
IMAGE_URL: str
|
|
22
|
+
INCLUDE: str
|
|
23
|
+
INCOMPLETE_DETAILS: str
|
|
24
|
+
INSTRUCTIONS: str
|
|
25
|
+
JSON_SCHEMA: str
|
|
26
|
+
MAX_RETRIES: str
|
|
27
|
+
NAME: str
|
|
28
|
+
OUTPUT: str
|
|
29
|
+
PARAMETERS: str
|
|
30
|
+
REASON: str
|
|
31
|
+
REASONING: str
|
|
32
|
+
ROLE: str
|
|
33
|
+
SCHEMA: str
|
|
34
|
+
REQUIRE_APPROVAL: str
|
|
35
|
+
REQUIRED: str
|
|
36
|
+
SERVER_LABEL: str
|
|
37
|
+
SERVER_NAME: str
|
|
38
|
+
SERVER_URL: str
|
|
39
|
+
STATUS: str
|
|
40
|
+
STRICT: str
|
|
41
|
+
SUMMARY: str
|
|
42
|
+
TEXT: str
|
|
43
|
+
TIMEOUT: str
|
|
44
|
+
TITLE: str
|
|
45
|
+
TOOL_NAME: str
|
|
46
|
+
TOOLS: str
|
|
47
|
+
TYPE: str
|
|
48
|
+
|
|
49
|
+
class InputType:
|
|
50
|
+
"""Defines valid input types in OpenAI."""
|
|
51
|
+
AUTO: str
|
|
52
|
+
CODE_INTERPRETER: str
|
|
53
|
+
CODE_INTERPRETER_CALL_OUTPUTS: str
|
|
54
|
+
FUNCTION: str
|
|
55
|
+
FUNCTION_CALL: str
|
|
56
|
+
FUNCTION_CALL_OUTPUT: str
|
|
57
|
+
INPUT_FILE: str
|
|
58
|
+
INPUT_IMAGE: str
|
|
59
|
+
INPUT_TEXT: str
|
|
60
|
+
JSON_SCHEMA: str
|
|
61
|
+
MCP: str
|
|
62
|
+
MCP_CALL: str
|
|
63
|
+
NEVER: str
|
|
64
|
+
NULL: str
|
|
65
|
+
OUTPUT_TEXT: str
|
|
66
|
+
REASONING: str
|
|
67
|
+
SUMMARY_TEXT: str
|
|
68
|
+
WEB_SEARCH_PREVIEW: str
|
|
69
|
+
|
|
70
|
+
class OutputType:
|
|
71
|
+
"""Defines valid output types in OpenAI."""
|
|
72
|
+
CODE_INTERPRETER_CALL: str
|
|
73
|
+
CODE_INTERPRETER_CALL_DELTA: str
|
|
74
|
+
CODE_INTERPRETER_CALL_DONE: str
|
|
75
|
+
CODE_INTERPRETER_CALL_IN_PROGRESS: str
|
|
76
|
+
COMPLETED: str
|
|
77
|
+
CONTAINER_FILE_CITATION: str
|
|
78
|
+
FIND_IN_PAGE: str
|
|
79
|
+
FUNCTION_CALL: str
|
|
80
|
+
IMAGE: str
|
|
81
|
+
INCOMPLETE: str
|
|
82
|
+
ITEM_DONE: str
|
|
83
|
+
MCP_CALL: str
|
|
84
|
+
MCP_LIST_TOOLS: str
|
|
85
|
+
MESSAGE: str
|
|
86
|
+
OPEN_PAGE: str
|
|
87
|
+
REASONING: str
|
|
88
|
+
REASONING_ADDED: str
|
|
89
|
+
REASONING_DELTA: str
|
|
90
|
+
REASONING_DONE: str
|
|
91
|
+
REFUSAL: str
|
|
92
|
+
SEARCH: str
|
|
93
|
+
TEXT_DELTA: str
|
|
94
|
+
WEB_SEARCH_CALL: str
|
|
95
|
+
|
|
96
|
+
class ReasoningEffort(StrEnum):
|
|
97
|
+
"""Defines the reasoning effort for reasoning models."""
|
|
98
|
+
HIGH = 'high'
|
|
99
|
+
MEDIUM = 'medium'
|
|
100
|
+
LOW = 'low'
|
|
101
|
+
MINIMAL = 'minimal'
|
|
102
|
+
|
|
103
|
+
class ReasoningSummary(StrEnum):
|
|
104
|
+
"""Defines the reasoning summary for reasoning models."""
|
|
105
|
+
AUTO = 'auto'
|
|
106
|
+
DETAILED = 'detailed'
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
|
|
3
|
+
class Key:
|
|
4
|
+
"""Defines valid keys in OpenAI Chat Completions."""
|
|
5
|
+
API_KEY: str
|
|
6
|
+
ARGUMENTS: str
|
|
7
|
+
BASE_URL: str
|
|
8
|
+
CONTENT: str
|
|
9
|
+
CHOICES: str
|
|
10
|
+
DATA: str
|
|
11
|
+
DEFS: str
|
|
12
|
+
DESCRIPTION: str
|
|
13
|
+
EFFORT: str
|
|
14
|
+
FILE: str
|
|
15
|
+
FILE_DATA: str
|
|
16
|
+
FILENAME: str
|
|
17
|
+
FINISH_REASON: str
|
|
18
|
+
FORMAT: str
|
|
19
|
+
FUNCTION: str
|
|
20
|
+
ID: str
|
|
21
|
+
IMAGE_URL: str
|
|
22
|
+
INPUT_AUDIO: str
|
|
23
|
+
JSON_SCHEMA: str
|
|
24
|
+
MAX_RETRIES: str
|
|
25
|
+
MESSAGE: str
|
|
26
|
+
NAME: str
|
|
27
|
+
PARAMETERS: str
|
|
28
|
+
RESPONSE_FORMAT: str
|
|
29
|
+
ROLE: str
|
|
30
|
+
SCHEMA: str
|
|
31
|
+
STRICT: str
|
|
32
|
+
TEXT: str
|
|
33
|
+
TIMEOUT: str
|
|
34
|
+
TITLE: str
|
|
35
|
+
TOOLS: str
|
|
36
|
+
TOOL_CALLS: str
|
|
37
|
+
TOOL_CALL_ID: str
|
|
38
|
+
TYPE: str
|
|
39
|
+
URL: str
|
|
40
|
+
USAGE: str
|
|
41
|
+
REASONING: str
|
|
42
|
+
REASONING_CONTENT: str
|
|
43
|
+
REASONING_EFFORT: str
|
|
44
|
+
SUMMARY: str
|
|
45
|
+
|
|
46
|
+
class InputType:
|
|
47
|
+
"""Defines valid input types in OpenAI Chat Completions."""
|
|
48
|
+
FILE: str
|
|
49
|
+
FUNCTION: str
|
|
50
|
+
IMAGE_URL: str
|
|
51
|
+
INPUT_AUDIO: str
|
|
52
|
+
JSON_SCHEMA: str
|
|
53
|
+
TEXT: str
|
|
54
|
+
TOOL: str
|
|
55
|
+
REASONING: str
|
|
56
|
+
SUMMARY_TEXT: str
|
|
57
|
+
|
|
58
|
+
class ReasoningEffort(StrEnum):
|
|
59
|
+
"""Defines the reasoning effort for reasoning models."""
|
|
60
|
+
HIGH = 'high'
|
|
61
|
+
MEDIUM = 'medium'
|
|
62
|
+
LOW = 'low'
|
|
@@ -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,31 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
|
|
3
|
+
class Key:
|
|
4
|
+
"""Defines valid keys in xAI."""
|
|
5
|
+
ARGUMENTS: str
|
|
6
|
+
CHANNEL_OPTIONS: str
|
|
7
|
+
CITATIONS: str
|
|
8
|
+
COMPLETION_TOKENS: str
|
|
9
|
+
CONTENT: str
|
|
10
|
+
FINISH_REASON: str
|
|
11
|
+
FUNCTION: str
|
|
12
|
+
ID: str
|
|
13
|
+
NAME: str
|
|
14
|
+
ON: str
|
|
15
|
+
PROMPT_TOKENS: str
|
|
16
|
+
REASONING_CONTENT: str
|
|
17
|
+
REASONING_EFFORT: str
|
|
18
|
+
RESPONSE_FORMAT: str
|
|
19
|
+
SEARCH_PARAMETERS: str
|
|
20
|
+
TIMEOUT: str
|
|
21
|
+
TOOL_CALLS: str
|
|
22
|
+
TOOLS: str
|
|
23
|
+
TYPE: str
|
|
24
|
+
URL: str
|
|
25
|
+
URL_CITATION: str
|
|
26
|
+
USAGE: str
|
|
27
|
+
|
|
28
|
+
class ReasoningEffort(StrEnum):
|
|
29
|
+
"""Defines the reasoning effort for reasoning models."""
|
|
30
|
+
HIGH = 'high'
|
|
31
|
+
LOW = 'low'
|