openai-sdk-helpers 0.2.0__py3-none-any.whl → 0.4.0__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 (58) hide show
  1. openai_sdk_helpers/__init__.py +6 -6
  2. openai_sdk_helpers/agent/__init__.py +4 -2
  3. openai_sdk_helpers/agent/base.py +391 -106
  4. openai_sdk_helpers/agent/config.py +405 -44
  5. openai_sdk_helpers/agent/coordination.py +68 -31
  6. openai_sdk_helpers/agent/runner.py +29 -19
  7. openai_sdk_helpers/agent/search/base.py +103 -54
  8. openai_sdk_helpers/agent/search/vector.py +99 -68
  9. openai_sdk_helpers/agent/search/web.py +84 -50
  10. openai_sdk_helpers/agent/summarizer.py +33 -7
  11. openai_sdk_helpers/agent/translator.py +58 -24
  12. openai_sdk_helpers/agent/validation.py +35 -4
  13. openai_sdk_helpers/cli.py +42 -0
  14. openai_sdk_helpers/config.py +0 -1
  15. openai_sdk_helpers/environment.py +3 -2
  16. openai_sdk_helpers/files_api.py +35 -3
  17. openai_sdk_helpers/prompt/base.py +6 -0
  18. openai_sdk_helpers/response/__init__.py +3 -3
  19. openai_sdk_helpers/response/base.py +161 -22
  20. openai_sdk_helpers/response/config.py +50 -200
  21. openai_sdk_helpers/response/files.py +5 -5
  22. openai_sdk_helpers/response/messages.py +3 -3
  23. openai_sdk_helpers/response/runner.py +7 -7
  24. openai_sdk_helpers/response/tool_call.py +94 -4
  25. openai_sdk_helpers/response/vector_store.py +3 -3
  26. openai_sdk_helpers/streamlit_app/app.py +16 -16
  27. openai_sdk_helpers/streamlit_app/config.py +38 -37
  28. openai_sdk_helpers/streamlit_app/streamlit_web_search.py +2 -2
  29. openai_sdk_helpers/structure/__init__.py +6 -2
  30. openai_sdk_helpers/structure/agent_blueprint.py +2 -2
  31. openai_sdk_helpers/structure/base.py +8 -99
  32. openai_sdk_helpers/structure/plan/plan.py +2 -2
  33. openai_sdk_helpers/structure/plan/task.py +9 -9
  34. openai_sdk_helpers/structure/prompt.py +2 -2
  35. openai_sdk_helpers/structure/responses.py +15 -15
  36. openai_sdk_helpers/structure/summary.py +3 -3
  37. openai_sdk_helpers/structure/translation.py +32 -0
  38. openai_sdk_helpers/structure/validation.py +2 -2
  39. openai_sdk_helpers/structure/vector_search.py +7 -7
  40. openai_sdk_helpers/structure/web_search.py +6 -6
  41. openai_sdk_helpers/tools.py +41 -15
  42. openai_sdk_helpers/utils/__init__.py +19 -5
  43. openai_sdk_helpers/utils/instructions.py +35 -0
  44. openai_sdk_helpers/utils/json/__init__.py +55 -0
  45. openai_sdk_helpers/utils/json/base_model.py +181 -0
  46. openai_sdk_helpers/utils/{json_utils.py → json/data_class.py} +43 -70
  47. openai_sdk_helpers/utils/json/ref.py +113 -0
  48. openai_sdk_helpers/utils/json/utils.py +203 -0
  49. openai_sdk_helpers/utils/output_validation.py +21 -1
  50. openai_sdk_helpers/utils/path_utils.py +34 -1
  51. openai_sdk_helpers/utils/registry.py +194 -0
  52. openai_sdk_helpers/vector_storage/storage.py +10 -0
  53. {openai_sdk_helpers-0.2.0.dist-info → openai_sdk_helpers-0.4.0.dist-info}/METADATA +7 -7
  54. openai_sdk_helpers-0.4.0.dist-info/RECORD +86 -0
  55. openai_sdk_helpers-0.2.0.dist-info/RECORD +0 -79
  56. {openai_sdk_helpers-0.2.0.dist-info → openai_sdk_helpers-0.4.0.dist-info}/WHEEL +0 -0
  57. {openai_sdk_helpers-0.2.0.dist-info → openai_sdk_helpers-0.4.0.dist-info}/entry_points.txt +0 -0
  58. {openai_sdk_helpers-0.2.0.dist-info → openai_sdk_helpers-0.4.0.dist-info}/licenses/LICENSE +0 -0
