openai-sdk-helpers 0.0.2__py3-none-any.whl → 0.0.4__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.
Files changed (41) hide show
  1. {openai_sdk_helpers-0.0.2.dist-info → openai_sdk_helpers-0.0.4.dist-info}/METADATA +57 -4
  2. openai_sdk_helpers-0.0.4.dist-info/RECORD +4 -0
  3. openai_sdk_helpers/__init__.py +0 -34
  4. openai_sdk_helpers/agent/__init__.py +0 -23
  5. openai_sdk_helpers/agent/base.py +0 -432
  6. openai_sdk_helpers/agent/config.py +0 -66
  7. openai_sdk_helpers/agent/project_manager.py +0 -416
  8. openai_sdk_helpers/agent/runner.py +0 -117
  9. openai_sdk_helpers/agent/utils.py +0 -47
  10. openai_sdk_helpers/agent/vector_search.py +0 -418
  11. openai_sdk_helpers/agent/web_search.py +0 -404
  12. openai_sdk_helpers/config.py +0 -141
  13. openai_sdk_helpers/enums/__init__.py +0 -7
  14. openai_sdk_helpers/enums/base.py +0 -17
  15. openai_sdk_helpers/environment.py +0 -27
  16. openai_sdk_helpers/prompt/__init__.py +0 -77
  17. openai_sdk_helpers/response/__init__.py +0 -16
  18. openai_sdk_helpers/response/base.py +0 -477
  19. openai_sdk_helpers/response/messages.py +0 -211
  20. openai_sdk_helpers/response/runner.py +0 -42
  21. openai_sdk_helpers/response/tool_call.py +0 -70
  22. openai_sdk_helpers/structure/__init__.py +0 -57
  23. openai_sdk_helpers/structure/base.py +0 -591
  24. openai_sdk_helpers/structure/plan/__init__.py +0 -13
  25. openai_sdk_helpers/structure/plan/enum.py +0 -48
  26. openai_sdk_helpers/structure/plan/plan.py +0 -104
  27. openai_sdk_helpers/structure/plan/task.py +0 -122
  28. openai_sdk_helpers/structure/prompt.py +0 -24
  29. openai_sdk_helpers/structure/responses.py +0 -148
  30. openai_sdk_helpers/structure/summary.py +0 -65
  31. openai_sdk_helpers/structure/vector_search.py +0 -82
  32. openai_sdk_helpers/structure/web_search.py +0 -46
  33. openai_sdk_helpers/utils/__init__.py +0 -13
  34. openai_sdk_helpers/utils/core.py +0 -208
  35. openai_sdk_helpers/vector_storage/__init__.py +0 -15
  36. openai_sdk_helpers/vector_storage/cleanup.py +0 -91
  37. openai_sdk_helpers/vector_storage/storage.py +0 -501
  38. openai_sdk_helpers/vector_storage/types.py +0 -58
  39. openai_sdk_helpers-0.0.2.dist-info/RECORD +0 -40
  40. {openai_sdk_helpers-0.0.2.dist-info → openai_sdk_helpers-0.0.4.dist-info}/WHEEL +0 -0
  41. {openai_sdk_helpers-0.0.2.dist-info → openai_sdk_helpers-0.0.4.dist-info}/licenses/LICENSE +0 -0
