gllm-inference-binary 0.5.51__cp311-cp311-win_amd64.whl → 0.5.66__cp311-cp311-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. gllm_inference/builder/build_lm_invoker.pyi +10 -1
  2. gllm_inference/constants.pyi +0 -1
  3. gllm_inference/em_invoker/cohere_em_invoker.pyi +1 -2
  4. gllm_inference/lm_invoker/__init__.pyi +2 -1
  5. gllm_inference/lm_invoker/anthropic_lm_invoker.pyi +95 -109
  6. gllm_inference/lm_invoker/azure_openai_lm_invoker.pyi +92 -109
  7. gllm_inference/lm_invoker/batch/batch_operations.pyi +2 -1
  8. gllm_inference/lm_invoker/bedrock_lm_invoker.pyi +51 -65
  9. gllm_inference/lm_invoker/datasaur_lm_invoker.pyi +36 -36
  10. gllm_inference/lm_invoker/google_lm_invoker.pyi +195 -110
  11. gllm_inference/lm_invoker/langchain_lm_invoker.pyi +52 -64
  12. gllm_inference/lm_invoker/litellm_lm_invoker.pyi +86 -106
  13. gllm_inference/lm_invoker/lm_invoker.pyi +20 -1
  14. gllm_inference/lm_invoker/openai_chat_completions_lm_invoker.pyi +87 -107
  15. gllm_inference/lm_invoker/openai_lm_invoker.pyi +235 -185
  16. gllm_inference/lm_invoker/portkey_lm_invoker.pyi +104 -68
  17. gllm_inference/lm_invoker/schema/google.pyi +12 -0
  18. gllm_inference/lm_invoker/schema/openai.pyi +22 -0
  19. gllm_inference/lm_invoker/sea_lion_lm_invoker.pyi +48 -0
  20. gllm_inference/lm_invoker/xai_lm_invoker.pyi +94 -131
  21. gllm_inference/model/__init__.pyi +2 -1
  22. gllm_inference/model/lm/sea_lion_lm.pyi +16 -0
  23. gllm_inference/prompt_builder/prompt_builder.pyi +6 -2
  24. gllm_inference/schema/__init__.pyi +4 -3
  25. gllm_inference/schema/attachment.pyi +20 -6
  26. gllm_inference/schema/enums.pyi +14 -1
  27. gllm_inference/schema/events.pyi +2 -2
  28. gllm_inference/schema/formatter.pyi +31 -0
  29. gllm_inference/schema/lm_output.pyi +245 -23
  30. gllm_inference/schema/model_id.pyi +1 -1
  31. gllm_inference/utils/validation.pyi +3 -0
  32. gllm_inference.cp311-win_amd64.pyd +0 -0
  33. gllm_inference.pyi +5 -6
  34. {gllm_inference_binary-0.5.51.dist-info → gllm_inference_binary-0.5.66.dist-info}/METADATA +5 -5
  35. {gllm_inference_binary-0.5.51.dist-info → gllm_inference_binary-0.5.66.dist-info}/RECORD +37 -34
  36. {gllm_inference_binary-0.5.51.dist-info → gllm_inference_binary-0.5.66.dist-info}/WHEEL +0 -0
  37. {gllm_inference_binary-0.5.51.dist-info → gllm_inference_binary-0.5.66.dist-info}/top_level.txt +0 -0
@@ -51,83 +51,82 @@ class BedrockLMInvoker(BaseLMInvoker):
51
51
  result = await lm_invoker.invoke([text, image])
52
52
  ```
53
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 = BedrockLMInvoker(..., tools=[tool_1, tool_2])
63
- ```
54
+ Text output:
55
+ The `BedrockLMInvoker` generates text outputs by default.
56
+ Text outputs are stored in the `outputs` attribute of the `LMOutput` object and can be accessed
57
+ via the `texts` (all text outputs) or `text` (first text output) properties.
64
58
 
65
59
  Output example:
66
60
  ```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
- )
61
+ LMOutput(outputs=[LMOutputItem(type="text", output="Hello, there!")])
74
62
  ```