@@ -9,9 +9,10 @@ from __future__ import annotations
9
9
 
10
10
  from typing import Any, Dict, Optional
11
11
 
12
- from agents import Agent, RunResult, RunResultStreaming, Runner
12
+ from agents import Agent, RunResult, RunResultStreaming, Runner, Session
13
13
 
14
14
  from openai_sdk_helpers.utils.async_utils import run_coroutine_with_fallback
15
+ from ..structure.base import StructureBase
15
16
 
16
17
 
17
18
  async def run_async(
@@ -19,7 +20,8 @@ async def run_async(
19
20
  input: str,
20
21
  *,
21
22
  context: Optional[Dict[str, Any]] = None,
22
- output_type: Optional[Any] = None,
23
+ output_structure: Optional[type[StructureBase]] = None,
24
+ session: Optional[Session] = None,
23
25
  ) -> Any:
24
26
  """Run an Agent asynchronously.
25
27
 
@@ -31,13 +33,15 @@ async def run_async(
31
33
  Prompt or query string for the agent.
32
34
  context : dict or None, default=None
33
35
  Optional context dictionary passed to the agent.
34
- output_type : type or None, default=None
36
+ output_structure : type[StructureBase] or None, default=None
35
37
  Optional type used to cast the final output.
38
+ session : Session or None, default=None
39
+ Optional session for maintaining conversation history.
36
40
 
37
41
  Returns
38
42
  -------
39
43
  Any
40
- Agent response, optionally converted to ``output_type``.
44
+ Agent response, optionally converted to ``output_structure``.
41
45
 
42
46
  Examples
43
47
  --------
@@ -49,9 +53,9 @@ async def run_async(
49
53
  ... return result
50
54
  >>> asyncio.run(example()) # doctest: +SKIP
51
55
  """
52
- result = await Runner.run(agent, input, context=context)
53
- if output_type is not None:
54
- return result.final_output_as(output_type)
56
+ result = await Runner.run(agent, input, context=context, session=session)
57
+ if output_structure is not None:
58
+ return result.final_output_as(output_structure)
55
59
  return result
56
60
 
57
61
 
@@ -60,7 +64,8 @@ def run_sync(
60
64
  input: str,
61
65
  *,
62
66
  context: Optional[Dict[str, Any]] = None,
63
- output_type: Optional[Any] = None,
67
+ output_structure: Optional[type[StructureBase]] = None,
68
+ session: Optional[Session] = None,
64
69
  ) -> Any:
65
70
  """Run an Agent synchronously.
66
71
 
@@ -76,13 +81,15 @@ def run_sync(
76
81
  Prompt or query string for the agent.
77
82
  context : dict or None, default=None
78
83
  Optional context dictionary passed to the agent.
79
- output_type : type or None, default=None
84
+ output_structure : type[StructureBase] or None, default=None
80
85
  Optional type used to cast the final output.
86
+ session : Session or None, default=None
87
+ Optional session for maintaining conversation history.
81
88
 
82
89
  Returns
83
90
  -------
84
91
  Any
85
- Agent response, optionally converted to ``output_type``.
92
+ Agent response, optionally converted to ``output_structure``.
86
93
 
87
94
  Raises
88
95
  ------
@@ -95,10 +102,10 @@ def run_sync(
95
102
  >>> agent = Agent(name="test", instructions="test", model="gpt-4o-mini")
96
103
  >>> result = run_sync(agent, "What is 2+2?") # doctest: +SKIP
97
104
  """
98
- coro = Runner.run(agent, input, context=context)
105
+ coro = Runner.run(agent, input, context=context, session=session)
99
106
  result: RunResult = run_coroutine_with_fallback(coro)
100
- if output_type is not None:
101
- return result.final_output_as(output_type)
107
+ if output_structure is not None:
108
+ return result.final_output_as(output_structure)
102
109
  return result
103
110
 
104
111
 
@@ -107,8 +114,9 @@ def run_streamed(
107
114
  input: str,
108
115
  *,
109
116
  context: Optional[Dict[str, Any]] = None,
110
- output_type: Optional[Any] = None,
111
- ) -> RunResultStreaming:
117
+ output_structure: Optional[type[StructureBase]] = None,
118
+ session: Optional[Session] = None,
119
+ ) -> RunResultStreaming | StructureBase:
112
120
  """Stream agent execution results.
113
121
 
114
122
  Parameters
@@ -119,8 +127,10 @@ def run_streamed(
119
127
  Prompt or query string for the agent.
120
128
  context : dict or None, default=None
121
129
  Optional context dictionary passed to the agent.
122
- output_type : type or None, default=None
130
+ output_structure : type[StructureBase] or None, default=None
123
131
  Optional type used to cast the final output.
132
+ session : Session or None, default=None
133
+ Optional session for maintaining conversation history.
124
134
 
125
135
  Returns
126
136
  -------
@@ -135,9 +145,9 @@ def run_streamed(
135
145
  >>> for chunk in result.stream_text(): # doctest: +SKIP
136
146
  ... print(chunk, end="")
137
147
  """
