openai-sdk-helpers 0.6.0__py3-none-any.whl → 0.6.2__py3-none-any.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.
- openai_sdk_helpers/agent/__init__.py +2 -0
- openai_sdk_helpers/agent/base.py +88 -12
- openai_sdk_helpers/agent/classifier.py +905 -94
- openai_sdk_helpers/agent/configuration.py +42 -0
- openai_sdk_helpers/agent/files.py +120 -0
- openai_sdk_helpers/agent/runner.py +9 -9
- openai_sdk_helpers/agent/translator.py +2 -2
- openai_sdk_helpers/files_api.py +46 -1
- openai_sdk_helpers/prompt/classifier.jinja +28 -7
- openai_sdk_helpers/settings.py +65 -0
- openai_sdk_helpers/structure/__init__.py +4 -0
- openai_sdk_helpers/structure/base.py +79 -55
- openai_sdk_helpers/structure/classification.py +265 -43
- openai_sdk_helpers/structure/plan/enum.py +4 -0
- {openai_sdk_helpers-0.6.0.dist-info → openai_sdk_helpers-0.6.2.dist-info}/METADATA +12 -1
- {openai_sdk_helpers-0.6.0.dist-info → openai_sdk_helpers-0.6.2.dist-info}/RECORD +19 -18
- {openai_sdk_helpers-0.6.0.dist-info → openai_sdk_helpers-0.6.2.dist-info}/WHEEL +0 -0
- {openai_sdk_helpers-0.6.0.dist-info → openai_sdk_helpers-0.6.2.dist-info}/entry_points.txt +0 -0
- {openai_sdk_helpers-0.6.0.dist-info → openai_sdk_helpers-0.6.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
from enum import Enum
|
|
6
|
-
from typing import Any, Iterable, Optional
|
|
6
|
+
from typing import Any, Iterable, Optional, cast
|
|
7
7
|
|
|
8
8
|
from .base import StructureBase, spec_field
|
|
9
9
|
|
|
@@ -13,11 +13,9 @@ class TaxonomyNode(StructureBase):
|
|
|
13
13
|
|
|
14
14
|
Attributes
|
|
15
15
|
----------
|
|
16
|
-
id : str
|
|
17
|
-
Unique identifier for the taxonomy node.
|
|
18
16
|
label : str
|
|
19
17
|
Human-readable label for the taxonomy node.
|
|
20
|
-
description : str
|
|
18
|
+
description : str | None
|
|
21
19
|
Optional description of the node.
|
|
22
20
|
children : list[TaxonomyNode]
|
|
23
21
|
Child nodes in the taxonomy.
|
|
@@ -30,15 +28,14 @@ class TaxonomyNode(StructureBase):
|
|
|
30
28
|
Return the computed path for the node.
|
|
31
29
|
is_leaf
|
|
32
30
|
Return True when the taxonomy node has no children.
|
|
33
|
-
|
|
34
|
-
Return the child node matching the provided
|
|
31
|
+
child_by_path(path)
|
|
32
|
+
Return the child node matching the provided path.
|
|
35
33
|
"""
|
|
36
34
|
|
|
37
|
-
id: str = spec_field("id", description="Unique identifier for the taxonomy.")
|
|
38
35
|
label: str = spec_field(
|
|
39
36
|
"label", description="Human-readable label for the taxonomy node."
|
|
40
37
|
)
|
|
41
|
-
description:
|
|
38
|
+
description: str | None = spec_field(
|
|
42
39
|
"description",
|
|
43
40
|
description="Optional description of the taxonomy node.",
|
|
44
41
|
default=None,
|
|
@@ -88,22 +85,95 @@ class TaxonomyNode(StructureBase):
|
|
|
88
85
|
"""
|
|
89
86
|
return self.build_path()
|
|
90
87
|
|
|
91
|
-
def
|
|
92
|
-
|
|
88
|
+
def child_by_path(
|
|
89
|
+
self, path: Iterable[str] | str | None
|
|
90
|
+
) -> Optional["TaxonomyNode"]:
|
|
91
|
+
"""Return the child node matching the provided path.
|
|
93
92
|
|
|
94
93
|
Parameters
|
|
95
94
|
----------
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
path : Iterable[str] or str or None
|
|
96
|
+
Path segments or a delimited path string to locate.
|
|
98
97
|
|
|
99
98
|
Returns
|
|
100
99
|
-------
|
|
101
100
|
TaxonomyNode or None
|
|
102
101
|
Matching child node, if found.
|
|
103
102
|
"""
|
|
104
|
-
if
|
|
103
|
+
if path is None:
|
|
105
104
|
return None
|
|
106
|
-
|
|
105
|
+
if isinstance(path, str):
|
|
106
|
+
path_segments = _split_path_identifier(path)
|
|
107
|
+
else:
|
|
108
|
+
path_segments = list(path)
|
|
109
|
+
last_segment = path_segments[-1] if path_segments else None
|
|
110
|
+
if not last_segment:
|
|
111
|
+
return None
|
|
112
|
+
return next(
|
|
113
|
+
(child for child in self.children if child.label == last_segment),
|
|
114
|
+
None,
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class Taxonomy(StructureBase):
|
|
119
|
+
"""Represent a taxonomy with metadata and root nodes.
|
|
120
|
+
|
|
121
|
+
Attributes
|
|
122
|
+
----------
|
|
123
|
+
name : str
|
|
124
|
+
Human-readable taxonomy name.
|
|
125
|
+
description : str | None
|
|
126
|
+
Optional description of the taxonomy.
|
|
127
|
+
nodes : list[TaxonomyNode]
|
|
128
|
+
Root taxonomy nodes.
|
|
129
|
+
|
|
130
|
+
Methods
|
|
131
|
+
-------
|
|
132
|
+
flattened_nodes
|
|
133
|
+
Return a flattened list of all taxonomy nodes.
|
|
134
|
+
"""
|
|
135
|
+
|
|
136
|
+
name: str = spec_field("name", description="Human-readable taxonomy name.")
|
|
137
|
+
description: str | None = spec_field(
|
|
138
|
+
"description",
|
|
139
|
+
description="Optional description of the taxonomy.",
|
|
140
|
+
default=None,
|
|
141
|
+
)
|
|
142
|
+
nodes: list[TaxonomyNode] = spec_field(
|
|
143
|
+
"nodes",
|
|
144
|
+
description="Root taxonomy nodes.",
|
|
145
|
+
default_factory=list,
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
@property
|
|
149
|
+
def flattened_nodes(self) -> list[TaxonomyNode]:
|
|
150
|
+
"""Return a flattened list of all taxonomy nodes.
|
|
151
|
+
|
|
152
|
+
Returns
|
|
153
|
+
-------
|
|
154
|
+
list[TaxonomyNode]
|
|
155
|
+
Depth-first list of taxonomy nodes.
|
|
156
|
+
"""
|
|
157
|
+
return flatten_taxonomy(self.nodes)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def _split_path_identifier(path: str) -> list[str]:
|
|
161
|
+
"""Split a path identifier into label segments.
|
|
162
|
+
|
|
163
|
+
Parameters
|
|
164
|
+
----------
|
|
165
|
+
path : str
|
|
166
|
+
Path identifier to split.
|
|
167
|
+
|
|
168
|
+
Returns
|
|
169
|
+
-------
|
|
170
|
+
list[str]
|
|
171
|
+
Label segments extracted from the path identifier.
|
|
172
|
+
"""
|
|
173
|
+
delimiter = " > "
|
|
174
|
+
escape_token = "\\>"
|
|
175
|
+
segments = path.split(delimiter) if path else []
|
|
176
|
+
return [segment.replace(escape_token, delimiter) for segment in segments]
|
|
107
177
|
|
|
108
178
|
|
|
109
179
|
class ClassificationStopReason(str, Enum):
|
|
@@ -139,14 +209,14 @@ class ClassificationStopReason(str, Enum):
|
|
|
139
209
|
|
|
140
210
|
|
|
141
211
|
class ClassificationStep(StructureBase):
|
|
142
|
-
"""Represent a
|
|
212
|
+
"""Represent a classification step constrained to taxonomy node enums.
|
|
143
213
|
|
|
144
214
|
Attributes
|
|
145
215
|
----------
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
216
|
+
selected_node : Enum or None
|
|
217
|
+
Enum value of the selected taxonomy node.
|
|
218
|
+
selected_nodes : list[Enum] or None
|
|
219
|
+
Enum values of selected taxonomy nodes for multi-class classification.
|
|
150
220
|
confidence : float or None
|
|
151
221
|
Confidence score between 0 and 1.
|
|
152
222
|
stop_reason : ClassificationStopReason
|
|
@@ -156,18 +226,34 @@ class ClassificationStep(StructureBase):
|
|
|
156
226
|
|
|
157
227
|
Methods
|
|
158
228
|
-------
|
|
229
|
+
build_for_enum(enum_cls)
|
|
230
|
+
Build a ClassificationStep subclass with enum-constrained selections.
|
|
159
231
|
as_summary()
|
|
160
232
|
Return a dictionary summary of the classification step.
|
|
233
|
+
|
|
234
|
+
Examples
|
|
235
|
+
--------
|
|
236
|
+
Create a multi-class step and summarize the selections:
|
|
237
|
+
|
|
238
|
+
>>> NodeEnum = Enum("NodeEnum", {"BILLING": "billing"})
|
|
239
|
+
>>> StepEnum = ClassificationStep.build_for_enum(NodeEnum)
|
|
240
|
+
>>> step = StepEnum(
|
|
241
|
+
... selected_nodes=[NodeEnum.BILLING],
|
|
242
|
+
... confidence=0.82,
|
|
243
|
+
... stop_reason=ClassificationStopReason.STOP,
|
|
244
|
+
... )
|
|
245
|
+
>>> step.as_summary()["selected_nodes"]
|
|
246
|
+
[<NodeEnum.BILLING: 'billing'>]
|
|
161
247
|
"""
|
|
162
248
|
|
|
163
|
-
|
|
164
|
-
"
|
|
165
|
-
description="
|
|
249
|
+
selected_node: Enum | None = spec_field(
|
|
250
|
+
"selected_node",
|
|
251
|
+
description="Path identifier of the selected taxonomy node.",
|
|
166
252
|
default=None,
|
|
167
253
|
)
|
|
168
|
-
|
|
169
|
-
"
|
|
170
|
-
description="
|
|
254
|
+
selected_nodes: list[Enum] | None = spec_field(
|
|
255
|
+
"selected_nodes",
|
|
256
|
+
description="Path identifiers of selected taxonomy nodes.",
|
|
171
257
|
default=None,
|
|
172
258
|
)
|
|
173
259
|
confidence: Optional[float] = spec_field(
|
|
@@ -179,6 +265,7 @@ class ClassificationStep(StructureBase):
|
|
|
179
265
|
"stop_reason",
|
|
180
266
|
description="Reason for stopping or continuing traversal.",
|
|
181
267
|
default=ClassificationStopReason.STOP,
|
|
268
|
+
allow_null=False,
|
|
182
269
|
)
|
|
183
270
|
rationale: Optional[str] = spec_field(
|
|
184
271
|
"rationale",
|
|
@@ -186,6 +273,38 @@ class ClassificationStep(StructureBase):
|
|
|
186
273
|
default=None,
|
|
187
274
|
)
|
|
188
275
|
|
|
276
|
+
@classmethod
|
|
277
|
+
def build_for_enum(cls, enum_cls: type[Enum]) -> type["ClassificationStep"]:
|
|
278
|
+
"""Build a ClassificationStep subclass with enum-constrained fields.
|
|
279
|
+
|
|
280
|
+
Parameters
|
|
281
|
+
----------
|
|
282
|
+
enum_cls : type[Enum]
|
|
283
|
+
Enum type to use for node selections.
|
|
284
|
+
|
|
285
|
+
Returns
|
|
286
|
+
-------
|
|
287
|
+
type[ClassificationStep]
|
|
288
|
+
Specialized ClassificationStep class bound to the enum.
|
|
289
|
+
"""
|
|
290
|
+
namespace: dict[str, Any] = {
|
|
291
|
+
"__annotations__": {
|
|
292
|
+
"selected_node": enum_cls | None,
|
|
293
|
+
"selected_nodes": list[enum_cls] | None,
|
|
294
|
+
},
|
|
295
|
+
"selected_node": spec_field(
|
|
296
|
+
"selected_node",
|
|
297
|
+
description="Path identifier of the selected taxonomy node.",
|
|
298
|
+
default=None,
|
|
299
|
+
),
|
|
300
|
+
"selected_nodes": spec_field(
|
|
301
|
+
"selected_nodes",
|
|
302
|
+
description="Path identifiers of selected taxonomy nodes.",
|
|
303
|
+
default=None,
|
|
304
|
+
),
|
|
305
|
+
}
|
|
306
|
+
return cast(type["ClassificationStep"], type("BoundStep", (cls,), namespace))
|
|
307
|
+
|
|
189
308
|
def as_summary(self) -> dict[str, Any]:
|
|
190
309
|
"""Return a dictionary summary of the classification step.
|
|
191
310
|
|
|
@@ -193,47 +312,93 @@ class ClassificationStep(StructureBase):
|
|
|
193
312
|
-------
|
|
194
313
|
dict[str, Any]
|
|
195
314
|
Summary data for logging or inspection.
|
|
315
|
+
|
|
316
|
+
Examples
|
|
317
|
+
--------
|
|
318
|
+
>>> NodeEnum = Enum("NodeEnum", {"ROOT": "root"})
|
|
319
|
+
>>> StepEnum = ClassificationStep.build_for_enum(NodeEnum)
|
|
320
|
+
>>> step = StepEnum(selected_node=NodeEnum.ROOT)
|
|
321
|
+
>>> step.as_summary()["selected_node"]
|
|
322
|
+
<NodeEnum.ROOT: 'root'>
|
|
196
323
|
"""
|
|
324
|
+
selected_node = _normalize_enum_value(self.selected_node)
|
|
325
|
+
selected_nodes = [
|
|
326
|
+
_normalize_enum_value(item) for item in self.selected_nodes or []
|
|
327
|
+
]
|
|
197
328
|
return {
|
|
198
|
-
"
|
|
199
|
-
"
|
|
329
|
+
"selected_node": selected_node,
|
|
330
|
+
"selected_nodes": selected_nodes or None,
|
|
200
331
|
"confidence": self.confidence,
|
|
201
332
|
"stop_reason": self.stop_reason.value,
|
|
202
333
|
}
|
|
203
334
|
|
|
204
335
|
|
|
336
|
+
def _normalize_enum_value(value: Any) -> Any:
|
|
337
|
+
"""Normalize enum values into raw primitives.
|
|
338
|
+
|
|
339
|
+
Parameters
|
|
340
|
+
----------
|
|
341
|
+
value : Any
|
|
342
|
+
Value to normalize.
|
|
343
|
+
|
|
344
|
+
Returns
|
|
345
|
+
-------
|
|
346
|
+
Any
|
|
347
|
+
Primitive value suitable for summaries.
|
|
348
|
+
"""
|
|
349
|
+
if isinstance(value, Enum):
|
|
350
|
+
return value.value
|
|
351
|
+
return value
|
|
352
|
+
|
|
353
|
+
|
|
205
354
|
class ClassificationResult(StructureBase):
|
|
206
355
|
"""Represent the final result of taxonomy traversal.
|
|
207
356
|
|
|
208
357
|
Attributes
|
|
209
358
|
----------
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
359
|
+
final_node : TaxonomyNode or None
|
|
360
|
+
Resolved taxonomy node for the final selection.
|
|
361
|
+
final_nodes : list[TaxonomyNode] or None
|
|
362
|
+
Resolved taxonomy nodes for the final selections across branches.
|
|
214
363
|
confidence : float or None
|
|
215
364
|
Confidence score for the final selection.
|
|
216
365
|
stop_reason : ClassificationStopReason
|
|
217
366
|
Reason the traversal ended.
|
|
218
367
|
path : list[ClassificationStep]
|
|
219
368
|
Ordered list of classification steps.
|
|
369
|
+
path_nodes : list[TaxonomyNode]
|
|
370
|
+
Resolved taxonomy nodes selected across the path.
|
|
220
371
|
|
|
221
372
|
Methods
|
|
222
373
|
-------
|
|
223
374
|
depth
|
|
224
375
|
Return the number of classification steps recorded.
|
|
225
|
-
|
|
226
|
-
Return the
|
|
376
|
+
path_identifiers
|
|
377
|
+
Return the identifiers selected at each step.
|
|
378
|
+
|
|
379
|
+
Examples
|
|
380
|
+
--------
|
|
381
|
+
Summarize single and multi-class output:
|
|
382
|
+
|
|
383
|
+
>>> node = TaxonomyNode(label="Tax")
|
|
384
|
+
>>> result = ClassificationResult(
|
|
385
|
+
... final_node=node,
|
|
386
|
+
... final_nodes=[node],
|
|
387
|
+
... confidence=0.91,
|
|
388
|
+
... stop_reason=ClassificationStopReason.STOP,
|
|
389
|
+
... )
|
|
390
|
+
>>> result.final_nodes
|
|
391
|
+
[TaxonomyNode(label='Tax', description=None, children=[])]
|
|
227
392
|
"""
|
|
228
393
|
|
|
229
|
-
|
|
230
|
-
"
|
|
231
|
-
description="
|
|
394
|
+
final_node: TaxonomyNode | None = spec_field(
|
|
395
|
+
"final_node",
|
|
396
|
+
description="Resolved taxonomy node for the final selection.",
|
|
232
397
|
default=None,
|
|
233
398
|
)
|
|
234
|
-
|
|
235
|
-
"
|
|
236
|
-
description="
|
|
399
|
+
final_nodes: list[TaxonomyNode] | None = spec_field(
|
|
400
|
+
"final_nodes",
|
|
401
|
+
description="Resolved taxonomy nodes for the final selections.",
|
|
237
402
|
default=None,
|
|
238
403
|
)
|
|
239
404
|
confidence: Optional[float] = spec_field(
|
|
@@ -251,6 +416,11 @@ class ClassificationResult(StructureBase):
|
|
|
251
416
|
description="Ordered list of classification steps.",
|
|
252
417
|
default_factory=list,
|
|
253
418
|
)
|
|
419
|
+
path_nodes: list[TaxonomyNode] = spec_field(
|
|
420
|
+
"path_nodes",
|
|
421
|
+
description="Resolved taxonomy nodes selected across the path.",
|
|
422
|
+
default_factory=list,
|
|
423
|
+
)
|
|
254
424
|
|
|
255
425
|
@property
|
|
256
426
|
def depth(self) -> int:
|
|
@@ -264,15 +434,35 @@ class ClassificationResult(StructureBase):
|
|
|
264
434
|
return len(self.path)
|
|
265
435
|
|
|
266
436
|
@property
|
|
267
|
-
def
|
|
268
|
-
"""Return the
|
|
437
|
+
def path_identifiers(self) -> list[str]:
|
|
438
|
+
"""Return the identifiers selected at each step.
|
|
269
439
|
|
|
270
440
|
Returns
|
|
271
441
|
-------
|
|
272
442
|
list[str]
|
|
273
|
-
|
|
443
|
+
Identifiers selected at each classification step.
|
|
444
|
+
|
|
445
|
+
Examples
|
|
446
|
+
--------
|
|
447
|
+
>>> steps = [
|
|
448
|
+
... ClassificationStep(selected_node="Root"),
|
|
449
|
+
... ClassificationStep(selected_nodes=["Root > Leaf", "Root > Branch"]),
|
|
450
|
+
... ]
|
|
451
|
+
>>> ClassificationResult(
|
|
452
|
+
... stop_reason=ClassificationStopReason.STOP,
|
|
453
|
+
... path=steps,
|
|
454
|
+
... ).path_identifiers
|
|
455
|
+
['Root', 'Root > Leaf', 'Root > Branch']
|
|
274
456
|
"""
|
|
275
|
-
|
|
457
|
+
identifiers: list[str] = []
|
|
458
|
+
for step in self.path:
|
|
459
|
+
if step.selected_nodes:
|
|
460
|
+
identifiers.extend(
|
|
461
|
+
_normalize_enum_value(value) for value in step.selected_nodes
|
|
462
|
+
)
|
|
463
|
+
elif step.selected_node:
|
|
464
|
+
identifiers.append(_normalize_enum_value(step.selected_node))
|
|
465
|
+
return [identifier for identifier in identifiers if identifier]
|
|
276
466
|
|
|
277
467
|
|
|
278
468
|
def flatten_taxonomy(nodes: Iterable[TaxonomyNode]) -> list[TaxonomyNode]:
|
|
@@ -296,10 +486,42 @@ def flatten_taxonomy(nodes: Iterable[TaxonomyNode]) -> list[TaxonomyNode]:
|
|
|
296
486
|
return flattened
|
|
297
487
|
|
|
298
488
|
|
|
489
|
+
def taxonomy_enum_path(value: Enum | str | None) -> list[str]:
|
|
490
|
+
"""Return the taxonomy path segments for an enum value.
|
|
491
|
+
|
|
492
|
+
Parameters
|
|
493
|
+
----------
|
|
494
|
+
value : Enum or str or None
|
|
495
|
+
Enum member or path identifier string to split. If None, return an
|
|
496
|
+
empty list.
|
|
497
|
+
|
|
498
|
+
Returns
|
|
499
|
+
-------
|
|
500
|
+
list[str]
|
|
501
|
+
Path segments extracted from the taxonomy identifier.
|
|
502
|
+
|
|
503
|
+
Examples
|
|
504
|
+
--------
|
|
505
|
+
>>> StepEnum = Enum("StepEnum", {"ROOT_LEAF": "Root > Leaf"})
|
|
506
|
+
>>> taxonomy_enum_path(StepEnum.ROOT_LEAF)
|
|
507
|
+
['Root', 'Leaf']
|
|
508
|
+
"""
|
|
509
|
+
if value is None:
|
|
510
|
+
return []
|
|
511
|
+
normalized_value = _normalize_enum_value(value)
|
|
512
|
+
if not normalized_value:
|
|
513
|
+
return []
|
|
514
|
+
if not isinstance(normalized_value, str):
|
|
515
|
+
normalized_value = str(normalized_value)
|
|
516
|
+
return _split_path_identifier(normalized_value)
|
|
517
|
+
|
|
518
|
+
|
|
299
519
|
__all__ = [
|
|
300
520
|
"ClassificationResult",
|
|
301
521
|
"ClassificationStep",
|
|
302
522
|
"ClassificationStopReason",
|
|
523
|
+
"Taxonomy",
|
|
303
524
|
"TaxonomyNode",
|
|
304
525
|
"flatten_taxonomy",
|
|
526
|
+
"taxonomy_enum_path",
|
|
305
527
|
]
|
|
@@ -29,6 +29,8 @@ class AgentEnum(CrosswalkJSONEnum):
|
|
|
29
29
|
Translation agent for language conversion.
|
|
30
30
|
VALIDATOR : str
|
|
31
31
|
Validation agent for checking constraints and guardrails.
|
|
32
|
+
CLASSIFIER : str
|
|
33
|
+
Taxonomy classifier agent for structured label selection.
|
|
32
34
|
PLANNER : str
|
|
33
35
|
Meta-planning agent for generating execution plans.
|
|
34
36
|
DESIGNER : str
|
|
@@ -58,6 +60,7 @@ class AgentEnum(CrosswalkJSONEnum):
|
|
|
58
60
|
SUMMARIZER = "SummarizerAgent"
|
|
59
61
|
TRANSLATOR = "TranslatorAgent"
|
|
60
62
|
VALIDATOR = "ValidatorAgent"
|
|
63
|
+
CLASSIFIER = "TaxonomyClassifierAgent"
|
|
61
64
|
PLANNER = "MetaPlanner"
|
|
62
65
|
DESIGNER = "AgentDesigner"
|
|
63
66
|
BUILDER = "AgentBuilder"
|
|
@@ -89,6 +92,7 @@ class AgentEnum(CrosswalkJSONEnum):
|
|
|
89
92
|
"SUMMARIZER": {"value": "SummarizerAgent"},
|
|
90
93
|
"TRANSLATOR": {"value": "TranslatorAgent"},
|
|
91
94
|
"VALIDATOR": {"value": "ValidatorAgent"},
|
|
95
|
+
"CLASSIFIER": {"value": "TaxonomyClassifierAgent"},
|
|
92
96
|
"PLANNER": {"value": "MetaPlanner"},
|
|
93
97
|
"DESIGNER": {"value": "AgentDesigner"},
|
|
94
98
|
"BUILDER": {"value": "AgentBuilder"},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: openai-sdk-helpers
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.2
|
|
4
4
|
Summary: Composable helpers for OpenAI SDK agents, prompts, and storage
|
|
5
5
|
Author: openai-sdk-helpers maintainers
|
|
6
6
|
License: MIT
|
|
@@ -97,6 +97,7 @@ The `agent` module provides a higher-level abstraction for building agents, whil
|
|
|
97
97
|
- **SummarizerAgent**: Generate concise summaries from provided text
|
|
98
98
|
- **TranslatorAgent**: Translate text into target languages
|
|
99
99
|
- **ValidatorAgent**: Check inputs and outputs against safety guardrails
|
|
100
|
+
- **TaxonomyClassifierAgent**: Classify text into taxonomy-driven labels
|
|
100
101
|
|
|
101
102
|
#### Response Module (Built on `openai` SDK)
|
|
102
103
|
- **Response handling utilities** for direct API control with fine-grained message management
|
|
@@ -210,12 +211,18 @@ These use the `agent` module built on `openai-agents` SDK:
|
|
|
210
211
|
```python
|
|
211
212
|
from openai_sdk_helpers.agent import (
|
|
212
213
|
SummarizerAgent,
|
|
214
|
+
TaxonomyClassifierAgent,
|
|
213
215
|
TranslatorAgent,
|
|
214
216
|
ValidatorAgent,
|
|
215
217
|
)
|
|
218
|
+
from openai_sdk_helpers.structure import TaxonomyNode
|
|
216
219
|
|
|
217
220
|
# Initialize agents with a default model
|
|
218
221
|
summarizer = SummarizerAgent(default_model="gpt-4o-mini")
|
|
222
|
+
classifier = TaxonomyClassifierAgent(
|
|
223
|
+
model="gpt-4o-mini",
|
|
224
|
+
taxonomy=[TaxonomyNode(label="Billing"), TaxonomyNode(label="Support")],
|
|
225
|
+
)
|
|
219
226
|
translator = TranslatorAgent(default_model="gpt-4o-mini")
|
|
220
227
|
validator = ValidatorAgent(default_model="gpt-4o-mini")
|
|
221
228
|
|
|
@@ -227,6 +234,10 @@ print(summary.text)
|
|
|
227
234
|
translation = translator.run_sync("Bonjour", target_language="English")
|
|
228
235
|
print(translation)
|
|
229
236
|
|
|
237
|
+
# Classify text against a taxonomy
|
|
238
|
+
classification = classifier.run_sync("I need help with my invoice")
|
|
239
|
+
print(classification.final_node)
|
|
240
|
+
|
|
230
241
|
# Validate against guardrails
|
|
231
242
|
validation = validator.run_sync(
|
|
232
243
|
"Share meeting notes with names removed",
|
|
@@ -2,20 +2,21 @@ openai_sdk_helpers/__init__.py,sha256=8I469KuzrbAjhNX2A5UnYt_kSmjXqQbfHectTeUx7T
|
|
|
2
2
|
openai_sdk_helpers/cli.py,sha256=BDc08NqWVfL4GBekxMfN5IPPB4pmN1Od9sVpKtIJRZk,8025
|
|
3
3
|
openai_sdk_helpers/environment.py,sha256=mNoswzIdv37tTRhFwA2B6_Onxsm7vhfjPArfwhYuL7g,1825
|
|
4
4
|
openai_sdk_helpers/errors.py,sha256=ZclLp94o08fSsFNjFn_yrX9yTjw1RE0v7A5T1hBChUc,2925
|
|
5
|
-
openai_sdk_helpers/files_api.py,sha256=
|
|
5
|
+
openai_sdk_helpers/files_api.py,sha256=kn-A2pwiNkxMd035PkWDLi_EWzccuEnGyMpLQcY-aVY,14086
|
|
6
6
|
openai_sdk_helpers/logging.py,sha256=djtMo_R_88JjxJeUGU_hSlYCTRv3ffoSu1ocOKrUBIw,1153
|
|
7
7
|
openai_sdk_helpers/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
openai_sdk_helpers/settings.py,sha256=
|
|
8
|
+
openai_sdk_helpers/settings.py,sha256=9qTdEIWuvQfQEQI8MU6STUDvbOk-I9FdmAEDjb2Zwx8,13316
|
|
9
9
|
openai_sdk_helpers/tools.py,sha256=8hhcytpmDfoXV16UQbDmDVV0rhLOn8c_VjXO8XaTFLQ,19000
|
|
10
10
|
openai_sdk_helpers/types.py,sha256=ejCG0rYqJhjOQvKLoNnzq-TzcKCFt69GVfi7y805NkU,1451
|
|
11
|
-
openai_sdk_helpers/agent/__init__.py,sha256=
|
|
12
|
-
openai_sdk_helpers/agent/base.py,sha256=
|
|
13
|
-
openai_sdk_helpers/agent/classifier.py,sha256=
|
|
14
|
-
openai_sdk_helpers/agent/configuration.py,sha256=
|
|
11
|
+
openai_sdk_helpers/agent/__init__.py,sha256=qyzKzPhD8KsEl6d79XERK32AK5It_BZNOqChOpBdmhg,1199
|
|
12
|
+
openai_sdk_helpers/agent/base.py,sha256=vLs0oALhxsd_Xy5dGjSZTUFTug-YwZkF1LabQ2ruLxk,29508
|
|
13
|
+
openai_sdk_helpers/agent/classifier.py,sha256=GWgjQxkh1QbZhKlcDCkj-aNgpa8seJWxTfbtXyQSkSg,34889
|
|
14
|
+
openai_sdk_helpers/agent/configuration.py,sha256=ZeH4ErgVe-BZamjUeNONbQi60ViolgYAWh-c8hNAQTw,15810
|
|
15
15
|
openai_sdk_helpers/agent/coordinator.py,sha256=lVjA0yI-GhGKlqbNR_k9GOCrUjFoZ0QoqRaafHckyME,18052
|
|
16
|
-
openai_sdk_helpers/agent/
|
|
16
|
+
openai_sdk_helpers/agent/files.py,sha256=H7UfSZSjFUbv1cjRvNld9kZwIjc5wPq4vynqU8HgGJE,4478
|
|
17
|
+
openai_sdk_helpers/agent/runner.py,sha256=uNf8FiLIlZsbSvE-CopYhv5sPAyxU2te0OaBBxO9RWY,3613
|
|
17
18
|
openai_sdk_helpers/agent/summarizer.py,sha256=-yVm-KdTvGRXGj1MlEikTAFYVlPoovLNIL3Tc_WYIzs,3653
|
|
18
|
-
openai_sdk_helpers/agent/translator.py,sha256=
|
|
19
|
+
openai_sdk_helpers/agent/translator.py,sha256=Skke5wyZTpo_9gMcwHRyoBQl00zTBeXnIUujUIr2ZDE,6017
|
|
19
20
|
openai_sdk_helpers/agent/utils.py,sha256=DTD5foCqGYfXf13F2bZMYIQROl7SbDSy5GDPGi0Zl-0,1089
|
|
20
21
|
openai_sdk_helpers/agent/validator.py,sha256=krktzjaHhEprn76F7hD4cH6H2CwucmFN1KWJ_vjl01g,4774
|
|
21
22
|
openai_sdk_helpers/agent/search/__init__.py,sha256=LXXzEcX2MU7_htHRdRCGPw0hsr9CrZn0ESii7GZJMBw,806
|
|
@@ -29,7 +30,7 @@ openai_sdk_helpers/extract/extractor.py,sha256=vmRJyhKDEYAVfRk0KMgLH5hTqUfDAUyWB
|
|
|
29
30
|
openai_sdk_helpers/extract/generator.py,sha256=K9Euq0IaWs82oe5aRm73_18DelLKYyuH8VhfZ1_ZCEU,14695
|
|
30
31
|
openai_sdk_helpers/prompt/__init__.py,sha256=MOqgKwG9KLqKudoKRlUfLxiSmdOi2aD6hNrWDFqLHkk,418
|
|
31
32
|
openai_sdk_helpers/prompt/base.py,sha256=6X0zeopEvO0ba8207O8Nnj1QvFZEZier7kNNh4qkcmE,7782
|
|
32
|
-
openai_sdk_helpers/prompt/classifier.jinja,sha256=
|
|
33
|
+
openai_sdk_helpers/prompt/classifier.jinja,sha256=6od2DyyEUUrT0AmeJfJ57gJxJ6gdbPc11vff-VNywNk,1895
|
|
33
34
|
openai_sdk_helpers/prompt/extractor_config_agent_instructions.jinja,sha256=vCrsoUnsgHWSr7OS_ojMUjmPtHfbyv9bzKfaMaCJ99E,329
|
|
34
35
|
openai_sdk_helpers/prompt/extractor_config_generator.jinja,sha256=9rZ1PZdoQtnxDxFUlKRb0SooIEfNw4_Em99n9xvFyyU,960
|
|
35
36
|
openai_sdk_helpers/prompt/extractor_config_generator_instructions.jinja,sha256=GqV3DrGObyER_Fa-GMGGqhWBrQIH9FFlyKdgTjidyzg,534
|
|
@@ -54,10 +55,10 @@ openai_sdk_helpers/response/vector_store.py,sha256=HClp6O_g20uklQTY7trC4age3rtDm
|
|
|
54
55
|
openai_sdk_helpers/streamlit_app/__init__.py,sha256=3yAkl6qV71cqtT5YFZuC9Bkqit0NtffDV6jmMWpT1k4,812
|
|
55
56
|
openai_sdk_helpers/streamlit_app/app.py,sha256=kkjtdCKVwrJ9nZWuBArm3dhvcjMESX0TMqAiF61_JLM,17402
|
|
56
57
|
openai_sdk_helpers/streamlit_app/configuration.py,sha256=0KeJ4HqCNFthBHsedV6ptqHluAcTPBb5_TujFOGkIUU,16685
|
|
57
|
-
openai_sdk_helpers/structure/__init__.py,sha256
|
|
58
|
+
openai_sdk_helpers/structure/__init__.py,sha256=ErtNlTADV4cc7s27i_CbQATd2PD9xcJd8_D273QmyOI,4253
|
|
58
59
|
openai_sdk_helpers/structure/agent_blueprint.py,sha256=VyJWkgPNzAYKRDMeR1M4kE6qqQURnwqtrrEn0TRJf0g,9698
|
|
59
|
-
openai_sdk_helpers/structure/base.py,sha256=
|
|
60
|
-
openai_sdk_helpers/structure/classification.py,sha256=
|
|
60
|
+
openai_sdk_helpers/structure/base.py,sha256=UrnNNU9qQ9mEES8MB9y6QESbDgPXH47XW8LVWSxYUYM,25280
|
|
61
|
+
openai_sdk_helpers/structure/classification.py,sha256=Vk7LGG3pty5T0Eh94Pao7kWY8_Wcuw37ywdPDcnElrg,15316
|
|
61
62
|
openai_sdk_helpers/structure/extraction.py,sha256=wODP0iLAhhsdQkMWRYPYTiLUMU8bFMKiBjPl3PKUleg,37335
|
|
62
63
|
openai_sdk_helpers/structure/prompt.py,sha256=ZfsaHdA0hj5zmZDrOdpXjCsC8U-jjzwFG4JBsWYiaH4,1535
|
|
63
64
|
openai_sdk_helpers/structure/responses.py,sha256=WUwh0DhXj24pkvgqH1FMkdx5V2ArdvdtrDN_fuMBtDU,4882
|
|
@@ -67,7 +68,7 @@ openai_sdk_helpers/structure/validation.py,sha256=D03rlyBDn22qNjTGaGsjhsk3g50oPm
|
|
|
67
68
|
openai_sdk_helpers/structure/vector_search.py,sha256=XNQsG6_-c7X6TpXjqWOdKCmqXatX1gwd0zq-hII3cz4,5782
|
|
68
69
|
openai_sdk_helpers/structure/web_search.py,sha256=cPqjwip0xS3OHf7yQ3B_t4VJSlviqgqzPpOkT8_qLvY,4330
|
|
69
70
|
openai_sdk_helpers/structure/plan/__init__.py,sha256=IGr0Tk4inN_8o7fT2N02_FTi6U6l2T9_npcQHAlBwKA,1076
|
|
70
|
-
openai_sdk_helpers/structure/plan/enum.py,sha256=
|
|
71
|
+
openai_sdk_helpers/structure/plan/enum.py,sha256=sXi4Qk3zalF1vhLdo9c_hyhPSNr1hDZHhK1WygEIc2w,3273
|
|
71
72
|
openai_sdk_helpers/structure/plan/helpers.py,sha256=Vc6dBTMFrNWlsaCTpEImEIKjfFq4BSSxNjB4K8dywOQ,5139
|
|
72
73
|
openai_sdk_helpers/structure/plan/plan.py,sha256=yRBx0Z7tog4sGyq7s1kJHvqQOzLpKT8JJ9Ur5j-lhtk,9130
|
|
73
74
|
openai_sdk_helpers/structure/plan/task.py,sha256=DAfgJIa3Yq2AMEzaX20o8SdOs2AlM28pPE9GfbmXk3o,3547
|
|
@@ -91,8 +92,8 @@ openai_sdk_helpers/vector_storage/__init__.py,sha256=L5LxO09puh9_yBB9IDTvc1CvVkA
|
|
|
91
92
|
openai_sdk_helpers/vector_storage/cleanup.py,sha256=sZ4ZSTlnjF52o9Cc8A9dTX37ZYXXDxS_fdIpoOBWvrg,3666
|
|
92
93
|
openai_sdk_helpers/vector_storage/storage.py,sha256=t_ukacaXRa9EXE4-3BxsrB4Rjhu6nTu7NA9IjCJBIpQ,24259
|
|
93
94
|
openai_sdk_helpers/vector_storage/types.py,sha256=jTCcOYMeOpZWvcse0z4T3MVs-RBOPC-fqWTBeQrgafU,1639
|
|
94
|
-
openai_sdk_helpers-0.6.
|
|
95
|
-
openai_sdk_helpers-0.6.
|
|
96
|
-
openai_sdk_helpers-0.6.
|
|
97
|
-
openai_sdk_helpers-0.6.
|
|
98
|
-
openai_sdk_helpers-0.6.
|
|
95
|
+
openai_sdk_helpers-0.6.2.dist-info/METADATA,sha256=TGZjA_nQ2FDm9KeEjun4MrIAUl-zAxB-Xi5UCUkn8nY,24622
|
|
96
|
+
openai_sdk_helpers-0.6.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
97
|
+
openai_sdk_helpers-0.6.2.dist-info/entry_points.txt,sha256=gEOD1ZeXe8d2OP-KzUlG-b_9D9yUZTCt-GFW3EDbIIY,63
|
|
98
|
+
openai_sdk_helpers-0.6.2.dist-info/licenses/LICENSE,sha256=CUhc1NrE50bs45tcXF7OcTQBKEvkUuLqeOHgrWQ5jaA,1067
|
|
99
|
+
openai_sdk_helpers-0.6.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|