openai-sdk-helpers 0.4.3__py3-none-any.whl → 0.5.1__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 (52) hide show
  1. openai_sdk_helpers/__init__.py +41 -7
  2. openai_sdk_helpers/agent/__init__.py +1 -2
  3. openai_sdk_helpers/agent/base.py +169 -190
  4. openai_sdk_helpers/agent/configuration.py +12 -20
  5. openai_sdk_helpers/agent/coordinator.py +14 -17
  6. openai_sdk_helpers/agent/runner.py +3 -45
  7. openai_sdk_helpers/agent/search/base.py +49 -71
  8. openai_sdk_helpers/agent/search/vector.py +82 -110
  9. openai_sdk_helpers/agent/search/web.py +103 -81
  10. openai_sdk_helpers/agent/summarizer.py +20 -28
  11. openai_sdk_helpers/agent/translator.py +17 -23
  12. openai_sdk_helpers/agent/validator.py +17 -23
  13. openai_sdk_helpers/errors.py +9 -0
  14. openai_sdk_helpers/extract/__init__.py +23 -0
  15. openai_sdk_helpers/extract/extractor.py +157 -0
  16. openai_sdk_helpers/extract/generator.py +476 -0
  17. openai_sdk_helpers/files_api.py +1 -0
  18. openai_sdk_helpers/logging.py +12 -1
  19. openai_sdk_helpers/prompt/extractor_config_agent_instructions.jinja +6 -0
  20. openai_sdk_helpers/prompt/extractor_config_generator.jinja +37 -0
  21. openai_sdk_helpers/prompt/extractor_config_generator_instructions.jinja +9 -0
  22. openai_sdk_helpers/prompt/extractor_prompt_optimizer_agent_instructions.jinja +4 -0
  23. openai_sdk_helpers/prompt/extractor_prompt_optimizer_request.jinja +11 -0
  24. openai_sdk_helpers/response/__init__.py +2 -6
  25. openai_sdk_helpers/response/base.py +233 -164
  26. openai_sdk_helpers/response/configuration.py +39 -14
  27. openai_sdk_helpers/response/files.py +41 -2
  28. openai_sdk_helpers/response/runner.py +1 -48
  29. openai_sdk_helpers/response/tool_call.py +0 -141
  30. openai_sdk_helpers/response/vector_store.py +8 -5
  31. openai_sdk_helpers/streamlit_app/app.py +1 -9
  32. openai_sdk_helpers/structure/__init__.py +16 -0
  33. openai_sdk_helpers/structure/base.py +239 -278
  34. openai_sdk_helpers/structure/extraction.py +1228 -0
  35. openai_sdk_helpers/structure/plan/plan.py +0 -20
  36. openai_sdk_helpers/structure/plan/task.py +0 -33
  37. openai_sdk_helpers/structure/prompt.py +16 -0
  38. openai_sdk_helpers/structure/responses.py +2 -2
  39. openai_sdk_helpers/structure/web_search.py +0 -10
  40. openai_sdk_helpers/tools.py +346 -99
  41. openai_sdk_helpers/utils/__init__.py +7 -0
  42. openai_sdk_helpers/utils/json/base_model.py +315 -32
  43. openai_sdk_helpers/utils/langextract.py +194 -0
  44. openai_sdk_helpers/vector_storage/cleanup.py +7 -2
  45. openai_sdk_helpers/vector_storage/storage.py +37 -7
  46. {openai_sdk_helpers-0.4.3.dist-info → openai_sdk_helpers-0.5.1.dist-info}/METADATA +21 -6
  47. openai_sdk_helpers-0.5.1.dist-info/RECORD +95 -0
  48. openai_sdk_helpers/streamlit_app/streamlit_web_search.py +0 -75
  49. openai_sdk_helpers-0.4.3.dist-info/RECORD +0 -86
  50. {openai_sdk_helpers-0.4.3.dist-info → openai_sdk_helpers-0.5.1.dist-info}/WHEEL +0 -0
  51. {openai_sdk_helpers-0.4.3.dist-info → openai_sdk_helpers-0.5.1.dist-info}/entry_points.txt +0 -0
  52. {openai_sdk_helpers-0.4.3.dist-info → openai_sdk_helpers-0.5.1.dist-info}/licenses/LICENSE +0 -0