138
- result = Runner.run_streamed(agent, input, context=context)
139
- if output_type is not None:
140
- return result.final_output_as(output_type)
148
+ result = Runner.run_streamed(agent, input, context=context, session=session)
149
+ if output_structure is not None:
150
+ return result.final_output_as(output_structure)
141
151
  return result
142
152
 
143
153
 
@@ -13,14 +13,16 @@ from pathlib import Path
13
13
  from typing import Generic, List, Optional, TypeVar, Union
14
14
 
15
15
  from ..base import AgentBase
16
- from ..config import AgentConfig
16
+ from ..config import AgentConfiguration
17
+ from ...structure.base import StructureBase
17
18
 
18
19
  # Type variables for search workflow components
19
- ItemType = TypeVar("ItemType") # Search item structure (e.g., WebSearchItemStructure)
20
+ ItemType = TypeVar(
21
+ "ItemType", bound=StructureBase
22
+ ) # Search item structure (e.g., WebSearchItemStructure)
20
23
  ResultType = TypeVar("ResultType") # Individual search result
21
- PlanType = TypeVar("PlanType") # Complete search plan structure
22
- ReportType = TypeVar("ReportType") # Final report structure
23
- OutputType = TypeVar("OutputType") # Generic output type
24
+ PlanType = TypeVar("PlanType", bound=StructureBase) # Complete search plan structure
25
+ ReportType = TypeVar("ReportType", bound=StructureBase) # Final report structure
24
26
 
25
27
 
26
28
  class SearchPlanner(AgentBase, Generic[PlanType]):
@@ -29,12 +31,35 @@ class SearchPlanner(AgentBase, Generic[PlanType]):
29
31
  Subclasses implement specific planner logic by overriding the
30
32
  `_configure_agent` method and specifying the output type.
31
33
 
34
+ Parameters
35
+ ----------
36
+ prompt_dir : Path, optional
37
+ Directory containing prompt templates.
38
+ default_model : str, optional
39
+ Default model identifier to use when not defined in config.
40
+
32
41
  Methods
33
42
  -------
34
43
  run_agent(query)
35
44
  Generate a search plan for the provided query.
36
45
  _configure_agent()
