gllm-inference-binary 0.5.9b1__cp312-cp312-macosx_11_0_universal2.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.

Potentially problematic release.


This version of gllm-inference-binary might be problematic. Click here for more details.

Files changed (105) hide show
  1. gllm_inference/__init__.pyi +0 -0
  2. gllm_inference/builder/__init__.pyi +6 -0
  3. gllm_inference/builder/build_em_invoker.pyi +137 -0
  4. gllm_inference/builder/build_lm_invoker.pyi +161 -0
  5. gllm_inference/builder/build_lm_request_processor.pyi +93 -0
  6. gllm_inference/builder/build_output_parser.pyi +29 -0
  7. gllm_inference/catalog/__init__.pyi +4 -0
  8. gllm_inference/catalog/catalog.pyi +121 -0
  9. gllm_inference/catalog/lm_request_processor_catalog.pyi +112 -0
  10. gllm_inference/catalog/prompt_builder_catalog.pyi +82 -0
  11. gllm_inference/constants.pyi +10 -0
  12. gllm_inference/em_invoker/__init__.pyi +10 -0
  13. gllm_inference/em_invoker/azure_openai_em_invoker.pyi +88 -0
  14. gllm_inference/em_invoker/bedrock_em_invoker.pyi +106 -0
  15. gllm_inference/em_invoker/em_invoker.pyi +90 -0
  16. gllm_inference/em_invoker/google_em_invoker.pyi +129 -0
  17. gllm_inference/em_invoker/langchain/__init__.pyi +3 -0
  18. gllm_inference/em_invoker/langchain/em_invoker_embeddings.pyi +84 -0
  19. gllm_inference/em_invoker/langchain_em_invoker.pyi +46 -0
  20. gllm_inference/em_invoker/openai_compatible_em_invoker.pyi +96 -0
  21. gllm_inference/em_invoker/openai_em_invoker.pyi +90 -0
  22. gllm_inference/em_invoker/schema/__init__.pyi +0 -0
  23. gllm_inference/em_invoker/schema/bedrock.pyi +22 -0
  24. gllm_inference/em_invoker/schema/google.pyi +9 -0
  25. gllm_inference/em_invoker/schema/langchain.pyi +5 -0
  26. gllm_inference/em_invoker/schema/openai.pyi +7 -0
  27. gllm_inference/em_invoker/schema/openai_compatible.pyi +7 -0
  28. gllm_inference/em_invoker/schema/twelvelabs.pyi +17 -0
  29. gllm_inference/em_invoker/schema/voyage.pyi +15 -0
  30. gllm_inference/em_invoker/twelevelabs_em_invoker.pyi +101 -0
  31. gllm_inference/em_invoker/voyage_em_invoker.pyi +104 -0
  32. gllm_inference/exceptions/__init__.pyi +4 -0
  33. gllm_inference/exceptions/error_parser.pyi +41 -0
  34. gllm_inference/exceptions/exceptions.pyi +132 -0
  35. gllm_inference/exceptions/provider_error_map.pyi +23 -0
  36. gllm_inference/lm_invoker/__init__.pyi +12 -0
  37. gllm_inference/lm_invoker/anthropic_lm_invoker.pyi +275 -0
  38. gllm_inference/lm_invoker/azure_openai_lm_invoker.pyi +252 -0
  39. gllm_inference/lm_invoker/bedrock_lm_invoker.pyi +234 -0
  40. gllm_inference/lm_invoker/datasaur_lm_invoker.pyi +166 -0
  41. gllm_inference/lm_invoker/google_lm_invoker.pyi +317 -0
  42. gllm_inference/lm_invoker/langchain_lm_invoker.pyi +260 -0
  43. gllm_inference/lm_invoker/litellm_lm_invoker.pyi +248 -0
  44. gllm_inference/lm_invoker/lm_invoker.pyi +152 -0
  45. gllm_inference/lm_invoker/openai_compatible_lm_invoker.pyi +265 -0
  46. gllm_inference/lm_invoker/openai_lm_invoker.pyi +362 -0
  47. gllm_inference/lm_invoker/schema/__init__.pyi +0 -0
  48. gllm_inference/lm_invoker/schema/anthropic.pyi +50 -0
  49. gllm_inference/lm_invoker/schema/bedrock.pyi +53 -0
  50. gllm_inference/lm_invoker/schema/datasaur.pyi +12 -0
  51. gllm_inference/lm_invoker/schema/google.pyi +24 -0
  52. gllm_inference/lm_invoker/schema/langchain.pyi +23 -0
  53. gllm_inference/lm_invoker/schema/openai.pyi +91 -0
  54. gllm_inference/lm_invoker/schema/openai_compatible.pyi +60 -0
  55. gllm_inference/lm_invoker/schema/xai.pyi +31 -0
  56. gllm_inference/lm_invoker/xai_lm_invoker.pyi +305 -0
  57. gllm_inference/model/__init__.pyi +9 -0
  58. gllm_inference/model/em/__init__.pyi +0 -0
  59. gllm_inference/model/em/google_em.pyi +16 -0
  60. gllm_inference/model/em/openai_em.pyi +15 -0
  61. gllm_inference/model/em/twelvelabs_em.pyi +13 -0
  62. gllm_inference/model/em/voyage_em.pyi +20 -0
  63. gllm_inference/model/lm/__init__.pyi +0 -0
  64. gllm_inference/model/lm/anthropic_lm.pyi +20 -0
  65. gllm_inference/model/lm/google_lm.pyi +17 -0
  66. gllm_inference/model/lm/openai_lm.pyi +27 -0
  67. gllm_inference/output_parser/__init__.pyi +3 -0
  68. gllm_inference/output_parser/json_output_parser.pyi +60 -0
  69. gllm_inference/output_parser/output_parser.pyi +27 -0
  70. gllm_inference/prompt_builder/__init__.pyi +3 -0
  71. gllm_inference/prompt_builder/prompt_builder.pyi +56 -0
  72. gllm_inference/prompt_formatter/__init__.pyi +7 -0
  73. gllm_inference/prompt_formatter/agnostic_prompt_formatter.pyi +49 -0
  74. gllm_inference/prompt_formatter/huggingface_prompt_formatter.pyi +55 -0
  75. gllm_inference/prompt_formatter/llama_prompt_formatter.pyi +59 -0
  76. gllm_inference/prompt_formatter/mistral_prompt_formatter.pyi +53 -0
  77. gllm_inference/prompt_formatter/openai_prompt_formatter.pyi +35 -0
  78. gllm_inference/prompt_formatter/prompt_formatter.pyi +30 -0
  79. gllm_inference/request_processor/__init__.pyi +4 -0
  80. gllm_inference/request_processor/lm_request_processor.pyi +101 -0
  81. gllm_inference/request_processor/uses_lm_mixin.pyi +130 -0
  82. gllm_inference/schema/__init__.pyi +14 -0
  83. gllm_inference/schema/attachment.pyi +88 -0
  84. gllm_inference/schema/code_exec_result.pyi +14 -0
  85. gllm_inference/schema/config.pyi +15 -0
  86. gllm_inference/schema/enums.pyi +29 -0
  87. gllm_inference/schema/lm_output.pyi +36 -0
  88. gllm_inference/schema/message.pyi +52 -0
  89. gllm_inference/schema/model_id.pyi +147 -0
  90. gllm_inference/schema/reasoning.pyi +15 -0
  91. gllm_inference/schema/token_usage.pyi +75 -0
  92. gllm_inference/schema/tool_call.pyi +14 -0
  93. gllm_inference/schema/tool_result.pyi +11 -0
  94. gllm_inference/schema/type_alias.pyi +11 -0
  95. gllm_inference/utils/__init__.pyi +5 -0
  96. gllm_inference/utils/io_utils.pyi +26 -0
  97. gllm_inference/utils/langchain.pyi +30 -0
  98. gllm_inference/utils/validation.pyi +12 -0
  99. gllm_inference.build/.gitignore +1 -0
  100. gllm_inference.cpython-312-darwin.so +0 -0
  101. gllm_inference.pyi +123 -0
  102. gllm_inference_binary-0.5.9b1.dist-info/METADATA +71 -0
  103. gllm_inference_binary-0.5.9b1.dist-info/RECORD +105 -0
  104. gllm_inference_binary-0.5.9b1.dist-info/WHEEL +6 -0
  105. gllm_inference_binary-0.5.9b1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,362 @@
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 INVOKER_PROPAGATED_MAX_RETRIES as INVOKER_PROPAGATED_MAX_RETRIES
6
+ from gllm_inference.lm_invoker.lm_invoker import BaseLMInvoker as BaseLMInvoker
7
+ from gllm_inference.lm_invoker.schema.openai import InputType as InputType, Key as Key, OutputType as OutputType, ReasoningEffort as ReasoningEffort, ReasoningSummary as ReasoningSummary
8
+ from gllm_inference.schema import Attachment as Attachment, AttachmentType as AttachmentType, CodeExecResult as CodeExecResult, EmitDataType as EmitDataType, LMOutput as LMOutput, Message as Message, MessageRole as MessageRole, ModelId as ModelId, ModelProvider as ModelProvider, Reasoning as Reasoning, ResponseSchema as ResponseSchema, TokenUsage as TokenUsage, ToolCall as ToolCall, ToolResult as ToolResult
9
+ from gllm_inference.utils import validate_string_enum as validate_string_enum
10
+ from langchain_core.tools import Tool as LangChainTool
11
+ from typing import Any
12
+
13
+ SUPPORTED_ATTACHMENTS: Incomplete
14
+
15
+ class OpenAILMInvoker(BaseLMInvoker):
16
+ '''A language model invoker to interact with OpenAI language models.
17
+
18
+ Attributes:
19
+ model_id (str): The model ID of the language model.
20
+ model_provider (str): The provider of the language model.
21
+ model_name (str): The name of the language model.
22
+ client (AsyncOpenAI): The OpenAI client instance.
23
+ default_hyperparameters (dict[str, Any]): Default hyperparameters for invoking the model.
24
+ tools (list[Tool]): The list of tools provided to the model to enable tool calling.
25
+ response_schema (ResponseSchema | None): The schema of the response. If provided, the model will output a
26
+ structured response as defined by the schema. Supports both Pydantic BaseModel and JSON schema dictionary.
27
+ output_analytics (bool): Whether to output the invocation analytics.
28
+ retry_config (RetryConfig): The retry configuration for the language model.
29
+ reasoning_effort (ReasoningEffort | None): The reasoning effort for reasoning models. Not allowed
30
+ for non-reasoning models. If None, the model will perform medium reasoning effort.
31
+ reasoning_summary (ReasoningSummary | None): The reasoning summary level for reasoning models. Not allowed
32
+ for non-reasoning models. If None, no summary will be generated.
33
+ code_interpreter (bool): Whether to enable the code interpreter.
34
+ web_search (bool): Whether to enable the web search.
35
+
36
+ Basic usage:
37
+ The `OpenAILMInvoker` can be used as follows:
38
+ ```python
39
+ lm_invoker = OpenAILMInvoker(model_name="gpt-4.1-nano")
40
+ result = await lm_invoker.invoke("Hi there!")
41
+ ```
42
+
43
+ Input types:
44
+ The `OpenAILMInvoker` supports the following input types: text, document, and image.
45
+ Non-text inputs can be passed as an `Attachment` object with the `user` role.
46
+
47
+ Usage example:
48
+ ```python
49
+ text = "What animal is in this image?"
50
+ image = Attachment.from_path("path/to/local/image.png")
51
+ result = await lm_invoker.invoke([text, image])
52
+ ```
53
+
54
+ Tool calling:
55
+ Tool calling is a feature that allows the language model to call tools to perform tasks.
56
+ Tools can be passed to the via the `tools` parameter as a list of `Tool` objects.
57
+ When tools are provided and the model decides to call a tool, the tool calls are stored in the
58
+ `tool_calls` attribute in the output.
59
+
60
+ Usage example:
61
+ ```python
62
+ lm_invoker = OpenAILMInvoker(..., tools=[tool_1, tool_2])
63
+ ```
64
+
65
+ Output example:
66
+ ```python
67
+ LMOutput(
68
+ response="Let me call the tools...",
69
+ tool_calls=[
70
+ ToolCall(id="123", name="tool_1", args={"key": "value"}),
71
+ ToolCall(id="456", name="tool_2", args={"key": "value"}),
72
+ ]
73
+ )
74
+ ```
75
+
76
+ Structured output:
77
+ Structured output is a feature that allows the language model to output a structured response.
78
+ This feature can be enabled by providing a schema to the `response_schema` parameter.
79
+
80
+ The schema must be either a JSON schema dictionary or a Pydantic BaseModel class.
81
+ If JSON schema is used, it must be compatible with Pydantic\'s JSON schema, especially for complex schemas.
82
+ For this reason, it is recommended to create the JSON schema using Pydantic\'s `model_json_schema` method.
83
+
84
+ The language model also doesn\'t need to stream anything when structured output is enabled. Thus, standard
85
+ invocation will be performed regardless of whether the `event_emitter` parameter is provided or not.
86
+
87
+ When enabled, the structured output is stored in the `structured_output` attribute in the output.
88
+ 1. If the schema is a JSON schema dictionary, the structured output is a dictionary.
89
+ 2. If the schema is a Pydantic BaseModel class, the structured output is a Pydantic model.
90
+
91
+ # Example 1: Using a JSON schema dictionary
92
+ Usage example:
93
+ ```python
94
+ schema = {
95
+ "title": "Animal",
96
+ "description": "A description of an animal.",
97
+ "properties": {
98
+ "color": {"title": "Color", "type": "string"},
99
+ "name": {"title": "Name", "type": "string"},
100
+ },
101
+ "required": ["name", "color"],
102
+ "type": "object",
103
+ }
104
+ lm_invoker = OpenAILMInvoker(..., response_schema=schema)
105
+ ```
106
+ Output example:
107
+ ```python
108
+ LMOutput(structured_output={"name": "Golden retriever", "color": "Golden"})
109
+ ```
110
+
111
+ # Example 2: Using a Pydantic BaseModel class
112
+ Usage example:
113
+ ```python
114
+ class Animal(BaseModel):
115
+ name: str
116
+ color: str
117
+
118
+ lm_invoker = OpenAILMInvoker(..., response_schema=Animal)
119
+ ```
120
+ Output example:
121
+ ```python
122
+ LMOutput(structured_output=Animal(name="Golden retriever", color="Golden"))
123
+ ```
124
+
125
+ Analytics tracking:
126
+ Analytics tracking is a feature that allows the module to output additional information about the invocation.
127
+ This feature can be enabled by setting the `output_analytics` parameter to `True`.
128
+ When enabled, the following attributes will be stored in the output:
129
+ 1. `token_usage`: The token usage.
130
+ 2. `duration`: The duration in seconds.
131
+ 3. `finish_details`: The details about how the generation finished.
132
+
133
+ Output example:
134
+ ```python
135
+ LMOutput(
136
+ response="Golden retriever is a good dog breed.",
137
+ token_usage=TokenUsage(input_tokens=100, output_tokens=50),
138
+ duration=0.729,
139
+ finish_details={"status": "completed", "incomplete_details": {"reason": None}},
140
+ )
141
+ ```
142
+
143
+ Retry and timeout:
144
+ The `OpenAILMInvoker` supports retry and timeout configuration.
145
+ By default, the max retries is set to 0 and the timeout is set to 30.0 seconds.
146
+ They can be customized by providing a custom `RetryConfig` object to the `retry_config` parameter.
147
+
148
+ Retry config examples:
149
+ ```python
150
+ retry_config = RetryConfig(max_retries=0, timeout=0.0) # No retry, no timeout
151
+ retry_config = RetryConfig(max_retries=0, timeout=10.0) # No retry, 10.0 seconds timeout
152
+ retry_config = RetryConfig(max_retries=5, timeout=0.0) # 5 max retries, no timeout
153
+ retry_config = RetryConfig(max_retries=5, timeout=10.0) # 5 max retries, 10.0 seconds timeout
154
+ ```
155
+
156
+ Usage example:
157
+ ```python
158
+ lm_invoker = OpenAILMInvoker(..., retry_config=retry_config)
159
+ ```
160
+
161
+ Reasoning:
162
+ OpenAI\'s GPT-5 models and o-series models are classified as reasoning models. Reasoning models think before
163
+ they answer, producing a long internal chain of thought before responding to the user. Reasoning models
164
+ excel in complex problem solving, coding, scientific reasoning, and multi-step planning for agentic workflows.
165
+
166
+ The reasoning effort of reasoning models can be set via the `reasoning_effort` parameter. This parameter
167
+ will guide the models on how many reasoning tokens it should generate before creating a response.
168
+ Available options include:
169
+ 1. "minimal": Favors the least amount of reasoning, only supported for GPT-5 models onwards.
170
+ 2. "low": Favors speed and economical token usage.
171
+ 3. "medium": Favors a balance between speed and reasoning accuracy.
172
+ 4. "high": Favors more complete reasoning at the cost of more tokens generated and slower responses.
173
+ When not set, the reasoning effort will be equivalent to `medium` by default.
174
+
175
+ OpenAI doesn\'t expose the raw reasoning tokens. However, the summary of the reasoning tokens can still be
176
+ generated. The summary level can be set via the `reasoning_summary` parameter. Available options include:
177
+ 1. "auto": The model decides the summary level automatically.
178
+ 2. "detailed": The model will generate a detailed summary of the reasoning tokens.
179
+ Reasoning summary is not compatible with tool calling.
180
+ When enabled, the reasoning summary will be stored in the `reasoning` attribute in the output.
181
+
182
+ Output example:
183
+ ```python
184
+ LMOutput(
185
+ response="Golden retriever is a good dog breed.",
186
+ reasoning=[Reasoning(id="x", reasoning="Let me think about it...")],
187
+ )
188
+ ```
189
+
190
+ When streaming is enabled along with reasoning summary, the reasoning summary token will be streamed with the
191
+ `EventType.DATA` event type.
192
+
193
+ Streaming output example:
194
+ ```python
195
+ {"type": "data", "value": \'{"data_type": "thinking_start", "data_value": ""}\', ...}
196
+ {"type": "data", "value": \'{"data_type": "thinking", "data_value": "Let me think "}\', ...}
197
+ {"type": "data", "value": \'{"data_type": "thinking", "data_value": "about it..."}\', ...}
198
+ {"type": "data", "value": \'{"data_type": "thinking_end", "data_value": ""}\', ...}
199
+ {"type": "response", "value": "Golden retriever ", ...}
200
+ {"type": "response", "value": "is a good dog breed.", ...}
201
+ ```
202
+
203
+ Setting reasoning-related parameters for non-reasoning models will raise an error.
204
+
205
+ Code interpreter:
206
+ The code interpreter is a feature that allows the language model to write and run Python code in a
207
+ sandboxed environment to solve complex problems in domains like data analysis, coding, and math.
208
+ This feature can be enabled by setting the `code_interpreter` parameter to `True`.
209
+
210
+ Usage example:
211
+ ```python
212
+ lm_invoker = OpenAILMInvoker(..., code_interpreter=True)
213
+ ```
214
+
215
+ When code interpreter is enabled, it is highly recommended to instruct the model to use the "python tool"
216
+ in the system message, as "python tool" is the term recognized by the model to refer to the code interpreter.
217
+
218
+ Messages example:
219
+ ```python
220
+ messages = [
221
+ Message(
222
+ role=MessageRole.SYSTEM,
223
+ contents=["You are a data analyst. Use the python tool to generate a file."],
224
+ ),
225
+ Message(
226
+ role=MessageRole.USER,
227
+ contents=["Show an histogram of the following data: [1, 2, 1, 4, 1, 2, 4, 2, 3, 1]"],
228
+ ),
229
+ ]
230
+ ```
231
+
232
+ When code interpreter is enabled, the code execution results are stored in the `code_exec_results`
233
+ attribute in the output.
234
+
235
+ Output example:
236
+ ```python
237
+ LMOutput(
238
+ response="The histogram is attached.",
239
+ code_exec_results=[
240
+ CodeExecResult(
241
+ id="123",
242
+ code="import matplotlib.pyplot as plt...",
243
+ output=[Attachment(data=b"...", mime_type="image/png")],
244
+ ),
245
+ ],
246
+ )
247
+ ```
248
+
249
+ When streaming is enabled, the executed code will be streamed with the `EventType.DATA` event type.
250
+ Streaming output example:
251
+ ```python
252
+ {"type": "data", "value": \'{"data_type": "code_start", "data_value": ""}\', ...}
253
+ {"type": "data", "value": \'{"data_type": "code", "data_value": "import matplotlib"}\', ...}
254
+ {"type": "data", "value": \'{"data_type": "code", "data_value": ".pyplot as plt..."}\', ...}
255
+ {"type": "data", "value": \'{"data_type": "code_end", "data_value": ""}\', ...}
256
+ {"type": "response", "value": "The histogram ", ...}
257
+ {"type": "response", "value": "is attached.", ...}
258
+ ```
259
+
260
+ Web search:
261
+ The web search is a feature that allows the language model to search the web for relevant information.
262
+ This feature can be enabled by setting the `web_search` parameter to `True`.
263
+
264
+ Usage example:
265
+ ```python
266
+ lm_invoker = OpenAILMInvoker(..., web_search=True)
267
+ ```
268
+
269
+ When web search is enabled, the language model will search the web for relevant information and may cite the
270
+ relevant sources. The citations will be stored as `Chunk` objects in the `citations` attribute in the output.
271
+ The content of the `Chunk` object is the type of the citation, e.g. "url_citation".
272
+
273
+ Output example:
274
+ ```python
275
+ LMOutput(
276
+ response="The winner of the match is team A ([Example title](https://www.example.com)).",
277
+ citations=[
278
+ Chunk(
279
+ id="123",
280
+ content="url_citation",
281
+ metadata={
282
+ "start_index": 164,
283
+ "end_index": 275,
284
+ "title": "Example title",
285
+ "url": "https://www.example.com",
286
+ "type": "url_citation",
287
+ },
288
+ ),
289
+ ],
290
+ )
291
+ ```
292
+
293
+ When streaming is enabled, the web search activities will be streamed with the `EventType.DATA` event type.
294
+ Streaming output example:
295
+ ```python
296
+ {"type": "data", "value": \'{"data_type": "activity", "data_value": "{\\"query\\": \\"search query\\"}", ...}\', ...}
297
+ {"type": "response", "value": "The winner of the match ", ...}
298
+ {"type": "response", "value": "is team A ([Example title](https://www.example.com)).", ...}
299
+ ```
300
+
301
+ Output types:
302
+ The output of the `OpenAILMInvoker` can either be:
303
+ 1. `str`: The text response if no additional output is needed.
304
+ 2. `LMOutput`: A Pydantic model with the following attributes if any additional output is needed:
305
+ 2.1. response (str): The text response.
306
+ 2.2. tool_calls (list[ToolCall]): The tool calls, if the `tools` parameter is defined and the language
307
+ model decides to invoke tools. Defaults to an empty list.
308
+ 2.3. structured_output (dict[str, Any] | BaseModel | None): The structured output, if the `response_schema`
309
+ parameter is defined. Defaults to None.
310
+ 2.4. token_usage (TokenUsage | None): The token usage analytics, if the `output_analytics` parameter is
311
+ set to `True`. Defaults to None.
312
+ 2.5. duration (float | None): The duration of the invocation in seconds, if the `output_analytics`
313
+ parameter is set to `True`. Defaults to None.
314
+ 2.6. finish_details (dict[str, Any] | None): The details about how the generation finished, if the
315
+ `output_analytics` parameter is set to `True`. Defaults to None.
316
+ 2.7. reasoning (list[Reasoning]): The reasoning objects, if the `reasoning_summary` parameter is provided
317
+ for reasoning models. Defaults to an empty list.
318
+ 2.8. citations (list[Chunk]): The citations, if the web_search is enabled and the language model decides
319
+ to cite the relevant sources. Defaults to an empty list.
320
+ 2.9. code_exec_results (list[CodeExecResult]): The code execution results, if the code interpreter is
321
+ enabled and the language model decides to execute any codes. Defaults to an empty list.
322
+ '''
323
+ client: Incomplete
324
+ 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, reasoning_effort: ReasoningEffort | None = None, reasoning_summary: ReasoningSummary | None = None, code_interpreter: bool = False, web_search: bool = False) -> None:
325
+ """Initializes a new instance of the OpenAILMInvoker class.
326
+
327
+ Args:
328
+ model_name (str): The name of the OpenAI model.
329
+ api_key (str | None, optional): The API key for authenticating with OpenAI. Defaults to None, in which
330
+ case the `OPENAI_API_KEY` environment variable will be used.
331
+ model_kwargs (dict[str, Any] | None, optional): Additional model parameters. Defaults to None.
332
+ default_hyperparameters (dict[str, Any] | None, optional): Default hyperparameters for invoking the model.
333
+ Defaults to None.
334
+ tools (list[Tool | LangChainTool] | None, optional): Tools provided to the model to enable tool calling.
335
+ Defaults to None, in which case an empty list is used.
336
+ response_schema (ResponseSchema | None, optional): The schema of the response. If provided, the model will
337
+ output a structured response as defined by the schema. Supports both Pydantic BaseModel and JSON schema
338
+ dictionary. Defaults to None.
339
+ output_analytics (bool, optional): Whether to output the invocation analytics. Defaults to False.
340
+ retry_config (RetryConfig | None, optional): The retry configuration for the language model.
341
+ Defaults to None, in which case a default config with no retry and 30.0 seconds timeout will be used.
342
+ reasoning_effort (ReasoningEffort | None, optional): The reasoning effort for reasoning models. Not allowed
343
+ for non-reasoning models. If None, the model will perform medium reasoning effort. Defaults to None.
344
+ reasoning_summary (ReasoningSummary | None, optional): The reasoning summary level for reasoning models.
345
+ Not allowed for non-reasoning models. If None, no summary will be generated. Defaults to None.
346
+ code_interpreter (bool, optional): Whether to enable the code interpreter. Defaults to False.
347
+ web_search (bool, optional): Whether to enable the web search. Defaults to False.
348
+
349
+ Raises:
350
+ ValueError:
351
+ 1. `reasoning_effort` is provided, but is not a valid ReasoningEffort.
352
+ 2. `reasoning_summary` is provided, but is not a valid ReasoningSummary.
353
+ """
354
+ def set_response_schema(self, response_schema: ResponseSchema | None) -> None:
355
+ """Sets the response schema for the OpenAI language model.
356
+
357
+ This method sets the response schema for the OpenAI language model. Any existing response schema will be
358
+ replaced.
359
+
360
+ Args:
361
+ response_schema (ResponseSchema | None): The response schema to be used.
362
+ """
File without changes
@@ -0,0 +1,50 @@
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
+ STOP_REASON: str
19
+ SYSTEM: str
20
+ TIMEOUT: str
21
+ THINKING: str
22
+ TOOLS: str
23
+ TOOL_CHOICE: str
24
+ TOOL_USE_ID: str
25
+ TEXT: str
26
+ TYPE: str
27
+
28
+ class InputType:
29
+ """Defines valid input types in Anthropic."""
30
+ BASE64: str
31
+ ENABLED: str
32
+ REDACTED_THINKING: str
33
+ TEXT: str
34
+ THINKING: str
35
+ TOOL: str
36
+ TOOL_RESULT: str
37
+ TOOL_USE: str
38
+
39
+ class OutputType:
40
+ """Defines valid output types in Anthropic."""
41
+ CONTENT_BLOCK_DELTA: str
42
+ CONTENT_BLOCK_START: str
43
+ CONTENT_BLOCK_STOP: str
44
+ MESSAGE_STOP: str
45
+ REDACTED_THINKING: str
46
+ TEXT: str
47
+ TEXT_DELTA: str
48
+ THINKING: str
49
+ THINKING_DELTA: str
50
+ 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,12 @@
1
+ class Key:
2
+ """Defines valid keys in Datasaur."""
3
+ CONTEXTS: str
4
+ MAX_RETRIES: str
5
+ NAME: str
6
+ TIMEOUT: str
7
+ TYPE: str
8
+ URL: str
9
+
10
+ class InputType:
11
+ """Defines valid input types in Datasaur."""
12
+ URL: 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,91 @@
1
+ from enum import StrEnum
2
+
3
+ class Key:
4
+ """Defines valid keys in OpenAI."""
5
+ ARGUMENTS: str
6
+ CALL_ID: str
7
+ CONTAINER: str
8
+ CONTENT: str
9
+ DEFAULT: str
10
+ DEFS: str
11
+ DESCRIPTION: str
12
+ EFFORT: str
13
+ FILE_DATA: str
14
+ FILENAME: str
15
+ FORMAT: str
16
+ ID: str
17
+ IMAGE_URL: str
18
+ INCLUDE: str
19
+ INCOMPLETE_DETAILS: str
20
+ INSTRUCTIONS: str
21
+ JSON_SCHEMA: str
22
+ MAX_RETRIES: str
23
+ NAME: str
24
+ OUTPUT: str
25
+ PARAMETERS: str
26
+ REASON: str
27
+ REASONING: str
28
+ ROLE: str
29
+ SCHEMA: str
30
+ REQUIRED: str
31
+ STATUS: str
32
+ STRICT: str
33
+ SUMMARY: str
34
+ TEXT: str
35
+ TIMEOUT: str
36
+ TITLE: str
37
+ TOOLS: str
38
+ TYPE: str
39
+
40
+ class InputType:
41
+ """Defines valid input types in OpenAI."""
42
+ AUTO: str
43
+ CODE_INTERPRETER: str
44
+ CODE_INTERPRETER_CALL_OUTPUTS: str
45
+ FUNCTION: str
46
+ FUNCTION_CALL: str
47
+ FUNCTION_CALL_OUTPUT: str
48
+ INPUT_FILE: str
49
+ INPUT_IMAGE: str
50
+ INPUT_TEXT: str
51
+ JSON_SCHEMA: str
52
+ NULL: str
53
+ OUTPUT_TEXT: str
54
+ REASONING: str
55
+ SUMMARY_TEXT: str
56
+
57
+ class OutputType:
58
+ """Defines valid output types in OpenAI."""
59
+ CODE_INTERPRETER_CALL: str
60
+ CODE_INTERPRETER_CALL_DELTA: str
61
+ CODE_INTERPRETER_CALL_DONE: str
62
+ CODE_INTERPRETER_CALL_IN_PROGRESS: str
63
+ COMPLETED: str
64
+ CONTAINER_FILE_CITATION: str
65
+ FIND_IN_PAGE: str
66
+ FUNCTION_CALL: str
67
+ IMAGE: str
68
+ INCOMPLETE: str
69
+ ITEM_DONE: str
70
+ MESSAGE: str
71
+ OPEN_PAGE: str
72
+ REASONING: str
73
+ REASONING_ADDED: str
74
+ REASONING_DELTA: str
75
+ REASONING_DONE: str
76
+ REFUSAL: str
77
+ SEARCH: str
78
+ TEXT_DELTA: str
79
+ WEB_SEARCH_CALL: str
80
+
81
+ class ReasoningEffort(StrEnum):
82
+ """Defines the reasoning effort for reasoning models."""
83
+ HIGH = 'high'
84
+ MEDIUM = 'medium'
85
+ LOW = 'low'
86
+ MINIMAL = 'minimal'
87
+
88
+ class ReasoningSummary(StrEnum):
89
+ """Defines the reasoning summary for reasoning models."""
90
+ AUTO = 'auto'
91
+ DETAILED = 'detailed'
@@ -0,0 +1,60 @@
1
+ from enum import StrEnum
2
+
3
+ class Key:
4
+ """Defines valid keys in OpenAI compatible models."""
5
+ ARGUMENTS: str
6
+ CONTENT: str
7
+ CHOICES: str
8
+ DATA: str
9
+ DEFS: str
10
+ DESCRIPTION: str
11
+ EFFORT: str
12
+ FILE: str
13
+ FILE_DATA: str
14
+ FILENAME: str
15
+ FINISH_REASON: str
16
+ FORMAT: str
17
+ FUNCTION: str
18
+ ID: str
19
+ IMAGE_URL: str
20
+ INPUT_AUDIO: str
21
+ JSON_SCHEMA: str
22
+ MAX_RETRIES: str
23
+ MESSAGE: str
24
+ NAME: str
25
+ PARAMETERS: str
26
+ RESPONSE_FORMAT: str
27
+ ROLE: str
28
+ SCHEMA: str
29
+ STRICT: str
30
+ TEXT: str
31
+ TIMEOUT: str
32
+ TITLE: str
33
+ TOOLS: str
34
+ TOOL_CALLS: str
35
+ TOOL_CALL_ID: str
36
+ TYPE: str
37
+ URL: str
38
+ USAGE: str
39
+ REASONING: str
40
+ REASONING_CONTENT: str
41
+ REASONING_EFFORT: str
42
+ SUMMARY: str
43
+
44
+ class InputType:
45
+ """Defines valid input types in OpenAI compatible models."""
46
+ FILE: str
47
+ FUNCTION: str
48
+ IMAGE_URL: str
49
+ INPUT_AUDIO: str
50
+ JSON_SCHEMA: str
51
+ TEXT: str
52
+ TOOL: str
53
+ REASONING: str
54
+ SUMMARY_TEXT: str
55
+
56
+ class ReasoningEffort(StrEnum):
57
+ """Defines the reasoning effort for reasoning models."""
58
+ HIGH = 'high'
59
+ MEDIUM = 'medium'
60
+ LOW = 'low'