@@ -57,26 +57,6 @@ class PlanStructure(StructureBase):
57
57
  description="Ordered list of agent tasks to execute.",
58
58
  )
59
59
 
60
- def print(self) -> str:
61
- """Return a human-readable representation of the plan.
62
-
63
- Returns
64
- -------
65
- str
66
- Concatenated description of each task with task numbers.
67
-
68
- Examples
69
- --------
70
- >>> plan = PlanStructure()
71
- >>> plan.print()
72
- 'No tasks defined.'
73
- """
74
- if not self.tasks:
75
- return "No tasks defined."
76
- return "\n\n".join(
77
- [f"Task {idx + 1}:\n{task.print()}" for idx, task in enumerate(self.tasks)]
78
- )
79
-
80
60
  def __len__(self) -> int:
81
61
  """Return the number of tasks in the plan.
82
62
 
@@ -117,38 +117,5 @@ class TaskStructure(StructureBase):
117
117
  return value
118
118
  return AgentEnum(value)
119
119
 
120
- def print(self) -> str:
121
- """Return a human-readable representation of the task.
122
-
123
- Parameters
124
- ----------
125
- None
126
-
127
- Returns
128
- -------
129
- str
130
- Multi-line description of the task metadata.
131
-
132
- Raises
133
- ------
134
- None
135
-
136
- Examples
137
- --------
138
- >>> TaskStructure(prompt="Test").print()
139
- 'Task type: ...' # doctest: +SKIP
140
- """
141
- return "\n".join(
142
- [
143
- StructureBase.format_output("Task type", value=self.task_type),
144
- StructureBase.format_output("Prompt", value=self.prompt),
145
- StructureBase.format_output("Context", value=self.context),
146
- StructureBase.format_output("Status", value=self.status),
147
- StructureBase.format_output("Start date", value=self.start_date),
148
- StructureBase.format_output("End date", value=self.end_date),
149
- StructureBase.format_output("Results", value=self.results),
150
- ]
151
- )
152
-
153
120
 
154
121
  __all__ = ["TaskStructure"]
@@ -41,3 +41,19 @@ class PromptStructure(StructureBase):
41
41
  "Generate a summary of the latest news in AI.",
42
42
  ],
43
43
  )
44
+
45
+ @staticmethod
46
+ def from_str(prompt_str: str) -> PromptStructure:
47
+ """Create a PromptStructure instance from a simple string.
48
+
49
+ Parameters
50
+ ----------
51
+ prompt_str : str
52
+ The prompt text to use for the OpenAI API request.
53
+
54
+ Returns
55
+ -------
56
+ PromptStructure
57
+ An instance of PromptStructure with the provided prompt text.
58
+ """
59
+ return PromptStructure(prompt=prompt_str)
@@ -92,7 +92,7 @@ def assistant_format(structure: type[StructureBase]) -> dict:
92
92
  def response_tool_definition(
93
93
  structure: type[StructureBase],
94
94
  tool_name: str,
95
- tool_description: str,
95
+ tool_description: str | None,
96
96
  ) -> dict:
97
97
  """Build a tool definition for OpenAI chat completions.
98
98
 
@@ -105,7 +105,7 @@ def response_tool_definition(
105
105
  Structure class that defines the tool schema.
106
106
  tool_name : str
107
107
  Name of the function tool.
108
- tool_description : str
108
+ tool_description : str | None
109
109
  Description of what the function tool does.
110
110
 
111
111
  Returns
@@ -150,13 +150,3 @@ class WebSearchStructure(StructureBase):
150
150
  "web_search_results"
151
151
  )
152
152
  web_search_report: WebSearchReportStructure = spec_field("web_search_report")
153
-
154
- def print(self) -> str:
155
- """Return the markdown report.
156
-
157
- Returns
158
- -------
159
- str
160
- Markdown-formatted report from web search results.
161
- """
162
- return self.web_search_report.markdown_report