37
- Return AgentConfig for this planner instance.
46
+ Return AgentConfiguration for this planner instance.
47
+
48
+ Raises
49
+ ------
50
+ ValueError
51
+ If the default model is not provided.
52
+
53
+ Examples
54
+ --------
55
+ >>> class MyPlanner(SearchPlanner):
56
+ ... def _configure_agent(self):
57
+ ... return AgentConfiguration(
58
+ ... name="my_planner",
59
+ ... description="Plans searches",
60
+ ... output_structure=WebSearchPlanStructure,
61
+ ... )
62
+ >>> planner = MyPlanner(default_model="gpt-4o-mini")
38
63
  """
39
64
 
40
65
  def __init__(
@@ -42,15 +67,7 @@ class SearchPlanner(AgentBase, Generic[PlanType]):
42
67
  prompt_dir: Optional[Path] = None,
43
68
  default_model: Optional[str] = None,
44
69
  ) -> None:
45
- """Initialize the planner agent.
46
-
47
- Parameters
48
- ----------
49
- prompt_dir : Path, optional
50
- Directory containing prompt templates.
51
- default_model : str, optional
52
- Default model identifier to use when not defined in config.
53
- """
70
+ """Initialize the planner agent."""
54
71
  config = self._configure_agent()
55
72
  super().__init__(
56
73
  config=config,
@@ -59,20 +76,20 @@ class SearchPlanner(AgentBase, Generic[PlanType]):
59
76
  )
60
77
 
61
78
  @abstractmethod
62
- def _configure_agent(self) -> AgentConfig:
79
+ def _configure_agent(self) -> AgentConfiguration:
63
80
  """Return configuration for this planner.
64
81
 
65
82
  Returns
66
83
  -------
67
- AgentConfig
68
- Configuration with name, description, and output_type set.
84
+ AgentConfiguration
85
+ Configuration with name, description, and output_structure set.
69
86
 
70
87
  Examples
71
88
  --------
