instructor 1.2.3__tar.gz → 1.2.4__tar.gz
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.
- {instructor-1.2.3 → instructor-1.2.4}/PKG-INFO +1 -1
- {instructor-1.2.3 → instructor-1.2.4}/instructor/client.py +23 -3
- {instructor-1.2.3 → instructor-1.2.4}/instructor/patch.py +4 -0
- {instructor-1.2.3 → instructor-1.2.4}/pyproject.toml +1 -1
- {instructor-1.2.3 → instructor-1.2.4}/LICENSE +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/README.md +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/__init__.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/_types/__init__.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/_types/_alias.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/cli/__init__.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/cli/cli.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/cli/files.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/cli/hub.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/cli/jobs.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/cli/usage.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/client_anthropic.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/client_cohere.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/client_groq.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/client_mistral.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/distil.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/dsl/__init__.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/dsl/citation.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/dsl/iterable.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/dsl/maybe.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/dsl/parallel.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/dsl/partial.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/dsl/simple_type.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/dsl/validators.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/exceptions.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/function_calls.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/mode.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/process_response.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/py.typed +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/retry.py +0 -0
- {instructor-1.2.3 → instructor-1.2.4}/instructor/utils.py +0 -0
|
@@ -67,6 +67,7 @@ class Instructor:
|
|
|
67
67
|
messages: List[ChatCompletionMessageParam],
|
|
68
68
|
max_retries: int = 3,
|
|
69
69
|
validation_context: dict | None = None,
|
|
70
|
+
strict: bool = True,
|
|
70
71
|
**kwargs,
|
|
71
72
|
) -> T:
|
|
72
73
|
kwargs = self.handle_kwargs(kwargs)
|
|
@@ -76,6 +77,7 @@ class Instructor:
|
|
|
76
77
|
messages=messages,
|
|
77
78
|
max_retries=max_retries,
|
|
78
79
|
validation_context=validation_context,
|
|
80
|
+
strict=strict,
|
|
79
81
|
**kwargs,
|
|
80
82
|
)
|
|
81
83
|
|
|
@@ -85,6 +87,7 @@ class Instructor:
|
|
|
85
87
|
messages: List[ChatCompletionMessageParam],
|
|
86
88
|
max_retries: int = 3,
|
|
87
89
|
validation_context: dict | None = None,
|
|
90
|
+
strict: bool = True,
|
|
88
91
|
**kwargs,
|
|
89
92
|
) -> Generator[T, None, None]:
|
|
90
93
|
assert self.provider != Provider.ANTHROPIC, "Anthropic doesn't support partial"
|
|
@@ -99,6 +102,7 @@ class Instructor:
|
|
|
99
102
|
response_model=response_model,
|
|
100
103
|
max_retries=max_retries,
|
|
101
104
|
validation_context=validation_context,
|
|
105
|
+
strict=strict,
|
|
102
106
|
**kwargs,
|
|
103
107
|
)
|
|
104
108
|
|
|
@@ -108,6 +112,7 @@ class Instructor:
|
|
|
108
112
|
response_model: Type[T],
|
|
109
113
|
max_retries: int = 3,
|
|
110
114
|
validation_context: dict | None = None,
|
|
115
|
+
strict: bool = True,
|
|
111
116
|
**kwargs,
|
|
112
117
|
) -> Iterable[T]:
|
|
113
118
|
assert self.provider != Provider.ANTHROPIC, "Anthropic doesn't support iterable"
|
|
@@ -121,6 +126,7 @@ class Instructor:
|
|
|
121
126
|
response_model=response_model,
|
|
122
127
|
max_retries=max_retries,
|
|
123
128
|
validation_context=validation_context,
|
|
129
|
+
strict=strict,
|
|
124
130
|
**kwargs,
|
|
125
131
|
)
|
|
126
132
|
|
|
@@ -130,6 +136,7 @@ class Instructor:
|
|
|
130
136
|
response_model: Type[T],
|
|
131
137
|
max_retries: int = 3,
|
|
132
138
|
validation_context: dict | None = None,
|
|
139
|
+
strict: bool = True,
|
|
133
140
|
**kwargs,
|
|
134
141
|
) -> Tuple[T, ChatCompletion | Any]:
|
|
135
142
|
kwargs = self.handle_kwargs(kwargs)
|
|
@@ -138,6 +145,7 @@ class Instructor:
|
|
|
138
145
|
response_model=response_model,
|
|
139
146
|
max_retries=max_retries,
|
|
140
147
|
validation_context=validation_context,
|
|
148
|
+
strict=strict,
|
|
141
149
|
**kwargs,
|
|
142
150
|
)
|
|
143
151
|
return model, model._raw_response
|
|
@@ -176,6 +184,7 @@ class AsyncInstructor(Instructor):
|
|
|
176
184
|
response_model: Type[T],
|
|
177
185
|
validation_context: dict | None = None,
|
|
178
186
|
max_retries: int = 3,
|
|
187
|
+
strict: bool = True,
|
|
179
188
|
**kwargs,
|
|
180
189
|
) -> T:
|
|
181
190
|
kwargs = self.handle_kwargs(kwargs)
|
|
@@ -184,6 +193,7 @@ class AsyncInstructor(Instructor):
|
|
|
184
193
|
validation_context=validation_context,
|
|
185
194
|
max_retries=max_retries,
|
|
186
195
|
messages=messages,
|
|
196
|
+
strict=strict,
|
|
187
197
|
**kwargs,
|
|
188
198
|
)
|
|
189
199
|
|
|
@@ -193,6 +203,7 @@ class AsyncInstructor(Instructor):
|
|
|
193
203
|
messages: List[ChatCompletionMessageParam],
|
|
194
204
|
validation_context: dict | None = None,
|
|
195
205
|
max_retries: int = 3,
|
|
206
|
+
strict: bool = True,
|
|
196
207
|
**kwargs,
|
|
197
208
|
) -> AsyncGenerator[T, None]:
|
|
198
209
|
assert self.provider != Provider.ANTHROPIC, "Anthropic doesn't support partial"
|
|
@@ -204,6 +215,7 @@ class AsyncInstructor(Instructor):
|
|
|
204
215
|
validation_context=validation_context,
|
|
205
216
|
max_retries=max_retries,
|
|
206
217
|
messages=messages,
|
|
218
|
+
strict=strict,
|
|
207
219
|
**kwargs,
|
|
208
220
|
):
|
|
209
221
|
yield item
|
|
@@ -214,6 +226,7 @@ class AsyncInstructor(Instructor):
|
|
|
214
226
|
messages: List[ChatCompletionMessageParam],
|
|
215
227
|
validation_context: dict | None = None,
|
|
216
228
|
max_retries: int = 3,
|
|
229
|
+
strict: bool = True,
|
|
217
230
|
**kwargs,
|
|
218
231
|
) -> AsyncGenerator[T, None]:
|
|
219
232
|
assert self.provider != Provider.ANTHROPIC, "Anthropic doesn't support iterable"
|
|
@@ -225,6 +238,7 @@ class AsyncInstructor(Instructor):
|
|
|
225
238
|
validation_context=validation_context,
|
|
226
239
|
max_retries=max_retries,
|
|
227
240
|
messages=messages,
|
|
241
|
+
strict=strict,
|
|
228
242
|
**kwargs,
|
|
229
243
|
):
|
|
230
244
|
yield item
|
|
@@ -235,6 +249,7 @@ class AsyncInstructor(Instructor):
|
|
|
235
249
|
messages: List[ChatCompletionMessageParam],
|
|
236
250
|
validation_context: dict | None = None,
|
|
237
251
|
max_retries: int = 3,
|
|
252
|
+
strict: bool = True,
|
|
238
253
|
**kwargs,
|
|
239
254
|
) -> Tuple[T, dict]:
|
|
240
255
|
kwargs = self.handle_kwargs(kwargs)
|
|
@@ -243,6 +258,7 @@ class AsyncInstructor(Instructor):
|
|
|
243
258
|
validation_context=validation_context,
|
|
244
259
|
max_retries=max_retries,
|
|
245
260
|
messages=messages,
|
|
261
|
+
strict=strict,
|
|
246
262
|
**kwargs,
|
|
247
263
|
)
|
|
248
264
|
return response, response._raw_response
|
|
@@ -274,9 +290,13 @@ def from_openai(
|
|
|
274
290
|
else:
|
|
275
291
|
provider = Provider.OPENAI
|
|
276
292
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
293
|
+
if not isinstance(client, (openai.OpenAI, openai.AsyncOpenAI)):
|
|
294
|
+
import warnings
|
|
295
|
+
|
|
296
|
+
warnings.warn(
|
|
297
|
+
"Client should be an instance of openai.OpenAI or openai.AsyncOpenAI. "
|
|
298
|
+
"Unexpected behavior may occur with other client types."
|
|
299
|
+
)
|
|
280
300
|
|
|
281
301
|
if provider in {Provider.ANYSCALE, Provider.TOGETHER}:
|
|
282
302
|
assert mode in {
|
|
@@ -116,6 +116,7 @@ def patch(
|
|
|
116
116
|
response_model: Type[T_Model] = None,
|
|
117
117
|
validation_context: dict = None,
|
|
118
118
|
max_retries: int = 1,
|
|
119
|
+
strict: bool = True,
|
|
119
120
|
*args: T_ParamSpec.args,
|
|
120
121
|
**kwargs: T_ParamSpec.kwargs,
|
|
121
122
|
) -> T_Model:
|
|
@@ -129,6 +130,7 @@ def patch(
|
|
|
129
130
|
max_retries=max_retries,
|
|
130
131
|
args=args,
|
|
131
132
|
kwargs=new_kwargs,
|
|
133
|
+
strict=strict,
|
|
132
134
|
mode=mode,
|
|
133
135
|
) # type: ignore
|
|
134
136
|
return response
|
|
@@ -138,6 +140,7 @@ def patch(
|
|
|
138
140
|
response_model: Type[T_Model] = None,
|
|
139
141
|
validation_context: dict = None,
|
|
140
142
|
max_retries: int = 1,
|
|
143
|
+
strict: bool = True,
|
|
141
144
|
*args: T_ParamSpec.args,
|
|
142
145
|
**kwargs: T_ParamSpec.kwargs,
|
|
143
146
|
) -> T_Model:
|
|
@@ -150,6 +153,7 @@ def patch(
|
|
|
150
153
|
validation_context=validation_context,
|
|
151
154
|
max_retries=max_retries,
|
|
152
155
|
args=args,
|
|
156
|
+
strict=strict,
|
|
153
157
|
kwargs=new_kwargs,
|
|
154
158
|
mode=mode,
|
|
155
159
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|