openai-sdk-helpers 0.3.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.
- openai_sdk_helpers/__init__.py +6 -6
- openai_sdk_helpers/agent/__init__.py +2 -2
- openai_sdk_helpers/agent/base.py +231 -110
- openai_sdk_helpers/agent/config.py +83 -29
- openai_sdk_helpers/agent/coordination.py +64 -28
- openai_sdk_helpers/agent/runner.py +16 -15
- openai_sdk_helpers/agent/search/base.py +94 -45
- openai_sdk_helpers/agent/search/vector.py +86 -58
- openai_sdk_helpers/agent/search/web.py +71 -40
- openai_sdk_helpers/agent/summarizer.py +32 -7
- openai_sdk_helpers/agent/translator.py +57 -24
- openai_sdk_helpers/agent/validation.py +34 -4
- openai_sdk_helpers/cli.py +42 -0
- openai_sdk_helpers/config.py +0 -1
- openai_sdk_helpers/environment.py +3 -2
- openai_sdk_helpers/files_api.py +35 -3
- openai_sdk_helpers/prompt/base.py +6 -0
- openai_sdk_helpers/response/__init__.py +3 -3
- openai_sdk_helpers/response/base.py +142 -73
- openai_sdk_helpers/response/config.py +43 -51
- openai_sdk_helpers/response/files.py +5 -5
- openai_sdk_helpers/response/messages.py +3 -3
- openai_sdk_helpers/response/runner.py +7 -7
- openai_sdk_helpers/response/tool_call.py +94 -4
- openai_sdk_helpers/response/vector_store.py +3 -3
- openai_sdk_helpers/streamlit_app/app.py +16 -16
- openai_sdk_helpers/streamlit_app/config.py +38 -37
- openai_sdk_helpers/streamlit_app/streamlit_web_search.py +2 -2
- openai_sdk_helpers/structure/__init__.py +6 -2
- openai_sdk_helpers/structure/agent_blueprint.py +2 -2
- openai_sdk_helpers/structure/base.py +8 -99
- openai_sdk_helpers/structure/plan/plan.py +2 -2
- openai_sdk_helpers/structure/plan/task.py +9 -9
- openai_sdk_helpers/structure/prompt.py +2 -2
- openai_sdk_helpers/structure/responses.py +15 -15
- openai_sdk_helpers/structure/summary.py +3 -3
- openai_sdk_helpers/structure/translation.py +32 -0
- openai_sdk_helpers/structure/validation.py +2 -2
- openai_sdk_helpers/structure/vector_search.py +7 -7
- openai_sdk_helpers/structure/web_search.py +6 -6
- openai_sdk_helpers/tools.py +41 -15
- openai_sdk_helpers/utils/__init__.py +19 -5
- openai_sdk_helpers/utils/json/__init__.py +55 -0
- openai_sdk_helpers/utils/json/base_model.py +181 -0
- openai_sdk_helpers/utils/{json_utils.py → json/data_class.py} +33 -68
- openai_sdk_helpers/utils/json/ref.py +113 -0
- openai_sdk_helpers/utils/json/utils.py +203 -0
- openai_sdk_helpers/utils/output_validation.py +21 -1
- openai_sdk_helpers/utils/path_utils.py +34 -1
- openai_sdk_helpers/utils/registry.py +17 -6
- openai_sdk_helpers/vector_storage/storage.py +10 -0
- {openai_sdk_helpers-0.3.0.dist-info → openai_sdk_helpers-0.4.0.dist-info}/METADATA +7 -7
- openai_sdk_helpers-0.4.0.dist-info/RECORD +86 -0
- openai_sdk_helpers-0.3.0.dist-info/RECORD +0 -81
- {openai_sdk_helpers-0.3.0.dist-info → openai_sdk_helpers-0.4.0.dist-info}/WHEEL +0 -0
- {openai_sdk_helpers-0.3.0.dist-info → openai_sdk_helpers-0.4.0.dist-info}/entry_points.txt +0 -0
- {openai_sdk_helpers-0.3.0.dist-info → openai_sdk_helpers-0.4.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -12,29 +12,54 @@ from abc import ABC, abstractmethod
|
|
|
12
12
|
from pathlib import Path
|
|
13
13
|
from typing import Generic, List, Optional, TypeVar, Union
|
|
14
14
|
|
|
15
|
-
from ..base import
|
|
15
|
+
from ..base import AgentBase
|
|
16
16
|
from ..config import AgentConfiguration
|
|
17
|
+
from ...structure.base import StructureBase
|
|
17
18
|
|
|
18
19
|
# Type variables for search workflow components
|
|
19
|
-
ItemType = TypeVar(
|
|
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
|
-
class SearchPlanner(
|
|
28
|
+
class SearchPlanner(AgentBase, Generic[PlanType]):
|
|
27
29
|
"""Generic planner agent for search workflows.
|
|
28
30
|
|
|
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
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(BaseAgent, 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,
|
|
@@ -65,14 +82,14 @@ class SearchPlanner(BaseAgent, Generic[PlanType]):
|
|
|
65
82
|
Returns
|
|
66
83
|
-------
|
|
67
84
|
AgentConfiguration
|
|
68
|
-
Configuration with name, description, and
|
|
85
|
+
Configuration with name, description, and output_structure set.
|
|
69
86
|
|
|
70
87
|
Examples
|
|
71
88
|
--------
|
|
72
89
|
>>> config = AgentConfiguration(
|
|
73
90
|
... name="web_planner",
|
|
74
91
|
... description="Plan web searches",
|
|
75
|
-
...
|
|
92
|
+
... output_structure=WebSearchPlanStructure,
|
|
76
93
|
... )
|
|
77
94
|
>>> return config
|
|
78
95
|
"""
|
|
@@ -93,18 +110,27 @@ class SearchPlanner(BaseAgent, Generic[PlanType]):
|
|
|
93
110
|
"""
|
|
94
111
|
result: PlanType = await self.run_async(
|
|
95
112
|
input=query,
|
|
96
|
-
|
|
113
|
+
output_structure=self._output_structure,
|
|
97
114
|
)
|
|
98
115
|
return result
|
|
99
116
|
|
|
100
117
|
|
|
101
|
-
class SearchToolAgent(
|
|
118
|
+
class SearchToolAgent(AgentBase, Generic[ItemType, ResultType, PlanType]):
|
|
102
119
|
"""Generic tool agent for executing search workflows.
|
|
103
120
|
|
|
104
121
|
Executes individual searches in a plan with concurrency control.
|
|
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)
|
|
@@ -113,6 +139,24 @@ class SearchToolAgent(BaseAgent, Generic[ItemType, ResultType, PlanType]):
|
|
|
113
139
|
Execute a single search item.
|
|
114
140
|
_configure_agent()
|
|
115
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(BaseAgent, 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__(
|
|
@@ -148,14 +182,14 @@ class SearchToolAgent(BaseAgent, Generic[ItemType, ResultType, PlanType]):
|
|
|
148
182
|
Returns
|
|
149
183
|
-------
|
|
150
184
|
AgentConfiguration
|
|
151
|
-
Configuration with name, description,
|
|
185
|
+
Configuration with name, description, input_structure, and tools set.
|
|
152
186
|
|
|
153
187
|
Examples
|
|
154
188
|
--------
|
|
155
189
|
>>> config = AgentConfiguration(
|
|
156
190
|
... name="web_search",
|
|
157
191
|
... description="Perform web searches",
|
|
158
|
-
...
|
|
192
|
+
... input_structure=WebSearchPlanStructure,
|
|
159
193
|
... tools=[WebSearchTool()],
|
|
160
194
|
... )
|
|
161
195
|
>>> return config
|
|
@@ -205,18 +239,41 @@ class SearchToolAgent(BaseAgent, Generic[ItemType, ResultType, PlanType]):
|
|
|
205
239
|
return [result for result in results if result is not None]
|
|
206
240
|
|
|
207
241
|
|
|
208
|
-
class SearchWriter(
|
|
242
|
+
class SearchWriter(AgentBase, Generic[ReportType]):
|
|
209
243
|
"""Generic writer agent for search workflow reports.
|
|
210
244
|
|
|
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
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(BaseAgent, 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,
|
|
@@ -247,14 +296,14 @@ class SearchWriter(BaseAgent, Generic[ReportType]):
|
|
|
247
296
|
Returns
|
|
248
297
|
-------
|
|
249
298
|
AgentConfiguration
|
|
250
|
-
Configuration with name, description, and
|
|
299
|
+
Configuration with name, description, and output_structure set.
|
|
251
300
|
|
|
252
301
|
Examples
|
|
253
302
|
--------
|
|
254
303
|
>>> config = AgentConfiguration(
|
|
255
304
|
... name="web_writer",
|
|
256
305
|
... description="Write web search report",
|
|
257
|
-
...
|
|
306
|
+
... output_structure=WebSearchReportStructure,
|
|
258
307
|
... )
|
|
259
308
|
>>> return config
|
|
260
309
|
"""
|
|
@@ -286,7 +335,7 @@ class SearchWriter(BaseAgent, Generic[ReportType]):
|
|
|
286
335
|
result: ReportType = await self.run_async(
|
|
287
336
|
input=query,
|
|
288
337
|
context=template_context,
|
|
289
|
-
|
|
338
|
+
output_structure=self._output_structure,
|
|
290
339
|
)
|
|
291
340
|
return result
|
|
292
341
|
|
|
@@ -26,24 +26,32 @@ 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
57
|
def _configure_agent(self) -> AgentConfiguration:
|
|
@@ -58,7 +66,7 @@ class VectorSearchPlanner(SearchPlanner[VectorSearchPlanStructure]):
|
|
|
58
66
|
name="vector_planner",
|
|
59
67
|
instructions="Agent instructions",
|
|
60
68
|
description="Plan vector searches based on a user query.",
|
|
61
|
-
|
|
69
|
+
output_structure=VectorSearchPlanStructure,
|
|
62
70
|
)
|
|
63
71
|
|
|
64
72
|
|
|
@@ -71,12 +79,37 @@ class VectorSearchTool(
|
|
|
71
79
|
):
|
|
72
80
|
"""Execute vector searches defined in a search plan.
|
|
73
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
|
+
|
|
74
98
|
Methods
|
|
75
99
|
-------
|
|
76
100
|
run_agent(search_plan)
|
|
77
101
|
Execute searches described by the plan.
|
|
78
102
|
run_search(item)
|
|
79
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")
|
|
80
113
|
"""
|
|
81
114
|
|
|
82
115
|
def __init__(
|
|
@@ -89,24 +122,7 @@ class VectorSearchTool(
|
|
|
89
122
|
vector_storage: Optional[VectorStorage] = None,
|
|
90
123
|
vector_storage_factory: Optional[Callable[[str], VectorStorage]] = None,
|
|
91
124
|
) -> None:
|
|
92
|
-
"""Initialize the search tool agent.
|
|
93
|
-
|
|
94
|
-
Parameters
|
|
95
|
-
----------
|
|
96
|
-
prompt_dir : Path or None, default=None
|
|
97
|
-
Directory containing prompt templates.
|
|
98
|
-
default_model : str or None, default=None
|
|
99
|
-
Default model identifier to use when not defined in config.
|
|
100
|
-
store_name : str or None, default=None
|
|
101
|
-
Name of the vector store to query.
|
|
102
|
-
max_concurrent_searches : int, default=MAX_CONCURRENT_SEARCHES
|
|
103
|
-
Maximum number of concurrent vector search tasks to run.
|
|
104
|
-
vector_storage : VectorStorage or None, default=None
|
|
105
|
-
Optional preconfigured vector storage instance to reuse.
|
|
106
|
-
vector_storage_factory : Callable or None, default=None
|
|
107
|
-
Factory for constructing a VectorStorage when one is not provided.
|
|
108
|
-
Receives ``store_name`` as an argument.
|
|
109
|
-
"""
|
|
125
|
+
"""Initialize the search tool agent."""
|
|
110
126
|
self._vector_storage: Optional[VectorStorage] = None
|
|
111
127
|
self._store_name = store_name or "editorial"
|
|
112
128
|
self._vector_storage_factory = vector_storage_factory
|
|
@@ -130,8 +146,8 @@ class VectorSearchTool(
|
|
|
130
146
|
name="vector_search",
|
|
131
147
|
instructions="Agent instructions",
|
|
132
148
|
description="Perform vector searches based on a search plan.",
|
|
133
|
-
|
|
134
|
-
|
|
149
|
+
input_structure=VectorSearchPlanStructure,
|
|
150
|
+
output_structure=VectorSearchItemResultsStructure,
|
|
135
151
|
)
|
|
136
152
|
|
|
137
153
|
def _get_vector_storage(self) -> VectorStorage:
|
|
@@ -181,24 +197,32 @@ class VectorSearchTool(
|
|
|
181
197
|
class VectorSearchWriter(SearchWriter[VectorSearchReportStructure]):
|
|
182
198
|
"""Generate reports summarizing vector search results.
|
|
183
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
|
+
|
|
184
207
|
Methods
|
|
185
208
|
-------
|
|
186
209
|
run_agent(query, search_results)
|
|
187
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")
|
|
188
220
|
"""
|
|
189
221
|
|
|
190
222
|
def __init__(
|
|
191
223
|
self, prompt_dir: Optional[Path] = None, default_model: Optional[str] = None
|
|
192
224
|
) -> None:
|
|
193
|
-
"""Initialize the writer agent.
|
|
194
|
-
|
|
195
|
-
Parameters
|
|
196
|
-
----------
|
|
197
|
-
prompt_dir : Path or None, default=None
|
|
198
|
-
Directory containing prompt templates.
|
|
199
|
-
default_model : str or None, default=None
|
|
200
|
-
Default model identifier to use when not defined in config.
|
|
201
|
-
"""
|
|
225
|
+
"""Initialize the writer agent."""
|
|
202
226
|
super().__init__(prompt_dir=prompt_dir, default_model=default_model)
|
|
203
227
|
|
|
204
228
|
def _configure_agent(self) -> AgentConfiguration:
|
|
@@ -213,7 +237,7 @@ class VectorSearchWriter(SearchWriter[VectorSearchReportStructure]):
|
|
|
213
237
|
name="vector_writer",
|
|
214
238
|
instructions="Agent instructions",
|
|
215
239
|
description="Write a report based on search results.",
|
|
216
|
-
|
|
240
|
+
output_structure=VectorSearchReportStructure,
|
|
217
241
|
)
|
|
218
242
|
|
|
219
243
|
|
|
@@ -225,6 +249,22 @@ class VectorSearch:
|
|
|
225
249
|
comprehensive reports. It combines ``VectorSearchPlanner``,
|
|
226
250
|
``VectorSearchTool``, and ``VectorSearchWriter`` into a single workflow.
|
|
227
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
|
+
|
|
228
268
|
Examples
|
|
229
269
|
--------
|
|
230
270
|
Basic vector search:
|
|
@@ -256,6 +296,11 @@ class VectorSearch:
|
|
|
256
296
|
Convenience asynchronous entry point for the workflow.
|
|
257
297
|
run_vector_agent_sync(search_query)
|
|
258
298
|
Convenience synchronous entry point for the workflow.
|
|
299
|
+
|
|
300
|
+
Raises
|
|
301
|
+
------
|
|
302
|
+
ValueError
|
|
303
|
+
If the default model is not provided.
|
|
259
304
|
"""
|
|
260
305
|
|
|
261
306
|
def __init__(
|
|
@@ -268,24 +313,7 @@ class VectorSearch:
|
|
|
268
313
|
vector_storage: Optional[VectorStorage] = None,
|
|
269
314
|
vector_storage_factory: Optional[Callable[[str], VectorStorage]] = None,
|
|
270
315
|
) -> None:
|
|
271
|
-
"""Create the main VectorSearch agent.
|
|
272
|
-
|
|
273
|
-
Parameters
|
|
274
|
-
----------
|
|
275
|
-
prompt_dir : Path or None, default=None
|
|
276
|
-
Directory containing prompt templates.
|
|
277
|
-
default_model : str or None, default=None
|
|
278
|
-
Default model identifier to use when not defined in config.
|
|
279
|
-
vector_store_name : str or None, default=None
|
|
280
|
-
Name of the vector store to query.
|
|
281
|
-
max_concurrent_searches : int, default=MAX_CONCURRENT_SEARCHES
|
|
282
|
-
Maximum number of concurrent search tasks to run.
|
|
283
|
-
vector_storage : VectorStorage or None, default=None
|
|
284
|
-
Optional preconfigured vector storage instance to reuse.
|
|
285
|
-
vector_storage_factory : callable, default=None
|
|
286
|
-
Factory used to construct a VectorStorage when one is not provided.
|
|
287
|
-
Receives ``vector_store_name`` as an argument.
|
|
288
|
-
"""
|
|
316
|
+
"""Create the main VectorSearch agent."""
|
|
289
317
|
self._prompt_dir = prompt_dir
|
|
290
318
|
self._default_model = default_model
|
|
291
319
|
self._vector_store_name = vector_store_name
|