72
- >>> config = AgentConfig(
89
+ >>> config = AgentConfiguration(
73
90
  ... name="web_planner",
74
91
  ... description="Plan web searches",
75
- ... output_type=WebSearchPlanStructure,
92
+ ... output_structure=WebSearchPlanStructure,
76
93
  ... )
77
94
  >>> return config
78
95
  """
@@ -93,7 +110,7 @@ class SearchPlanner(AgentBase, Generic[PlanType]):
93
110
  """
94
111
  result: PlanType = await self.run_async(
95
112
  input=query,
96
- output_type=self._output_type,
113
+ output_structure=self._output_structure,
97
114
  )
98
115
  return result
99
116
 
@@ -105,6 +122,15 @@ class SearchToolAgent(AgentBase, Generic[ItemType, ResultType, PlanType]):
105
122
  Subclasses implement search execution logic by overriding the
106
123
  `_configure_agent` and `run_search` methods.
107
124
 
125
+ Parameters
126
+ ----------
127
+ prompt_dir : Path, optional
128
+ Directory containing prompt templates.
129
+ default_model : str, optional
130
+ Default model identifier to use when not defined in config.
131
+ max_concurrent_searches : int, default=10
132
+ Maximum number of concurrent search operations.
133
+
108
134
  Methods
109
135
  -------
110
136
  run_agent(search_plan)
@@ -112,7 +138,25 @@ class SearchToolAgent(AgentBase, Generic[ItemType, ResultType, PlanType]):
112
138
  run_search(item)
113
139
  Execute a single search item.
114
140
  _configure_agent()
115
- Return AgentConfig for this tool agent.
141
+ Return AgentConfiguration for this tool agent.
142
+
143
+ Raises
144
+ ------
145
+ ValueError
146
+ If the default model is not provided.
147
+
148
+ Examples
149
+ --------
150
+ >>> class MyTool(SearchToolAgent):
151
+ ... def _configure_agent(self):
152
+ ... return AgentConfiguration(
153
+ ... name="my_tool",
154
+ ... description="Executes searches",
155
+ ... input_structure=WebSearchPlanStructure,
156
+ ... )
157
+ ... async def run_search(self, item):
158
+ ... return "result"
159
+ >>> tool = MyTool(default_model="gpt-4o-mini")
116
160
  """
117
161
 
118
162
  def __init__(
@@ -122,17 +166,7 @@ class SearchToolAgent(AgentBase, Generic[ItemType, ResultType, PlanType]):
122
166
  default_model: Optional[str] = None,
123
167
  max_concurrent_searches: int = 10,
124
168
  ) -> None:
125
- """Initialize the search tool agent.
126
-
127
- Parameters
128
- ----------
129
- prompt_dir : Path, optional
130
- Directory containing prompt templates.
131
- default_model : str, optional
132
- Default model identifier to use when not defined in config.
133
- max_concurrent_searches : int, default=10
134
- Maximum number of concurrent search operations.
135
- """
169
+ """Initialize the search tool agent."""
136
170
  self._max_concurrent_searches = max_concurrent_searches
137
171
  config = self._configure_agent()
138
172
  super().__init__(
@@ -142,20 +176,20 @@ class SearchToolAgent(AgentBase, Generic[ItemType, ResultType, PlanType]):
142
176
  )
143
177
 
144
178
  @abstractmethod
145
- def _configure_agent(self) -> AgentConfig:
179
+ def _configure_agent(self) -> AgentConfiguration:
146
180
  """Return configuration for this tool agent.
147
181
 
148
182
  Returns
149
183
  -------
150
- AgentConfig
151
- Configuration with name, description, input_type, and tools set.
184
+ AgentConfiguration
185
+ Configuration with name, description, input_structure, and tools set.
152
186
 
153
187
  Examples
154
188
  --------
155
- >>> config = AgentConfig(
189
+ >>> config = AgentConfiguration(
156
190
  ... name="web_search",
157
191
  ... description="Perform web searches",
158
- ... input_type=WebSearchPlanStructure,
192
+ ... input_structure=WebSearchPlanStructure,
159
193
  ... tools=[WebSearchTool()],
160
194
  ... )
161
195
  >>> return config
@@ -211,12 +245,35 @@ class SearchWriter(AgentBase, Generic[ReportType]):
211
245
  Synthesizes search results into a final report. Subclasses implement
212
246
  specific report generation logic by overriding the `_configure_agent` method.
213
247
 
248
+ Parameters
249
+ ----------
250
+ prompt_dir : Path, optional
251
+ Directory containing prompt templates.
252
+ default_model : str, optional
253
+ Default model identifier to use when not defined in config.
254
+
214
255
  Methods
215
256
  -------
216
257
  run_agent(query, search_results)
217
258
  Generate a report from search results.
218
259
  _configure_agent()
219
- Return AgentConfig for this writer instance.
260
+ Return AgentConfiguration for this writer instance.
261
+
262
+ Raises
263
+ ------
264
+ ValueError
265
+ If the default model is not provided.
266
+
267
+ Examples
268
+ --------
269
+ >>> class MyWriter(SearchWriter):
270
+ ... def _configure_agent(self):
271
+ ... return AgentConfiguration(
272
+ ... name="my_writer",
273
+ ... description="Writes reports",
274
+ ... output_structure=WebSearchReportStructure,
275
+ ... )
276
+ >>> writer = MyWriter(default_model="gpt-4o-mini")
220
277
  """
221
278
 
222
279
  def __init__(
@@ -224,15 +281,7 @@ class SearchWriter(AgentBase, Generic[ReportType]):
224
281
  prompt_dir: Optional[Path] = None,
225
282
  default_model: Optional[str] = None,
226
283
  ) -> None:
227
- """Initialize the writer agent.
228
-
229
- Parameters
230
- ----------
231
- prompt_dir : Path, optional
232
- Directory containing prompt templates.
233
- default_model : str, optional
234
- Default model identifier to use when not defined in config.
235
- """
284
+ """Initialize the writer agent."""
236
285
  config = self._configure_agent()
237
286
  super().__init__(
238
287
  config=config,
@@ -241,20 +290,20 @@ class SearchWriter(AgentBase, Generic[ReportType]):
241
290
  )
242
291
 
243
292
  @abstractmethod
244
- def _configure_agent(self) -> AgentConfig:
293
+ def _configure_agent(self) -> AgentConfiguration:
245
294
  """Return configuration for this writer.
246
295
 
247
296
  Returns
248
297
  -------
249
- AgentConfig
250
- Configuration with name, description, and output_type set.
298
+ AgentConfiguration
299
+ Configuration with name, description, and output_structure set.
251
300
 
252
301
  Examples
253
302
  --------
254
- >>> config = AgentConfig(
303
+ >>> config = AgentConfiguration(
255
304
  ... name="web_writer",
256
305
  ... description="Write web search report",
257
- ... output_type=WebSearchReportStructure,
306
+ ... output_structure=WebSearchReportStructure,
258
307
  ... )
259
308
  >>> return config
260
309
  """
@@ -286,7 +335,7 @@ class SearchWriter(AgentBase, Generic[ReportType]):
286
335
  result: ReportType = await self.run_async(
287
336
  input=query,
288
337
  context=template_context,
289
- output_type=self._output_type,
338
+ output_structure=self._output_structure,
290
339
  )
291
340
  return result
292
341
 
@@ -16,7 +16,7 @@ from ...structure.vector_search import (
16
16
  VectorSearchReportStructure,
17
17
  )
18
18
  from ...vector_storage import VectorStorage
19
- from ..config import AgentConfig
19
+ from ..config import AgentConfiguration
20
20
  from ..utils import run_coroutine_agent_sync
21
21
  from .base import SearchPlanner, SearchToolAgent, SearchWriter
22
22
 
@@ -26,38 +26,47 @@ MAX_CONCURRENT_SEARCHES = 10
26
26
  class VectorSearchPlanner(SearchPlanner[VectorSearchPlanStructure]):
27
27
  """Plan vector searches to satisfy a user query.
28
28
 
29
+ Parameters
30
+ ----------
31
+ prompt_dir : Path or None, default=None
32
+ Directory containing prompt templates.
33
+ default_model : str or None, default=None
34
+ Default model identifier to use when not defined in config.
35
+
29
36
  Methods
30
37
  -------
31
38
  run_agent(query)
32
39
  Generate a vector search plan for the provided query.
40
+
41
+ Raises
42
+ ------
43
+ ValueError
44
+ If the default model is not provided.
45
+
46
+ Examples
47
+ --------
48
+ >>> planner = VectorSearchPlanner(default_model="gpt-4o-mini")
33
49
  """
34
50
 
35
51
  def __init__(
36
52
  self, prompt_dir: Optional[Path] = None, default_model: Optional[str] = None
37
53
  ) -> None:
38
- """Initialize the planner agent.
39
-
40
- Parameters
41
- ----------
42
- prompt_dir : Path or None, default=None
43
- Directory containing prompt templates.
44
- default_model : str or None, default=None
45
- Default model identifier to use when not defined in config.
46
- """
54
+ """Initialize the planner agent."""
47
55
  super().__init__(prompt_dir=prompt_dir, default_model=default_model)
48
56
 
49
- def _configure_agent(self) -> AgentConfig:
57
+ def _configure_agent(self) -> AgentConfiguration:
50
58
  """Return configuration for the vector planner agent.
51
59
 
52
60
  Returns
53
61
  -------
54
- AgentConfig
62
+ AgentConfiguration
55
63
  Configuration with name, description, and output type.
56
64
  """
57
- return AgentConfig(
65
+ return AgentConfiguration(
58
66
  name="vector_planner",
67
+ instructions="Agent instructions",
59
68
  description="Plan vector searches based on a user query.",
60
- output_type=VectorSearchPlanStructure,
69
+ output_structure=VectorSearchPlanStructure,
61
70
  )
62
71
 
63
72
 
@@ -70,12 +79,37 @@ class VectorSearchTool(
70
79
  ):
71
80
  """Execute vector searches defined in a search plan.
72
81
 
82
+ Parameters
83
+ ----------
84
+ prompt_dir : Path or None, default=None
85
+ Directory containing prompt templates.
86
+ default_model : str or None, default=None
87
+ Default model identifier to use when not defined in config.
88
+ store_name : str or None, default=None
89
+ Name of the vector store to query.
90
+ max_concurrent_searches : int, default=MAX_CONCURRENT_SEARCHES
91
+ Maximum number of concurrent vector search tasks to run.
92
+ vector_storage : VectorStorage or None, default=None
93
+ Optional preconfigured vector storage instance to reuse.
94
+ vector_storage_factory : Callable or None, default=None
95
+ Factory for constructing a VectorStorage when one is not provided.
96
+ Receives ``store_name`` as an argument.
97
+
73
98
  Methods
74
99
  -------
75
100
  run_agent(search_plan)
76
101
  Execute searches described by the plan.
77
102
  run_search(item)
78
103
  Perform a single vector search and summarise the result.
104
+
105
+ Raises
106
+ ------
107
+ ValueError
108
+ If the default model is not provided.
109
+
110
+ Examples
111
+ --------
112
+ >>> tool = VectorSearchTool(default_model="gpt-4o-mini", store_name="my_store")
79
113
  """
80
114
 
81
115
  def __init__(
@@ -88,24 +122,7 @@ class VectorSearchTool(
88
122
  vector_storage: Optional[VectorStorage] = None,
89
123
  vector_storage_factory: Optional[Callable[[str], VectorStorage]] = None,
90
124
  ) -> None:
91
- """Initialize the search tool agent.
92
-
93
- Parameters
94
- ----------
95
- prompt_dir : Path or None, default=None
96
- Directory containing prompt templates.
97
- default_model : str or None, default=None
98
- Default model identifier to use when not defined in config.
99
- store_name : str or None, default=None
100
- Name of the vector store to query.
101
- max_concurrent_searches : int, default=MAX_CONCURRENT_SEARCHES
102
- Maximum number of concurrent vector search tasks to run.
103
- vector_storage : VectorStorage or None, default=None
104
- Optional preconfigured vector storage instance to reuse.
105
- vector_storage_factory : Callable or None, default=None
106
- Factory for constructing a VectorStorage when one is not provided.
107
- Receives ``store_name`` as an argument.
108
- """
125
+ """Initialize the search tool agent."""
109
126
  self._vector_storage: Optional[VectorStorage] = None
110
127
  self._store_name = store_name or "editorial"
111
128
  self._vector_storage_factory = vector_storage_factory
@@ -117,19 +134,20 @@ class VectorSearchTool(
117
134
  max_concurrent_searches=max_concurrent_searches,
118
135
  )
119
136
 
120
- def _configure_agent(self) -> AgentConfig:
137
+ def _configure_agent(self) -> AgentConfiguration:
121
138
  """Return configuration for the vector search tool agent.
122
139
 
123
140
  Returns
124
141
  -------
125
- AgentConfig
142
+ AgentConfiguration
126
143
  Configuration with name, description, and input type.
127
144
  """
128
- return AgentConfig(
145
+ return AgentConfiguration(
129
146
  name="vector_search",
147
+ instructions="Agent instructions",
130
148
  description="Perform vector searches based on a search plan.",
131
- input_type=VectorSearchPlanStructure,
132
- output_type=VectorSearchItemResultsStructure,
149
+ input_structure=VectorSearchPlanStructure,
150
+ output_structure=VectorSearchItemResultsStructure,
133
151
  )
134
152
 
135
153
  def _get_vector_storage(self) -> VectorStorage:
@@ -179,38 +197,47 @@ class VectorSearchTool(
179
197
  class VectorSearchWriter(SearchWriter[VectorSearchReportStructure]):
180
198
  """Generate reports summarizing vector search results.
181
199
 
200
+ Parameters
201
+ ----------
202
+ prompt_dir : Path or None, default=None
203
+ Directory containing prompt templates.
204
+ default_model : str or None, default=None
205
+ Default model identifier to use when not defined in config.
206
+
182
207
  Methods
183
208
  -------
184
209
  run_agent(query, search_results)
185
210
  Compile a final report from search results.
211
+
212
+ Raises
213
+ ------
214
+ ValueError
215
+ If the default model is not provided.
216
+
217
+ Examples
218
+ --------
219
+ >>> writer = VectorSearchWriter(default_model="gpt-4o-mini")
186
220
  """
187
221
 
188
222
  def __init__(
189
223
  self, prompt_dir: Optional[Path] = None, default_model: Optional[str] = None
190
224
  ) -> None:
191
- """Initialize the writer agent.
192
-
193
- Parameters
194
- ----------
195
- prompt_dir : Path or None, default=None
196
- Directory containing prompt templates.
197
- default_model : str or None, default=None
198
- Default model identifier to use when not defined in config.
199
- """
225
+ """Initialize the writer agent."""
200
226
  super().__init__(prompt_dir=prompt_dir, default_model=default_model)
201
227
 
202
- def _configure_agent(self) -> AgentConfig:
228
+ def _configure_agent(self) -> AgentConfiguration:
203
229
  """Return configuration for the vector writer agent.
204
230
 
205
231
  Returns
206
232
  -------
207
- AgentConfig
233
+ AgentConfiguration
208
234
  Configuration with name, description, and output type.
209
235
  """
210
- return AgentConfig(
236
+ return AgentConfiguration(
211
237
  name="vector_writer",
238
+ instructions="Agent instructions",
212
239
  description="Write a report based on search results.",
213
- output_type=VectorSearchReportStructure,
240
+ output_structure=VectorSearchReportStructure,
214
241
  )
215
242
 
216
243
 
@@ -222,6 +249,22 @@ class VectorSearch:
222
249
  comprehensive reports. It combines ``VectorSearchPlanner``,
223
250
  ``VectorSearchTool``, and ``VectorSearchWriter`` into a single workflow.
224
251
 
252
+ Parameters
253
+ ----------
254
+ prompt_dir : Path or None, default=None
255
+ Directory containing prompt templates.
256
+ default_model : str or None, default=None
257
+ Default model identifier to use when not defined in config.
258
+ vector_store_name : str or None, default=None
259
+ Name of the vector store to query.
260
+ max_concurrent_searches : int, default=MAX_CONCURRENT_SEARCHES
261
+ Maximum number of concurrent search tasks to run.
262
+ vector_storage : VectorStorage or None, default=None
263
+ Optional preconfigured vector storage instance to reuse.
264
+ vector_storage_factory : callable, default=None
265
+ Factory used to construct a VectorStorage when one is not provided.
266
+ Receives ``vector_store_name`` as an argument.
267
+
225
268
  Examples
226
269
  --------
227
270
  Basic vector search:
@@ -253,6 +296,11 @@ class VectorSearch:
253
296
  Convenience asynchronous entry point for the workflow.
254
297
  run_vector_agent_sync(search_query)
255
298
  Convenience synchronous entry point for the workflow.
299
+
300
+ Raises
301
+ ------
302
+ ValueError
303
+ If the default model is not provided.
256
304
  """
257
305
 
258
306
  def __init__(
@@ -265,24 +313,7 @@ class VectorSearch:
265
313
  vector_storage: Optional[VectorStorage] = None,
266
314
  vector_storage_factory: Optional[Callable[[str], VectorStorage]] = None,
267
315
  ) -> None:
268
- """Create the main VectorSearch agent.
269
-
270
- Parameters
271
- ----------
272
- prompt_dir : Path or None, default=None
273
- Directory containing prompt templates.
274
- default_model : str or None, default=None
275
- Default model identifier to use when not defined in config.
276
- vector_store_name : str or None, default=None
277
- Name of the vector store to query.
278
- max_concurrent_searches : int, default=MAX_CONCURRENT_SEARCHES
279
- Maximum number of concurrent search tasks to run.
280
- vector_storage : VectorStorage or None, default=None
281
- Optional preconfigured vector storage instance to reuse.
282
- vector_storage_factory : callable, default=None
283
- Factory used to construct a VectorStorage when one is not provided.
284
- Receives ``vector_store_name`` as an argument.
285
- """
316
+ """Create the main VectorSearch agent."""
286
317
  self._prompt_dir = prompt_dir
287
318
  self._default_model = default_model
288
319
  self._vector_store_name = vector_store_name