75
63
 
76
64
  Structured output:
77
- Structured output is a feature that allows the language model to output a structured response.
65
+ The `BedrockLMInvoker` can be configured to generate structured outputs.
78
66
  This feature can be enabled by providing a schema to the `response_schema` parameter.
79
67
 
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
- Structured output is achieved by providing the schema name in the `tool_choice` parameter. This forces
85
- the model to call the provided schema as a tool. Thus, structured output is not compatible with tool calling,
86
- since the tool calling is reserved to force the model to call the provided schema as a tool.
87
- The language model also doesn\'t need to stream anything when structured output is enabled. Thus, standard
88
- invocation will be performed regardless of whether the `event_emitter` parameter is provided or not.
68
+ Structured outputs are stored in the `outputs` attribute of the `LMOutput` object and can be accessed
69
+ via the `structureds` (all structured outputs) or `structured` (first structured output) properties.
89
70
 
90
- When enabled, the structured output is stored in the `structured_output` attribute in the output.
91
- 1. If the schema is a JSON schema dictionary, the structured output is a dictionary.
92
- 2. If the schema is a Pydantic BaseModel class, the structured output is a Pydantic model.
71
+ The schema must either be one of the following:
72
+ 1. A Pydantic BaseModel class
73
+ The structured output will be a Pydantic model.
74
+ 2. A JSON schema dictionary
75
+ JSON dictionary schema must be compatible with Pydantic\'s JSON schema, especially for complex schemas.
76
+ Thus, it is recommended to create the JSON schema using Pydantic\'s `model_json_schema` method.
77
+ The structured output will be a dictionary.
93
78
 
94
- # Example 1: Using a JSON schema dictionary
95
79
  Usage example:
96
80
  ```python
97
- schema = {
98
- "title": "Animal",
99
- "description": "A description of an animal.",
100
- "properties": {
101
- "color": {"title": "Color", "type": "string"},
102
- "name": {"title": "Name", "type": "string"},
103
- },
104
- "required": ["name", "color"],
105
- "type": "object",
106
- }
107
- lm_invoker = BedrockLMInvoker(..., response_schema=schema)
81
+ class Animal(BaseModel):
82
+ name: str
83
+ color: str
84
+
85
+ json_schema = Animal.model_json_schema()
86
+
87
+ lm_invoker = BedrockLMInvoker(..., response_schema=Animal) # Using Pydantic BaseModel class
88
+ lm_invoker = BedrockLMInvoker(..., response_schema=json_schema) # Using JSON schema dictionary
108
89
  ```
90
+
109
91
  Output example:
110
92
  ```python
111
- LMOutput(structured_output={"name": "Golden retriever", "color": "Golden"})
93
+ # Using Pydantic BaseModel class outputs a Pydantic model
94
+ LMOutput(outputs=[LMOutputItem(type="structured", output=Animal(name="dog", color="white"))])
95
+
96
+ # Using JSON schema dictionary outputs a dictionary
97
+ LMOutput(outputs=[LMOutputItem(type="structured", output={"name": "dog", "color": "white"})])
112
98
  ```
113
99
 
114
- # Example 2: Using a Pydantic BaseModel class
100
+ Structured output is not compatible with tool calling.
101
+ When structured output is enabled, streaming is disabled.
102
+
103
+ Tool calling:
104
+ The `BedrockLMInvoker` can be configured to call tools to perform certain tasks.
105
+ This feature can be enabled by providing a list of `Tool` objects to the `tools` parameter.
106
+
107
+ Tool calls outputs are stored in the `outputs` attribute of the `LMOutput` object and
108
+ can be accessed via the `tool_calls` property.
109
+
115
110
  Usage example:
116
111
  ```python
117
- class Animal(BaseModel):
118
- name: str
119
- color: str
120
-
121
- lm_invoker = BedrockLMInvoker(..., response_schema=Animal)
112
+ lm_invoker = BedrockLMInvoker(..., tools=[tool_1, tool_2])
122
113
  ```
114
+
123
115
  Output example:
124
116
  ```python
125
- LMOutput(structured_output=Animal(name="Golden retriever", color="Golden"))
117
+ LMOutput(
118
+ outputs=[
119
+ LMOutputItem(type="text", output="I\'m using tools..."),
120
+ LMOutputItem(type="tool_call", output=ToolCall(id="123", name="tool_1", args={"key": "value"})),
121
+ LMOutputItem(type="tool_call", output=ToolCall(id="456", name="tool_2", args={"key": "value"})),
122
+ ]
123
+ )
126
124
  ```
127
125
 
128
126
  Analytics tracking:
129
- Analytics tracking is a feature that allows the module to output additional information about the invocation.
127
+ The `BedrockLMInvoker` can be configured to output additional information about the invocation.
130
128
  This feature can be enabled by setting the `output_analytics` parameter to `True`.
129
+
131
130
  When enabled, the following attributes will be stored in the output:
132
131
  1. `token_usage`: The token usage.
133
132
  2. `duration`: The duration in seconds.
@@ -136,7 +135,7 @@ class BedrockLMInvoker(BaseLMInvoker):
136
135
  Output example:
137
136
  ```python
138
137
  LMOutput(
139
- response="Golden retriever is a good dog breed.",
138
+ outputs=[...],
140
139
  token_usage=TokenUsage(input_tokens=100, output_tokens=50),
141
140
  duration=0.729,
142
141
  finish_details={"stop_reason": "end_turn"},
@@ -151,8 +150,6 @@ class BedrockLMInvoker(BaseLMInvoker):
151
150
  Retry config examples:
152
151
  ```python
153
152
  retry_config = RetryConfig(max_retries=0, timeout=None) # No retry, no timeout
154
- retry_config = RetryConfig(max_retries=0, timeout=10.0) # No retry, 10.0 seconds timeout
155
- retry_config = RetryConfig(max_retries=5, timeout=None) # 5 max retries, no timeout
156
153
  retry_config = RetryConfig(max_retries=5, timeout=10.0) # 5 max retries, 10.0 seconds timeout
157
154
  ```
158
155
 
@@ -160,17 +157,6 @@ class BedrockLMInvoker(BaseLMInvoker):
160
157
  ```python
161
158
  lm_invoker = BedrockLMInvoker(..., retry_config=retry_config)
162
159
  ```
163
-
164
- Output types:
165
- The output of the `BedrockLMInvoker` can either be:
166
- 1. `str`: A text response.
167
- 2. `LMOutput`: A Pydantic model that may contain the following attributes:
168
- 2.1. response (str)
169
- 2.2. tool_calls (list[ToolCall])
170
- 2.3. structured_output (dict[str, Any] | BaseModel | None)
171
- 2.4. token_usage (TokenUsage | None)
172
- 2.5. duration (float | None)
173
- 2.6. finish_details (dict[str, Any] | None)
174
160
  '''
175
161
  session: Incomplete
176
162
  client_kwargs: Incomplete
@@ -44,9 +44,42 @@ class DatasaurLMInvoker(OpenAIChatCompletionsLMInvoker):
44
44
  result = await lm_invoker.invoke([text, image])
45
45
  ```
46
46
 
47
+ Text output:
48
+ The `DatasaurLMInvoker` generates text outputs by default.
49
+ Text outputs are stored in the `outputs` attribute of the `LMOutput` object and can be accessed
50
+ via the `texts` (all text outputs) or `text` (first text output) properties.
51
+
52
+ Output example:
53
+ ```python
54
+ LMOutput(outputs=[LMOutputItem(type="text", output="Hello, there!")])
55
+ ```
56
+
57
+ Citations:
58
+ The `DatasaurLMInvoker` can be configured to output the citations used to generate the response.
59
+ This feature can be enabled by setting the `citations` parameter to `True`.
60
+
61
+ Citations outputs are stored in the `outputs` attribute of the `LMOutput` object and
62
+ can be accessed via the `citations` property.
63
+
64
+ Usage example:
65
+ ```python
66
+ lm_invoker = DatasaurLMInvoker(..., citations=True)
67
+ ```
68
+
69
+ Output example:
70
+ ```python
71
+ LMOutput(
72
+ outputs=[
73
+ LMOutputItem(type="citation", output=Chunk(id="123", content="...", metadata={...}, score=0.95)),
74
+ LMOutputItem(type="text", output="According to recent reports... ([Source](https://www.example.com))."),
75
+ ],
76
+ )
77
+ ```
78
+
47
79
  Analytics tracking:
48
- Analytics tracking is a feature that allows the module to output additional information about the invocation.
80
+ The `DatasaurLMInvoker` can be configured to output additional information about the invocation.
49
81
  This feature can be enabled by setting the `output_analytics` parameter to `True`.
82
+
50
83
  When enabled, the following attributes will be stored in the output:
51
84
  1. `token_usage`: The token usage.
52
85
  2. `duration`: The duration in seconds.
@@ -55,16 +88,13 @@ class DatasaurLMInvoker(OpenAIChatCompletionsLMInvoker):
55
88
  Output example:
56
89
  ```python
57
90
  LMOutput(
58
- response="Golden retriever is a good dog breed.",
91
+ outputs=[...],
59
92
  token_usage=TokenUsage(input_tokens=100, output_tokens=50),
60
93
  duration=0.729,
61
- finish_details={"finish_reason": "stop"},
94
+ finish_details={"stop_reason": "end_turn"},
62
95
  )
63
96
  ```
64
97
 
65
- When streaming is enabled, token usage is not supported. Therefore, the `token_usage` attribute will be `None`
66
- regardless of the value of the `output_analytics` parameter.
67
-
68
98
  Retry and timeout:
69
99
  The `DatasaurLMInvoker` supports retry and timeout configuration.
70
100
  By default, the max retries is set to 0 and the timeout is set to 30.0 seconds.
@@ -73,8 +103,6 @@ class DatasaurLMInvoker(OpenAIChatCompletionsLMInvoker):
73
103
  Retry config examples:
74
104
  ```python
75
105
  retry_config = RetryConfig(max_retries=0, timeout=None) # No retry, no timeout
76
- retry_config = RetryConfig(max_retries=0, timeout=10.0) # No retry, 10.0 seconds timeout
77
- retry_config = RetryConfig(max_retries=5, timeout=None) # 5 max retries, no timeout
78
106
  retry_config = RetryConfig(max_retries=5, timeout=10.0) # 5 max retries, 10.0 seconds timeout
79
107
  ```
80
108
 
@@ -82,34 +110,6 @@ class DatasaurLMInvoker(OpenAIChatCompletionsLMInvoker):
82
110
  ```python
83
111
  lm_invoker = DatasaurLMInvoker(..., retry_config=retry_config)
84
112
  ```
85
-
86
- Citations:
87
- The `DatasaurLMInvoker` can be configured to output the citations used to generate the response.
88
- They can be enabled by setting the `citations` parameter to `True`.
89
- When enabled, the citations will be stored as `Chunk` objects in the `citations` attribute in the output.
90
-
91
- Usage example:
92
- ```python
93
- lm_invoker = DatasaurLMInvoker(..., citations=True)
94
- ```
95
-
96
- Output example:
97
- ```python
98
- LMOutput(
99
- response="The winner of the match is team A ([Example title](https://www.example.com)).",
100
- citations=[Chunk(id="123", content="...", metadata={...}, score=0.95)],
101
- )
102
- ```
103
-
104
- Output types:
105
- The output of the `DatasaurLMInvoker` can either be:
106
- 1. `str`: A text response.
107
- 2. `LMOutput`: A Pydantic model that may contain the following attributes:
108
- 2.1. response (str)
109
- 2.2. token_usage (TokenUsage | None)
110
- 2.3. duration (float | None)
111
- 2.4. finish_details (dict[str, Any] | None)
112
- 2.5. citations (list[Chunk])
113
113
  '''
114
114
  client_kwargs: Incomplete
115
115
  citations: Incomplete