@@ -1,104 +0,0 @@
1
- """Structured output model for agent plans."""
2
-
3
- from __future__ import annotations
4
-
5
- from typing import List
6
-
7
- from ..base import BaseStructure, spec_field
8
- from .task import AgentTaskStructure
9
-
10
-
11
- class PlanStructure(BaseStructure):
12
- """Structured representation of an ordered list of agent tasks.
13
-
14
- Methods
15
- -------
16
- print()
17
- Return a formatted description of every task in order.
18
- __len__()
19
- Return the count of tasks in the plan.
20
- append(task)
21
- Append an ``AgentTaskStructure`` to the plan.
22
- """
23
-
24
- tasks: List[AgentTaskStructure] = spec_field(
25
- "tasks",
26
- default_factory=list,
27
- description="Ordered list of agent tasks to execute.",
28
- )
29
-
30
- def print(self) -> str:
31
- """Return a human-readable representation of the plan.
32
-
33
- Parameters
34
- ----------
35
- None
36
-
37
- Returns
38
- -------
39
- str
40
- Concatenated description of each plan step.
41
-
42
- Raises
43
- ------
44
- None
45
-
46
- Examples
47
- --------
48
- >>> PlanStructure().print()
49
- 'No tasks defined.'
50
- """
51
- if not self.tasks:
52
- return "No tasks defined."
53
- return "\n\n".join(
54
- [f"Task {idx + 1}:\n{task.print()}" for idx, task in enumerate(self.tasks)]
55
- )
56
-
57
- def __len__(self) -> int:
58
- """Return the number of tasks contained in the plan.
59
-
60
- Parameters
61
- ----------
62
- None
63
-
64
- Returns
65
- -------
66
- int
67
- Count of stored agent tasks.
68
-
69
- Raises
70
- ------
71
- None
72
-
73
- Examples
74
- --------
75
- >>> len(PlanStructure())
76
- 0
77
- """
78
- return len(self.tasks)
79
-
80
- def append(self, task: AgentTaskStructure) -> None:
81
- """Add a task to the plan in execution order.
82
-
83
- Parameters
84
- ----------
85
- task : AgentTaskStructure
86
- Task to append to the plan.
87
-
88
- Returns
89
- -------
90
- None
91
-
92
- Raises
93
- ------
94
- None
95
-
96
- Examples
97
- --------
98
- >>> plan = PlanStructure()
99
- >>> plan.append(AgentTaskStructure(prompt="Test")) # doctest: +SKIP
100
- """
101
- self.tasks.append(task)
102
-
103
-
104
- __all__ = ["PlanStructure"]
@@ -1,122 +0,0 @@
1
- """Structured output model for agent tasks."""
2
-
3
- from __future__ import annotations
4
-
5
- from datetime import datetime
6
- from typing import List, Literal, Optional
7
-
8
- from pydantic import field_validator
9
-
10
- from ..base import BaseStructure, spec_field
11
- from .enum import AgentEnum
12
-
13
-
14
- class AgentTaskStructure(BaseStructure):
15
- """Structured representation of a single agent task.
16
-
17
- Methods
18
- -------
19
- print()
20
- Return a formatted multi-line description of the task.
21
- """
22
-
23
- task_type: AgentEnum = spec_field(
24
- "task_type",
25
- default=AgentEnum.WEB_SEARCH,
26
- description="Agent type responsible for executing the task.",
27
- )
28
- prompt: str = spec_field(
29
- "prompt",
30
- description="Input passed to the agent.",
31
- examples=["Research the latest trends in AI-assisted data analysis."],
32
- )
33
- context: List[str] | None = spec_field(
34
- "context",
35
- default_factory=list,
36
- description="Additional context forwarded to the agent callable.",
37
- )
38
- start_date: Optional[datetime] = spec_field(
39
- "start_date",
40
- default=None,
41
- description="Timestamp marking when the task started (UTC).",
42
- )
43
- end_date: Optional[datetime] = spec_field(
44
- "end_date",
45
- default=None,
46
- description="Timestamp marking when the task completed (UTC).",
47
- )
48
- status: Literal["waiting", "running", "done", "error"] = spec_field(
49
- "status",
50
- default="waiting",
51
- description="Current lifecycle state for the task.",
52
- )
53
- results: List[str] = spec_field(
54
- "results",
55
- default_factory=list,
56
- description="Normalized string outputs returned by the agent.",
57
- )
58
-
59
- @field_validator("task_type", mode="before")
60
- @classmethod
61
- def _coerce_task_type(cls, value: AgentEnum | str) -> AgentEnum:
62
- """Coerce string inputs into ``AgentEnum`` values.
63
-
64
- Parameters
65
- ----------
66
- value : AgentEnum | str
67
- Enum instance or enum value string.
68
-
69
- Returns
70
- -------
71
- AgentEnum
72
- Parsed enum instance.
73
-
74
- Raises
75
- ------
76
- ValueError
77
- If the value cannot be mapped to a valid enum member.
78
-
79
- Examples
80
- --------
81
- >>> AgentTaskStructure._coerce_task_type("WebAgentSearch")
82
- <AgentEnum.WEB_SEARCH: 'WebAgentSearch'>
83
- """
84
- if isinstance(value, AgentEnum):
85
- return value
86
- return AgentEnum(value)
87
-
88
- def print(self) -> str:
89
- """Return a human-readable representation of the task.
90
-
91
- Parameters
92
- ----------
93
- None
94
-
95
- Returns
96
- -------
97
- str
98
- Multi-line description of the task metadata.
99
-
100
- Raises
101
- ------
102
- None
103
-
104
- Examples
105
- --------
106
- >>> AgentTaskStructure(prompt="Test").print()
107
- 'Task type: ...' # doctest: +SKIP
108
- """
109
- return "\n".join(
110
- [
111
- BaseStructure.format_output("Task type", self.task_type),
112
- BaseStructure.format_output("Prompt", self.prompt),
113
- BaseStructure.format_output("Context", self.context),
114
- BaseStructure.format_output("Status", self.status),
115
- BaseStructure.format_output("Start date", self.start_date),
116
- BaseStructure.format_output("End date", self.end_date),
117
- BaseStructure.format_output("Results", self.results),
118
- ]
119
- )
120
-
121
-
122
- __all__ = ["AgentTaskStructure"]
@@ -1,24 +0,0 @@
1
- """Shared structured output model for prompts."""
2
-
3
- from __future__ import annotations
4
-
5
- from .base import BaseStructure, spec_field
6
-
7
-
8
- class PromptStructure(BaseStructure):
9
- """The prompt text to use for the OpenAI API request.
10
-
11
- Methods
12
- -------
13
- print()
14
- Return the formatted model fields.
15
- """
16
-
17
- prompt: str = spec_field(
18
- "prompt",
19
- description="The prompt text to use for the OpenAI API request.",
20
- examples=[
21
- "What is the capital of France?",
22
- "Generate a summary of the latest news in AI.",
23
- ],
24
- )
@@ -1,148 +0,0 @@
1
- """OpenAI response and tool helpers for structured outputs."""
2
-
3
- from __future__ import annotations
4
-
5
- from typing import Type
6
-
7
- from openai.types.responses.response_format_text_json_schema_config_param import (
8
- ResponseFormatTextJSONSchemaConfigParam,
9
- )
10
- from openai.types.responses.response_text_config_param import ResponseTextConfigParam
11
-
12
- from .base import BaseStructure
13
- from ..utils import log
14
-
15
-
16
- def assistant_tool_definition(
17
- structure: Type[BaseStructure],
18
- name: str,
19
- description: str,
20
- force_required: bool = False,
21
- ) -> dict:
22
- """Build a function tool definition for OpenAI Assistants.
23
-
24
- Parameters
25
- ----------
26
- structure : type[BaseStructure]
27
- Structure class that defines the tool schema.
28
- name : str
29
- Name of the function tool.
30
- description : str
31
- Description of what the function tool does.
32
- force_required : bool, default=False
33
- When ``True``, mark all object properties as required.
34
-
35
- Returns
36
- -------
37
- dict
38
- Assistant tool definition payload.
39
- """
40
- log(f"{structure.__name__}::assistant_tool_definition")
41
- return {
42
- "type": "function",
43
- "function": {
44
- "name": name,
45
- "description": description,
46
- "parameters": structure.get_schema(force_required=force_required),
47
- },
48
- }
49
-
50
-
51
- def assistant_format(
52
- structure: Type[BaseStructure], force_required: bool = False
53
- ) -> dict:
54
- """Build a response format definition for OpenAI Assistants.
55
-
56
- Parameters
57
- ----------
58
- structure : type[BaseStructure]
59
- Structure class that defines the response schema.
60
- force_required : bool, default=False
61
- When ``True``, mark all object properties as required.
62
-
63
- Returns
64
- -------
65
- dict
66
- Assistant response format definition.
67
- """
68
- log(f"{structure.__name__}::assistant_format")
69
- return {
70
- "type": "json_schema",
71
- "json_schema": {
72
- "name": structure.__name__,
73
- "schema": structure.get_schema(force_required=force_required),
74
- },
75
- }
76
-
77
-
78
- def response_tool_definition(
79
- structure: Type[BaseStructure],
80
- tool_name: str,
81
- tool_description: str,
82
- force_required: bool = False,
83
- ) -> dict:
84
- """Build a tool definition for OpenAI chat completions.
85
-
86
- Parameters
87
- ----------
88
- structure : type[BaseStructure]
89
- Structure class that defines the tool schema.
90
- tool_name : str
91
- Name of the function tool.
92
- tool_description : str
93
- Description of what the function tool does.
94
- force_required : bool, default=False
95
- When ``True``, mark all object properties as required.
96
-
97
- Returns
98
- -------
99
- dict
100
- Tool definition payload for chat completions.
101
- """
102
- log(f"{structure.__name__}::response_tool_definition")
103
- return {
104
- "type": "function",
105
- "name": tool_name,
106
- "description": tool_description,
107
- "parameters": structure.get_schema(force_required=force_required),
108
- "strict": True,
109
- "additionalProperties": False,
110
- }
111
-
112
-
113
- def response_format(
114
- structure: Type[BaseStructure], force_required: bool = False
115
- ) -> ResponseTextConfigParam:
116
- """Build a response format for OpenAI chat completions.
117
-
118
- Parameters
119
- ----------
120
- structure : type[BaseStructure]
121
- Structure class that defines the response schema.
122
- force_required : bool, default=False
123
- When ``True``, mark all object properties as required.
124
-
125
- Returns
126
- -------
127
- ResponseTextConfigParam
128
- Response format definition.
129
- """
130
- log(f"{structure.__name__}::response_format")
131
- response_format_text_JSONSchema_config_param = (
132
- ResponseFormatTextJSONSchemaConfigParam(
133
- name=structure.__name__,
134
- schema=structure.get_schema(force_required=force_required),
135
- type="json_schema",
136
- description="This is a JSON schema format for the output structure.",
137
- strict=True,
138
- )
139
- )
140
- return ResponseTextConfigParam(format=response_format_text_JSONSchema_config_param)
141
-
142
-
143
- __all__ = [
144
- "assistant_tool_definition",
145
- "assistant_format",
146
- "response_tool_definition",
147
- "response_format",
148
- ]
@@ -1,65 +0,0 @@
1
- """Shared structured output models for summaries."""
2
-
3
- from __future__ import annotations
4
-
5
- from typing import List
6
-
7
- from .base import BaseStructure, spec_field
8
-
9
-
10
- class SummaryTopic(BaseStructure):
11
- """Capture a topic-level summary with supporting citations.
12
-
13
- Methods
14
- -------
15
- print()
16
- Return a formatted string representation of the stored fields.
17
- """
18
-
19
- topic: str = spec_field(
20
- "topic",
21
- default=...,
22
- description="Topic or micro-trend identified in the provided excerpts.",
23
- )
24
- summary: str = spec_field(
25
- "summary",
26
- default=...,
27
- description="Concise explanation of what the excerpts convey about the topic.",
28
- )
29
- citations: List[str] = spec_field(
30
- "citations",
31
- default_factory=list,
32
- description="Indices or short quotes that justify the topic summary.",
33
- )
34
-
35
-
36
- class SummaryStructure(BaseStructure):
37
- """Defines the consolidated summary returned by the summarizer agent.
38
-
39
- Methods
40
- -------
41
- print()
42
- Return a formatted string representation of the stored fields.
43
- """
44
-
45
- text: str = spec_field(
46
- "text",
47
- default=...,
48
- description="Combined summary synthesized from the supplied excerpts.",
49
- )
50
-
51
-
52
- class ExtendedSummaryStructure(SummaryStructure):
53
- """Extend ``SummaryStructure`` with optional topic breakdown metadata.
54
-
55
- Methods
56
- -------
57
- print()
58
- Return a formatted string representation of the stored fields.
59
- """
60
-
61
- metadata: List[SummaryTopic] = spec_field(
62
- "metadata",
63
- default_factory=list,
64
- description="Optional topic-level summaries with supporting citations.",
65
- )
@@ -1,82 +0,0 @@
1
- """Shared structured output models for vector search."""
2
-
3
- from __future__ import annotations
4
-
5
- from typing import List
6
-
7
- from .base import BaseStructure, spec_field
8
-
9
-
10
- class VectorSearchItemStructure(BaseStructure):
11
- """A single vector search to perform."""
12
-
13
- reason: str = spec_field("reason")
14
- query: str = spec_field("query")
15
-
16
-
17
- class VectorSearchPlanStructure(BaseStructure):
18
- """Collection of vector searches required to satisfy the query."""
19
-
20
- searches: List[VectorSearchItemStructure] = spec_field("searches")
21
-
22
-
23
- class VectorSearchItemResultStructure(BaseStructure):
24
- """Result of a single vector search."""
25
-
26
- texts: List[str] = spec_field("texts")
27
-
28
-
29
- class VectorSearchItemResultsStructure(BaseStructure):
30
- """Collection of search results returned from multiple queries.
31
-
32
- Methods
33
- -------
34
- append(item)
35
- Add a search result to the collection.
36
- """
37
-
38
- item_results: List[VectorSearchItemResultStructure] = spec_field(
39
- "item_results", default_factory=list
40
- )
41
-
42
- def append(self, item: VectorSearchItemResultStructure) -> None:
43
- """Add a search result to the collection.
44
-
45
- Parameters
46
- ----------
47
- item : VectorSearchItemResultStructure
48
- Result item to append.
49
-
50
- Returns
51
- -------
52
- None
53
- """
54
- self.item_results.append(item)
55
-
56
-
57
- class VectorSearchReportStructure(BaseStructure):
58
- """Structured output from the vector search writer agent."""
59
-
60
- short_summary: str = spec_field("short_summary")
61
- markdown_report: str = spec_field("markdown_report")
62
- follow_up_questions: List[str] = spec_field("follow_up_questions")
63
- sources: List[str] = spec_field("sources")
64
-
65
-
66
- class VectorSearchStructure(BaseStructure):
67
- """Complete output of a vector search workflow."""
68
-
69
- query: str = spec_field("query")
70
- plan: VectorSearchPlanStructure = spec_field("plan")
71
- results: VectorSearchItemResultsStructure = spec_field("results")
72
- report: VectorSearchReportStructure = spec_field("report")
73
-
74
-
75
- __all__ = [
76
- "VectorSearchReportStructure",
77
- "VectorSearchItemStructure",
78
- "VectorSearchItemResultStructure",
79
- "VectorSearchItemResultsStructure",
80
- "VectorSearchPlanStructure",
81
- "VectorSearchStructure",
82
- ]
@@ -1,46 +0,0 @@
1
- """Shared structured output model for web search results."""
2
-
3
- from __future__ import annotations
4
-
5
- from typing import List
6
-
7
- from .base import BaseStructure, spec_field
8
-
9
-
10
- class WebSearchReportStructure(BaseStructure):
11
- """Structured output from the writer agent."""
12
-
13
- short_summary: str = spec_field("short_summary")
14
- markdown_report: str = spec_field("markdown_report")
15
- follow_up_questions: List[str] = spec_field("follow_up_questions")
16
- sources: List[str] = spec_field("sources")
17
-
18
-
19
- class WebSearchItemStructure(BaseStructure):
20
- """A single web search to perform."""
21
-
22
- reason: str = spec_field("reason")
23
- query: str = spec_field("query")
24
-
25
-
26
- class WebSearchItemResultStructure(BaseStructure):
27
- """Result of a single web search."""
28
-
29
- text: str = spec_field("text")
30
-
31
-
32
- class WebSearchPlanStructure(BaseStructure):
33
- """Collection of searches required to satisfy the query."""
34
-
35
- searches: List[WebSearchItemStructure] = spec_field("searches")
36
-
37
-
38
- class WebSearchStructure(BaseStructure):
39
- """Complete output of a web search workflow."""
40
-
41
- query: str = spec_field("query")
42
- web_search_plan: WebSearchPlanStructure = spec_field("web_search_plan")
43
- web_search_results: List[WebSearchItemResultStructure] = spec_field(
44
- "web_search_results"
45
- )
46
- web_search_report: WebSearchReportStructure = spec_field("web_search_report")
@@ -1,13 +0,0 @@
1
- """Shared utility helpers for openai-sdk-helpers."""
2
-
3
- from __future__ import annotations
4
-
5
- from .core import JSONSerializable, check_filepath, customJSONEncoder, ensure_list, log
6
-
7
- __all__ = [
8
- "ensure_list",
9
- "check_filepath",
10
- "JSONSerializable",
11
- "customJSONEncoder",
12
- "log",
13
- ]