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.
- 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 +222 -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 +12 -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 +127 -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 +15 -0
- gllm_inference/lm_invoker/anthropic_lm_invoker.pyi +320 -0
- gllm_inference/lm_invoker/azure_openai_lm_invoker.pyi +237 -0
- gllm_inference/lm_invoker/batch/__init__.pyi +3 -0
- gllm_inference/lm_invoker/batch/batch_operations.pyi +128 -0
- gllm_inference/lm_invoker/bedrock_lm_invoker.pyi +212 -0
- gllm_inference/lm_invoker/datasaur_lm_invoker.pyi +157 -0
- gllm_inference/lm_invoker/google_lm_invoker.pyi +421 -0
- gllm_inference/lm_invoker/langchain_lm_invoker.pyi +239 -0
- gllm_inference/lm_invoker/litellm_lm_invoker.pyi +224 -0
- gllm_inference/lm_invoker/lm_invoker.pyi +183 -0
- gllm_inference/lm_invoker/openai_chat_completions_lm_invoker.pyi +252 -0
- gllm_inference/lm_invoker/openai_compatible_lm_invoker.pyi +52 -0
- gllm_inference/lm_invoker/openai_lm_invoker.pyi +437 -0
- gllm_inference/lm_invoker/portkey_lm_invoker.pyi +296 -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 +36 -0
- gllm_inference/lm_invoker/schema/langchain.pyi +23 -0
- gllm_inference/lm_invoker/schema/openai.pyi +109 -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/sea_lion_lm_invoker.pyi +48 -0
- gllm_inference/lm_invoker/xai_lm_invoker.pyi +252 -0
- gllm_inference/model/__init__.pyi +13 -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/sea_lion_lm.pyi +16 -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 +73 -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 +19 -0
- gllm_inference/schema/activity.pyi +64 -0
- gllm_inference/schema/attachment.pyi +102 -0
- gllm_inference/schema/code_exec_result.pyi +14 -0
- gllm_inference/schema/config.pyi +15 -0
- gllm_inference/schema/enums.pyi +82 -0
- gllm_inference/schema/events.pyi +105 -0
- gllm_inference/schema/formatter.pyi +31 -0
- gllm_inference/schema/lm_input.pyi +4 -0
- gllm_inference/schema/lm_output.pyi +266 -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 +15 -0
- gllm_inference.build/.gitignore +1 -0
- gllm_inference.cpython-313-darwin.so +0 -0
- gllm_inference.pyi +156 -0
- gllm_inference_binary-0.5.65.dist-info/METADATA +138 -0
- gllm_inference_binary-0.5.65.dist-info/RECORD +140 -0
- gllm_inference_binary-0.5.65.dist-info/WHEEL +5 -0
- gllm_inference_binary-0.5.65.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
from _typeshed import Incomplete
|
|
2
|
+
from gllm_core.schema import Chunk
|
|
3
|
+
from gllm_inference.schema.attachment import Attachment as Attachment
|
|
4
|
+
from gllm_inference.schema.code_exec_result import CodeExecResult as CodeExecResult
|
|
5
|
+
from gllm_inference.schema.enums import LMOutputType as LMOutputType
|
|
6
|
+
from gllm_inference.schema.mcp import MCPCall as MCPCall
|
|
7
|
+
from gllm_inference.schema.reasoning import Reasoning as Reasoning
|
|
8
|
+
from gllm_inference.schema.token_usage import TokenUsage as TokenUsage
|
|
9
|
+
from gllm_inference.schema.tool_call import ToolCall as ToolCall
|
|
10
|
+
from pydantic import BaseModel
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
LMOutputData = str | dict[str, Any] | BaseModel | Attachment | ToolCall | Reasoning | Chunk | CodeExecResult | MCPCall
|
|
14
|
+
logger: Incomplete
|
|
15
|
+
|
|
16
|
+
class LMOutputItem(BaseModel):
|
|
17
|
+
"""Defines the output item of a language model.
|
|
18
|
+
|
|
19
|
+
Attributes:
|
|
20
|
+
type (str): The type of the output item.
|
|
21
|
+
output (LMOutputData): The output data of the output item.
|
|
22
|
+
"""
|
|
23
|
+
type: str
|
|
24
|
+
output: LMOutputData
|
|
25
|
+
|
|
26
|
+
class LMOutput(BaseModel):
|
|
27
|
+
"""Defines the output of a language model.
|
|
28
|
+
|
|
29
|
+
Attributes:
|
|
30
|
+
outputs (list[LMOutputItem]): The outputs of the language model in sequential order. Defaults to an empty list.
|
|
31
|
+
token_usage (TokenUsage | None): The token usage analytics, if requested. Defaults to None.
|
|
32
|
+
duration (float | None): The duration of the invocation in seconds, if requested. Defaults to None.
|
|
33
|
+
finish_details (dict[str, Any]): The details about how the generation finished, if requested.
|
|
34
|
+
Defaults to an empty dictionary.
|
|
35
|
+
|
|
36
|
+
text (str): The first text response.
|
|
37
|
+
structured_output (dict[str, Any] | BaseModel | None): The first structured output.
|
|
38
|
+
|
|
39
|
+
texts (list[str]): The texts from the outputs.
|
|
40
|
+
structured_outputs (list[dict[str, Any] | BaseModel]): The structured outputs from the outputs.
|
|
41
|
+
attachments (list[Attachment]): The attachments from the outputs.
|
|
42
|
+
tool_calls (list[ToolCall]): The tool calls from the outputs.
|
|
43
|
+
thinkings (list[Reasoning]): The thinkings from the outputs.
|
|
44
|
+
citations (list[Chunk]): The citations from the outputs.
|
|
45
|
+
code_exec_results (list[CodeExecResult]): The code exec results from the outputs.
|
|
46
|
+
mcp_calls (list[MCPCall]): The MCP calls from the outputs.
|
|
47
|
+
|
|
48
|
+
response (str): Deprecated. Replaced by `text`.
|
|
49
|
+
reasoning (list[Reasoning]): Deprecated. Replaced by `thinkings`.
|
|
50
|
+
"""
|
|
51
|
+
outputs: list[LMOutputItem]
|
|
52
|
+
token_usage: TokenUsage | None
|
|
53
|
+
duration: float | None
|
|
54
|
+
finish_details: dict[str, Any]
|
|
55
|
+
def __init__(self, *, outputs: list[LMOutputItem] | None = None, token_usage: TokenUsage | None = None, duration: float | None = None, finish_details: dict[str, Any] | None = None, response: str = '', structured_output: dict[str, Any] | BaseModel | None = None, tool_calls: list[ToolCall] | None = None, reasoning: list[Reasoning] | None = None, attachments: list[Attachment] | None = None, citations: list[Chunk] | None = None, code_exec_results: list[CodeExecResult] | None = None, mcp_calls: list[MCPCall] | None = None) -> None:
|
|
56
|
+
"""Initialize the LMOutput.
|
|
57
|
+
|
|
58
|
+
This constructor is created for backward compatibility with the legacy method to initialize the LMOutput.
|
|
59
|
+
This constructor will be removed in v0.6.
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
outputs (list[LMOutputItem] | None, optional): The output items. Defaults to an empty list.
|
|
63
|
+
token_usage (TokenUsage | None, optional): The token usage analytics. Defaults to None.
|
|
64
|
+
duration (float | None, optional): The duration of the invocation in seconds. Defaults to None.
|
|
65
|
+
finish_details (dict[str, Any] | None, optional): The details about how the generation finished.
|
|
66
|
+
Defaults to an empty dictionary.
|
|
67
|
+
response (str, optional): The first text response. Defaults to an empty string.
|
|
68
|
+
structured_output (dict[str, Any] | BaseModel | None, optional): The first structured output.
|
|
69
|
+
Defaults to None.
|
|
70
|
+
tool_calls (list[ToolCall] | None, optional): The tool calls. Defaults to None.
|
|
71
|
+
reasoning (list[Reasoning] | None, optional): The thinkings. Defaults to None.
|
|
72
|
+
attachments (list[Attachment] | None, optional): The attachments. Defaults to None.
|
|
73
|
+
citations (list[Chunk] | None, optional): The citations. Defaults to None.
|
|
74
|
+
code_exec_results (list[CodeExecResult] | None, optional): The code exec results. Defaults to None.
|
|
75
|
+
mcp_calls (list[MCPCall] | None, optional): The MCP calls. Defaults to None.
|
|
76
|
+
"""
|
|
77
|
+
@property
|
|
78
|
+
def response(self) -> str:
|
|
79
|
+
"""Deprecated property to get the first text response from the LMOutput.
|
|
80
|
+
|
|
81
|
+
Returns:
|
|
82
|
+
str: The first text response from the LMOutput.
|
|
83
|
+
"""
|
|
84
|
+
@response.setter
|
|
85
|
+
def response(self, value: str) -> None:
|
|
86
|
+
"""Deprecated setter to set the first text response to the LMOutput.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
value (str): The first text response to set.
|
|
90
|
+
"""
|
|
91
|
+
@property
|
|
92
|
+
def text(self) -> str:
|
|
93
|
+
"""Get the first text from the LMOutput.
|
|
94
|
+
|
|
95
|
+
Returns:
|
|
96
|
+
str: The first text from the LMOutput.
|
|
97
|
+
"""
|
|
98
|
+
@property
|
|
99
|
+
def structured_output(self) -> dict[str, Any] | BaseModel | None:
|
|
100
|
+
"""Deprecated property to get the first structured output from the LMOutput.
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
dict[str, Any] | BaseModel | None: The first structured output from the LMOutput.
|
|
104
|
+
"""
|
|
105
|
+
@structured_output.setter
|
|
106
|
+
def structured_output(self, value: dict[str, Any] | BaseModel) -> None:
|
|
107
|
+
"""Deprecated setter to set the first structured output to the LMOutput.
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
value (dict[str, Any] | BaseModel): The first structured output to set.
|
|
111
|
+
"""
|
|
112
|
+
@property
|
|
113
|
+
def texts(self) -> list[str]:
|
|
114
|
+
"""Get the texts from the LMOutput.
|
|
115
|
+
|
|
116
|
+
Returns:
|
|
117
|
+
list[str]: The texts from the LMOutput.
|
|
118
|
+
"""
|
|
119
|
+
@property
|
|
120
|
+
def structured_outputs(self) -> list[dict[str, Any] | BaseModel]:
|
|
121
|
+
"""Get the structured outputs from the LMOutput.
|
|
122
|
+
|
|
123
|
+
Returns:
|
|
124
|
+
list[dict[str, Any] | BaseModel]: The structured outputs from the LMOutput.
|
|
125
|
+
"""
|
|
126
|
+
@property
|
|
127
|
+
def attachments(self) -> list[Attachment]:
|
|
128
|
+
"""Get the attachments from the LMOutput.
|
|
129
|
+
|
|
130
|
+
Returns:
|
|
131
|
+
list[Attachment]: The attachments from the LMOutput.
|
|
132
|
+
"""
|
|
133
|
+
@attachments.setter
|
|
134
|
+
def attachments(self, value: list[Attachment]) -> None:
|
|
135
|
+
"""Deprecated setter to set the attachments to the LMOutput.
|
|
136
|
+
|
|
137
|
+
Args:
|
|
138
|
+
value (list[Attachment]): The attachments to set.
|
|
139
|
+
"""
|
|
140
|
+
@property
|
|
141
|
+
def tool_calls(self) -> list[ToolCall]:
|
|
142
|
+
"""Get the tool calls from the LMOutput.
|
|
143
|
+
|
|
144
|
+
Returns:
|
|
145
|
+
list[ToolCall]: The tool calls from the LMOutput.
|
|
146
|
+
"""
|
|
147
|
+
@tool_calls.setter
|
|
148
|
+
def tool_calls(self, value: list[ToolCall]) -> None:
|
|
149
|
+
"""Deprecated setter to set the tool calls to the LMOutput.
|
|
150
|
+
|
|
151
|
+
Args:
|
|
152
|
+
value (list[ToolCall]): The tool calls to set.
|
|
153
|
+
"""
|
|
154
|
+
@property
|
|
155
|
+
def reasoning(self) -> list[Reasoning]:
|
|
156
|
+
"""Deprecated property to get the thinkings from the LMOutput.
|
|
157
|
+
|
|
158
|
+
Returns:
|
|
159
|
+
list[Reasoning]: The thinkings from the LMOutput.
|
|
160
|
+
"""
|
|
161
|
+
@reasoning.setter
|
|
162
|
+
def reasoning(self, value: list[Reasoning]) -> None:
|
|
163
|
+
"""Deprecated setter to set the thinkings to the LMOutput.
|
|
164
|
+
|
|
165
|
+
Args:
|
|
166
|
+
value (list[Reasoning]): The thinkings to set.
|
|
167
|
+
"""
|
|
168
|
+
@property
|
|
169
|
+
def thinkings(self) -> list[Reasoning]:
|
|
170
|
+
"""Get the thinkings from the LMOutput.
|
|
171
|
+
|
|
172
|
+
Returns:
|
|
173
|
+
list[Reasoning]: The thinkings from the LMOutput.
|
|
174
|
+
"""
|
|
175
|
+
@property
|
|
176
|
+
def citations(self) -> list[Chunk]:
|
|
177
|
+
"""Get the citations from the LMOutput.
|
|
178
|
+
|
|
179
|
+
Returns:
|
|
180
|
+
list[Chunk]: The citations from the LMOutput.
|
|
181
|
+
"""
|
|
182
|
+
@citations.setter
|
|
183
|
+
def citations(self, value: list[Chunk]) -> None:
|
|
184
|
+
"""Deprecated setter to set the citations to the LMOutput.
|
|
185
|
+
|
|
186
|
+
Args:
|
|
187
|
+
value (list[Chunk]): The citations to set.
|
|
188
|
+
"""
|
|
189
|
+
@property
|
|
190
|
+
def code_exec_results(self) -> list[CodeExecResult]:
|
|
191
|
+
"""Get the code exec results from the LMOutput.
|
|
192
|
+
|
|
193
|
+
Returns:
|
|
194
|
+
list[CodeExecResult]: The code exec results from the LMOutput.
|
|
195
|
+
"""
|
|
196
|
+
@code_exec_results.setter
|
|
197
|
+
def code_exec_results(self, value: list[CodeExecResult]) -> None:
|
|
198
|
+
"""Deprecated setter to set the code exec results to the LMOutput.
|
|
199
|
+
|
|
200
|
+
Args:
|
|
201
|
+
value (list[CodeExecResult]): The code exec results to set.
|
|
202
|
+
"""
|
|
203
|
+
@property
|
|
204
|
+
def mcp_calls(self) -> list[MCPCall]:
|
|
205
|
+
"""Get the MCP calls from the LMOutput.
|
|
206
|
+
|
|
207
|
+
Returns:
|
|
208
|
+
list[MCPCall]: The MCP calls from the LMOutput.
|
|
209
|
+
"""
|
|
210
|
+
@mcp_calls.setter
|
|
211
|
+
def mcp_calls(self, value: list[MCPCall]) -> None:
|
|
212
|
+
"""Deprecated setter to set the MCP calls to the LMOutput.
|
|
213
|
+
|
|
214
|
+
Args:
|
|
215
|
+
value (list[MCPCall]): The MCP calls to set.
|
|
216
|
+
"""
|
|
217
|
+
def add_text(self, text: str | list[str]) -> None:
|
|
218
|
+
"""Add an output or a list of outputs to the LMOutput.
|
|
219
|
+
|
|
220
|
+
Args:
|
|
221
|
+
text (str | list[str]): The text or a list of texts to add.
|
|
222
|
+
"""
|
|
223
|
+
def add_attachment(self, attachment: Attachment | list[Attachment]) -> None:
|
|
224
|
+
"""Add an attachment or a list of attachments to the LMOutput.
|
|
225
|
+
|
|
226
|
+
Args:
|
|
227
|
+
attachment (Attachment | list[Attachment]): The attachment or a list of attachments to add.
|
|
228
|
+
"""
|
|
229
|
+
def add_tool_call(self, tool_call: ToolCall | list[ToolCall]) -> None:
|
|
230
|
+
"""Add a tool call or a list of tool calls to the LMOutput.
|
|
231
|
+
|
|
232
|
+
Args:
|
|
233
|
+
tool_call (ToolCall | list[ToolCall]): The tool call or a list of tool calls to add.
|
|
234
|
+
"""
|
|
235
|
+
def add_structured(self, structured: dict[str, Any] | BaseModel | list[dict[str, Any] | BaseModel]) -> None:
|
|
236
|
+
"""Add a structured output or a list of structured outputs to the LMOutput.
|
|
237
|
+
|
|
238
|
+
Args:
|
|
239
|
+
structured (dict[str, Any] | BaseModel | list[dict[str, Any] | BaseModel]): The structured output
|
|
240
|
+
or a list of structured outputs to add.
|
|
241
|
+
"""
|
|
242
|
+
def add_thinking(self, thinking: Reasoning | list[Reasoning]) -> None:
|
|
243
|
+
"""Add a thinking or a list of thoughts to the LMOutput.
|
|
244
|
+
|
|
245
|
+
Args:
|
|
246
|
+
thinking (Reasoning | list[Reasoning]): The thinking or a list of thoughts to add.
|
|
247
|
+
"""
|
|
248
|
+
def add_citation(self, citation: Chunk | list[Chunk]) -> None:
|
|
249
|
+
"""Add a citation or a list of citations to the LMOutput.
|
|
250
|
+
|
|
251
|
+
Args:
|
|
252
|
+
citation (Chunk | list[Chunk]): The citation or a list of citations to add.
|
|
253
|
+
"""
|
|
254
|
+
def add_code_exec_result(self, code_exec_result: CodeExecResult | list[CodeExecResult]) -> None:
|
|
255
|
+
"""Add a code exec result or a list of code exec results to the LMOutput.
|
|
256
|
+
|
|
257
|
+
Args:
|
|
258
|
+
code_exec_result (CodeExecResult | list[CodeExecResult]): The code exec result or a list of code exec
|
|
259
|
+
results to add.
|
|
260
|
+
"""
|
|
261
|
+
def add_mcp_call(self, mcp_call: MCPCall | list[MCPCall]) -> None:
|
|
262
|
+
"""Add an MCP call or a list of MCP calls to the LMOutput.
|
|
263
|
+
|
|
264
|
+
Args:
|
|
265
|
+
mcp_call (MCPCall | list[MCPCall]): The MCP call or a list of MCP calls to add.
|
|
266
|
+
"""
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from pydantic import BaseModel
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
class MCPServer(BaseModel):
|
|
5
|
+
"""Defines an MCP server.
|
|
6
|
+
|
|
7
|
+
Attributes:
|
|
8
|
+
url (str): The URL of the MCP server.
|
|
9
|
+
name (str): The name of the MCP server.
|
|
10
|
+
allowed_tools (list[str] | None): The allowed tools of the MCP server.
|
|
11
|
+
Defaults to None, in which case all tools are allowed.
|
|
12
|
+
"""
|
|
13
|
+
url: str
|
|
14
|
+
name: str
|
|
15
|
+
allowed_tools: list[str] | None
|
|
16
|
+
|
|
17
|
+
class MCPCall(BaseModel):
|
|
18
|
+
"""Defines an MCP call.
|
|
19
|
+
|
|
20
|
+
Attributes:
|
|
21
|
+
id (str): The ID of the MCP call. Defaults to an empty string.
|
|
22
|
+
server_name (str): The name of the MCP server. Defaults to an empty string.
|
|
23
|
+
tool_name (str): The name of the tool. Defaults to an empty string.
|
|
24
|
+
args (dict[str, Any]): The arguments of the tool. Defaults to an empty dictionary.
|
|
25
|
+
output (str | None): The output of the tool. Defaults to None.
|
|
26
|
+
"""
|
|
27
|
+
id: str
|
|
28
|
+
server_name: str
|
|
29
|
+
tool_name: str
|
|
30
|
+
args: dict[str, Any]
|
|
31
|
+
output: str | None
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from gllm_inference.schema.enums import MessageRole as MessageRole
|
|
2
|
+
from gllm_inference.schema.type_alias import MessageContent as MessageContent
|
|
3
|
+
from pydantic import BaseModel
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
class Message(BaseModel):
|
|
7
|
+
"""Defines a message schema to be used as inputs for a language model.
|
|
8
|
+
|
|
9
|
+
Attributes:
|
|
10
|
+
role (MessageRole): The role of the message.
|
|
11
|
+
contents (list[MessageContent]): The contents of the message.
|
|
12
|
+
metadata (dict[str, Any]): The metadata of the message.
|
|
13
|
+
"""
|
|
14
|
+
role: MessageRole
|
|
15
|
+
contents: list[MessageContent]
|
|
16
|
+
metadata: dict[str, Any]
|
|
17
|
+
@classmethod
|
|
18
|
+
def system(cls, contents: MessageContent | list[MessageContent], metadata: dict[str, Any] | None = None) -> Message:
|
|
19
|
+
"""Create a system message.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
contents (MessageContent | list[MessageContent]): The message contents.
|
|
23
|
+
If a single content is provided, it will be wrapped in a list.
|
|
24
|
+
metadata (dict[str, Any], optional): Additional metadata for the message. Defaults to None.
|
|
25
|
+
|
|
26
|
+
Returns:
|
|
27
|
+
Message: A new message with SYSTEM role.
|
|
28
|
+
"""
|
|
29
|
+
@classmethod
|
|
30
|
+
def user(cls, contents: MessageContent | list[MessageContent], metadata: dict[str, Any] | None = None) -> Message:
|
|
31
|
+
"""Create a user message.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
contents (MessageContent | list[MessageContent]): The message contents.
|
|
35
|
+
If a single content is provided, it will be wrapped in a list.
|
|
36
|
+
metadata (dict[str, Any], optional): Additional metadata for the message. Defaults to None.
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
Message: A new message with USER role.
|
|
40
|
+
"""
|
|
41
|
+
@classmethod
|
|
42
|
+
def assistant(cls, contents: MessageContent | list[MessageContent], metadata: dict[str, Any] | None = None) -> Message:
|
|
43
|
+
"""Create an assistant message.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
contents (MessageContent | list[MessageContent]): The message contents.
|
|
47
|
+
If a single content is provided, it will be wrapped in a list.
|
|
48
|
+
metadata (dict[str, Any], optional): Additional metadata for the message. Defaults to None.
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
Message: A new message with ASSISTANT role.
|
|
52
|
+
"""
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
from _typeshed import Incomplete
|
|
2
|
+
from enum import StrEnum
|
|
3
|
+
from pydantic import BaseModel
|
|
4
|
+
|
|
5
|
+
PROVIDER_SEPARATOR: str
|
|
6
|
+
PATH_SEPARATOR: str
|
|
7
|
+
URL_NAME_REGEX_PATTERN: str
|
|
8
|
+
|
|
9
|
+
class ModelProvider(StrEnum):
|
|
10
|
+
"""Defines the supported model providers."""
|
|
11
|
+
ANTHROPIC = 'anthropic'
|
|
12
|
+
AZURE_OPENAI = 'azure-openai'
|
|
13
|
+
BEDROCK = 'bedrock'
|
|
14
|
+
COHERE = 'cohere'
|
|
15
|
+
DATASAUR = 'datasaur'
|
|
16
|
+
GOOGLE = 'google'
|
|
17
|
+
JINA = 'jina'
|
|
18
|
+
LANGCHAIN = 'langchain'
|
|
19
|
+
LITELLM = 'litellm'
|
|
20
|
+
OPENAI = 'openai'
|
|
21
|
+
PORTKEY = 'portkey'
|
|
22
|
+
OPENAI_CHAT_COMPLETIONS = 'openai-chat-completions'
|
|
23
|
+
OPENAI_COMPATIBLE = 'openai-compatible'
|
|
24
|
+
SEA_LION = 'sea-lion'
|
|
25
|
+
TWELVELABS = 'twelvelabs'
|
|
26
|
+
VOYAGE = 'voyage'
|
|
27
|
+
XAI = 'xai'
|
|
28
|
+
|
|
29
|
+
PROVIDERS_OPTIONAL_PATH: Incomplete
|
|
30
|
+
PROVIDERS_SUPPORT_PATH: Incomplete
|
|
31
|
+
|
|
32
|
+
class ModelId(BaseModel):
|
|
33
|
+
'''Defines a representation of a valid model id.
|
|
34
|
+
|
|
35
|
+
Attributes:
|
|
36
|
+
provider (ModelProvider): The provider of the model.
|
|
37
|
+
name (str | None): The name of the model.
|
|
38
|
+
path (str | None): The path of the model.
|
|
39
|
+
|
|
40
|
+
Provider-specific examples:
|
|
41
|
+
# Using Anthropic
|
|
42
|
+
```python
|
|
43
|
+
model_id = ModelId.from_string("anthropic/claude-sonnet-4-20250514")
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
# Using Bedrock
|
|
47
|
+
```python
|
|
48
|
+
model_id = ModelId.from_string("bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0")
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
# Using Cohere
|
|
52
|
+
```python
|
|
53
|
+
model_id = ModelId.from_string("cohere/embed-english-v3.0")
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
# Using Cohere with custom endpoint
|
|
57
|
+
```python
|
|
58
|
+
model_id = ModelId.from_string("cohere/https://my-cohere-url:8000/v1:my-model-name")
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
# Using Datasaur
|
|
62
|
+
```python
|
|
63
|
+
model_id = ModelId.from_string("datasaur/https://deployment.datasaur.ai/api/deployment/teamId/deploymentId/")
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
# Using Google
|
|
67
|
+
```python
|
|
68
|
+
model_id = ModelId.from_string("google/gemini-2.5-flash-lite")
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
# Using Jina
|
|
72
|
+
```python
|
|
73
|
+
model_id = ModelId.from_string("jina/jina-embeddings-v2-large")
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
# Using Jina with custom endpoint
|
|
77
|
+
```python
|
|
78
|
+
model_id = ModelId.from_string("jina/https://my-jina-url:8000/v1:my-model-name")
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
# Using OpenAI
|
|
82
|
+
```python
|
|
83
|
+
model_id = ModelId.from_string("openai/gpt-5-nano")
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
# Using OpenAI with Chat Completions API
|
|
87
|
+
```python
|
|
88
|
+
model_id = ModelId.from_string("openai-chat-completions/gpt-5-nano")
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
# Using OpenAI Responses API-compatible endpoints (e.g. SGLang)
|
|
92
|
+
```python
|
|
93
|
+
model_id = ModelId.from_string("openai/https://my-sglang-url:8000/v1:my-model-name")
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
# Using OpenAI Chat Completions API-compatible endpoints (e.g. Groq)
|
|
97
|
+
```python
|
|
98
|
+
model_id = ModelId.from_string("openai-chat-completions/https://api.groq.com/openai/v1:llama3-8b-8192")
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
# Using Azure OpenAI
|
|
102
|
+
```python
|
|
103
|
+
model_id = ModelId.from_string("azure-openai/https://my-resource.openai.azure.com/openai/v1:my-deployment")
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
# Using Voyage
|
|
107
|
+
```python
|
|
108
|
+
model_id = ModelId.from_string("voyage/voyage-3.5-lite")
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
# Using TwelveLabs
|
|
112
|
+
```python
|
|
113
|
+
model_id = ModelId.from_string("twelvelabs/Marengo-retrieval-2.7")
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
# Using LangChain
|
|
117
|
+
```python
|
|
118
|
+
model_id = ModelId.from_string("langchain/langchain_openai.ChatOpenAI:gpt-4o-mini")
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
For the list of supported providers, please refer to the following table:
|
|
122
|
+
https://python.langchain.com/docs/integrations/chat/#featured-providers
|
|
123
|
+
|
|
124
|
+
# Using LiteLLM
|
|
125
|
+
```python
|
|
126
|
+
model_id = ModelId.from_string("litellm/openai/gpt-4o-mini")
|
|
127
|
+
```
|
|
128
|
+
For the list of supported providers, please refer to the following page:
|
|
129
|
+
https://docs.litellm.ai/docs/providers/
|
|
130
|
+
|
|
131
|
+
# Using xAI
|
|
132
|
+
```python
|
|
133
|
+
model_id = ModelId.from_string("xai/grok-4-0709")
|
|
134
|
+
```
|
|
135
|
+
For the list of supported models, please refer to the following page:
|
|
136
|
+
https://docs.x.ai/docs/models
|
|
137
|
+
|
|
138
|
+
Custom model name validation example:
|
|
139
|
+
```python
|
|
140
|
+
validation_map = {
|
|
141
|
+
ModelProvider.ANTHROPIC: {"claude-sonnet-4-20250514"},
|
|
142
|
+
ModelProvider.GOOGLE: {"gemini-2.5-flash-lite"},
|
|
143
|
+
ModelProvider.OPENAI: {"gpt-4.1-nano", "gpt-5-nano"},
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
model_id = ModelId.from_string("...", validation_map)
|
|
147
|
+
```
|
|
148
|
+
'''
|
|
149
|
+
provider: ModelProvider
|
|
150
|
+
name: str | None
|
|
151
|
+
path: str | None
|
|
152
|
+
@classmethod
|
|
153
|
+
def from_string(cls, model_id: str, validation_map: dict[str, set[str]] | None = None) -> ModelId:
|
|
154
|
+
"""Parse a model id string into a ModelId object.
|
|
155
|
+
|
|
156
|
+
Args:
|
|
157
|
+
model_id (str): The model id to parse. Must be in the format defined in the following page:
|
|
158
|
+
https://gdplabs.gitbook.io/sdk/resources/supported-models
|
|
159
|
+
validation_map (dict[str, set[str]] | None, optional): An optional dictionary that maps provider names to
|
|
160
|
+
sets of valid model names. For the defined model providers, the model names will be validated against
|
|
161
|
+
the set of valid model names. For the undefined model providers, the model name will not be validated.
|
|
162
|
+
Defaults to None.
|
|
163
|
+
|
|
164
|
+
Returns:
|
|
165
|
+
ModelId: The parsed ModelId object.
|
|
166
|
+
|
|
167
|
+
Raises:
|
|
168
|
+
ValueError: If the provided model id is invalid or if the model name is not valid for the provider.
|
|
169
|
+
"""
|
|
170
|
+
def to_string(self) -> str:
|
|
171
|
+
"""Convert the ModelId object to a string.
|
|
172
|
+
|
|
173
|
+
Returns:
|
|
174
|
+
str: The string representation of the ModelId object. The format is defined in the following page:
|
|
175
|
+
https://gdplabs.gitbook.io/sdk/resources/supported-models
|
|
176
|
+
"""
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from pydantic import BaseModel
|
|
2
|
+
|
|
3
|
+
class Reasoning(BaseModel):
|
|
4
|
+
"""Defines a reasoning output when a language model is configured to use reasoning.
|
|
5
|
+
|
|
6
|
+
Attributes:
|
|
7
|
+
id (str): The ID of the reasoning output. Defaults to an empty string.
|
|
8
|
+
reasoning (str): The reasoning text. Defaults to an empty string.
|
|
9
|
+
type (str): The type of the reasoning output. Defaults to an empty string.
|
|
10
|
+
data (str): The additional data of the reasoning output. Defaults to an empty string.
|
|
11
|
+
"""
|
|
12
|
+
id: str
|
|
13
|
+
reasoning: str
|
|
14
|
+
type: str
|
|
15
|
+
data: str
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
from pydantic import BaseModel
|
|
2
|
+
|
|
3
|
+
class InputTokenDetails(BaseModel):
|
|
4
|
+
"""Defines the input token details schema.
|
|
5
|
+
|
|
6
|
+
Attributes:
|
|
7
|
+
cached_tokens (int): The number of cached tokens. Defaults to 0.
|
|
8
|
+
uncached_tokens (int): The number of uncached tokens. Defaults to 0.
|
|
9
|
+
"""
|
|
10
|
+
cached_tokens: int
|
|
11
|
+
uncached_tokens: int
|
|
12
|
+
def __add__(self, other: InputTokenDetails) -> InputTokenDetails:
|
|
13
|
+
"""Add two InputTokenDetails objects together.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
other (InputTokenDetails): The other InputTokenDetails object to add.
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
InputTokenDetails: A new InputTokenDetails object with summed values.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
class OutputTokenDetails(BaseModel):
|
|
23
|
+
"""Defines the output token details schema.
|
|
24
|
+
|
|
25
|
+
Attributes:
|
|
26
|
+
reasoning_tokens (int): The number of reasoning tokens. Defaults to 0.
|
|
27
|
+
response_tokens (int): The number of response tokens. Defaults to 0.
|
|
28
|
+
"""
|
|
29
|
+
reasoning_tokens: int
|
|
30
|
+
response_tokens: int
|
|
31
|
+
def __add__(self, other: OutputTokenDetails) -> OutputTokenDetails:
|
|
32
|
+
"""Add two OutputTokenDetails objects together.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
other (OutputTokenDetails): The other OutputTokenDetails object to add.
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
OutputTokenDetails: A new OutputTokenDetails object with summed values.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
class TokenUsage(BaseModel):
|
|
42
|
+
"""Defines the token usage data structure of a language model.
|
|
43
|
+
|
|
44
|
+
Attributes:
|
|
45
|
+
input_tokens (int): The number of input tokens. Defaults to 0.
|
|
46
|
+
output_tokens (int): The number of output tokens. Defaults to 0.
|
|
47
|
+
input_token_details (InputTokenDetails | None): The details of the input tokens. Defaults to None.
|
|
48
|
+
output_token_details (OutputTokenDetails | None): The details of the output tokens. Defaults to None.
|
|
49
|
+
"""
|
|
50
|
+
input_tokens: int
|
|
51
|
+
output_tokens: int
|
|
52
|
+
input_token_details: InputTokenDetails | None
|
|
53
|
+
output_token_details: OutputTokenDetails | None
|
|
54
|
+
@classmethod
|
|
55
|
+
def from_token_details(cls, input_tokens: int | None = None, output_tokens: int | None = None, cached_tokens: int | None = None, reasoning_tokens: int | None = None) -> TokenUsage:
|
|
56
|
+
"""Creates a TokenUsage from token details.
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
input_tokens (int | None): The number of input tokens. Defaults to None.
|
|
60
|
+
output_tokens (int | None): The number of output tokens. Defaults to None.
|
|
61
|
+
cached_tokens (int | None): The number of cached tokens. Defaults to None.
|
|
62
|
+
reasoning_tokens (int | None): The number of reasoning tokens. Defaults to None.
|
|
63
|
+
|
|
64
|
+
Returns:
|
|
65
|
+
TokenUsage: The instantiated TokenUsage.
|
|
66
|
+
"""
|
|
67
|
+
def __add__(self, other: TokenUsage) -> TokenUsage:
|
|
68
|
+
"""Add two TokenUsage objects together.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
other (TokenUsage): The other TokenUsage object to add.
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
TokenUsage: A new TokenUsage object with summed values.
|
|
75
|
+
"""
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from pydantic import BaseModel
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
class ToolCall(BaseModel):
|
|
5
|
+
"""Defines a tool call request when a language model decides to invoke a tool.
|
|
6
|
+
|
|
7
|
+
Attributes:
|
|
8
|
+
id (str): The ID of the tool call.
|
|
9
|
+
name (str): The name of the tool.
|
|
10
|
+
args (dict[str, Any]): The arguments of the tool call.
|
|
11
|
+
"""
|
|
12
|
+
id: str
|
|
13
|
+
name: str
|
|
14
|
+
args: dict[str, Any]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from pydantic import BaseModel
|
|
2
|
+
|
|
3
|
+
class ToolResult(BaseModel):
|
|
4
|
+
"""Defines a tool result to be sent back to the language model.
|
|
5
|
+
|
|
6
|
+
Attributes:
|
|
7
|
+
id (str): The ID of the tool call.
|
|
8
|
+
output (str): The output of the tool call.
|
|
9
|
+
"""
|
|
10
|
+
id: str
|
|
11
|
+
output: str
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from gllm_inference.schema.attachment import Attachment as Attachment
|
|
2
|
+
from gllm_inference.schema.reasoning import Reasoning as Reasoning
|
|
3
|
+
from gllm_inference.schema.tool_call import ToolCall as ToolCall
|
|
4
|
+
from gllm_inference.schema.tool_result import ToolResult as ToolResult
|
|
5
|
+
from pydantic import BaseModel
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
ResponseSchema = dict[str, Any] | type[BaseModel]
|
|
9
|
+
MessageContent = str | Attachment | ToolCall | ToolResult | Reasoning
|
|
10
|
+
EMContent = str | Attachment | tuple[str | Attachment, ...]
|
|
11
|
+
Vector = list[float]
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
from gllm_inference.utils.io_utils import base64_to_bytes as base64_to_bytes
|
|
2
|
+
from gllm_inference.utils.langchain import load_langchain_model as load_langchain_model, parse_model_data as parse_model_data
|
|
3
|
+
from gllm_inference.utils.validation import validate_string_enum as validate_string_enum
|
|
4
|
+
|
|
5
|
+
__all__ = ['base64_to_bytes', 'load_langchain_model', 'parse_model_data', 'validate_string_enum']
|