openai-sdk-helpers 0.0.2__tar.gz → 0.0.4__tar.gz

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 (78) hide show
  1. {openai_sdk_helpers-0.0.2 → openai_sdk_helpers-0.0.4}/PKG-INFO +57 -4
  2. {openai_sdk_helpers-0.0.2 → openai_sdk_helpers-0.0.4}/README.md +56 -3
  3. openai_sdk_helpers-0.0.4/openai_sdk_helpers/__init__.py +62 -0
  4. openai_sdk_helpers-0.0.4/openai_sdk_helpers/agent/__init__.py +31 -0
  5. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/agent/base.py +46 -148
  6. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/agent/config.py +2 -2
  7. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/agent/project_manager.py +125 -30
  8. openai_sdk_helpers-0.0.4/openai_sdk_helpers/agent/prompt_utils.py +9 -0
  9. openai_sdk_helpers-0.0.4/openai_sdk_helpers/agent/runner.py +215 -0
  10. openai_sdk_helpers-0.0.4/openai_sdk_helpers/agent/summarizer.py +85 -0
  11. openai_sdk_helpers-0.0.4/openai_sdk_helpers/agent/translator.py +139 -0
  12. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/agent/utils.py +2 -2
  13. openai_sdk_helpers-0.0.4/openai_sdk_helpers/agent/validation.py +97 -0
  14. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/agent/vector_search.py +67 -23
  15. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/agent/web_search.py +18 -18
  16. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/config.py +13 -1
  17. openai_sdk_helpers-0.0.4/openai_sdk_helpers/enums/base.py +29 -0
  18. openai_sdk_helpers-0.0.4/openai_sdk_helpers/prompt/summarizer.jinja +7 -0
  19. openai_sdk_helpers-0.0.4/openai_sdk_helpers/prompt/translator.jinja +7 -0
  20. openai_sdk_helpers-0.0.4/openai_sdk_helpers/prompt/validator.jinja +7 -0
  21. openai_sdk_helpers-0.0.4/openai_sdk_helpers/py.typed +0 -0
  22. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/response/__init__.py +4 -2
  23. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/response/base.py +34 -10
  24. openai_sdk_helpers-0.0.4/openai_sdk_helpers/response/runner.py +104 -0
  25. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/structure/__init__.py +11 -25
  26. openai_sdk_helpers-0.0.4/openai_sdk_helpers/structure/agent_blueprint.py +224 -0
  27. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/structure/base.py +158 -36
  28. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/structure/plan/__init__.py +4 -4
  29. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/structure/plan/enum.py +16 -0
  30. openai_sdk_helpers-0.0.4/openai_sdk_helpers/structure/plan/plan.py +253 -0
  31. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/structure/plan/task.py +5 -5
  32. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/structure/responses.py +7 -23
  33. openai_sdk_helpers-0.0.4/openai_sdk_helpers/structure/validation.py +47 -0
  34. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/structure/vector_search.py +4 -0
  35. {openai_sdk_helpers-0.0.2 → openai_sdk_helpers-0.0.4}/pyproject.toml +3 -2
  36. openai_sdk_helpers-0.0.2/.github/dependabot.yml +0 -10
  37. openai_sdk_helpers-0.0.2/.github/workflows/ci.yml +0 -44
  38. openai_sdk_helpers-0.0.2/.github/workflows/python-publish.yml +0 -39
  39. openai_sdk_helpers-0.0.2/AGENTS.md +0 -82
  40. openai_sdk_helpers-0.0.2/src/openai_sdk_helpers/__init__.py +0 -34
  41. openai_sdk_helpers-0.0.2/src/openai_sdk_helpers/agent/__init__.py +0 -23
  42. openai_sdk_helpers-0.0.2/src/openai_sdk_helpers/agent/runner.py +0 -117
  43. openai_sdk_helpers-0.0.2/src/openai_sdk_helpers/enums/base.py +0 -17
  44. openai_sdk_helpers-0.0.2/src/openai_sdk_helpers/response/runner.py +0 -42
  45. openai_sdk_helpers-0.0.2/src/openai_sdk_helpers/structure/plan/plan.py +0 -104
  46. openai_sdk_helpers-0.0.2/tests/agent/test_agent_base.py +0 -116
  47. openai_sdk_helpers-0.0.2/tests/agent/test_agent_runner.py +0 -45
  48. openai_sdk_helpers-0.0.2/tests/agent/test_agent_utils.py +0 -27
  49. openai_sdk_helpers-0.0.2/tests/agent/test_project_manager.py +0 -159
  50. openai_sdk_helpers-0.0.2/tests/conftest.py +0 -12
  51. openai_sdk_helpers-0.0.2/tests/response/test_response_base.py +0 -31
  52. openai_sdk_helpers-0.0.2/tests/response/test_response_base_unit.py +0 -63
  53. openai_sdk_helpers-0.0.2/tests/structure/test_structure_base.py +0 -148
  54. openai_sdk_helpers-0.0.2/tests/test_config.py +0 -58
  55. openai_sdk_helpers-0.0.2/tests/test_imports.py +0 -21
  56. openai_sdk_helpers-0.0.2/tests/test_integration.py +0 -57
  57. openai_sdk_helpers-0.0.2/tests/test_prompt_renderer.py +0 -26
  58. openai_sdk_helpers-0.0.2/tests/test_utils.py +0 -108
  59. openai_sdk_helpers-0.0.2/tests/test_vector_types.py +0 -35
  60. openai_sdk_helpers-0.0.2/tests/vector_storage/test_cleanup.py +0 -116
  61. openai_sdk_helpers-0.0.2/tests/vector_storage/test_storage.py +0 -163
  62. openai_sdk_helpers-0.0.2/tests/vector_storage/test_vector_storage.py +0 -64
  63. {openai_sdk_helpers-0.0.2 → openai_sdk_helpers-0.0.4}/.gitignore +0 -0
  64. {openai_sdk_helpers-0.0.2 → openai_sdk_helpers-0.0.4}/LICENSE +0 -0
  65. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/enums/__init__.py +0 -0
  66. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/environment.py +0 -0
  67. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/prompt/__init__.py +0 -0
  68. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/response/messages.py +0 -0
  69. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/response/tool_call.py +0 -0
  70. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/structure/prompt.py +0 -0
  71. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/structure/summary.py +0 -0
  72. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/structure/web_search.py +0 -0
  73. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/utils/__init__.py +0 -0
  74. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/utils/core.py +0 -0
  75. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/vector_storage/__init__.py +0 -0
  76. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/vector_storage/cleanup.py +0 -0
  77. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/vector_storage/storage.py +0 -0
  78. {openai_sdk_helpers-0.0.2/src → openai_sdk_helpers-0.0.4}/openai_sdk_helpers/vector_storage/types.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openai-sdk-helpers
3
- Version: 0.0.2
3
+ Version: 0.0.4
4
4
  Summary: Composable helpers for OpenAI SDK agents, prompts, and storage
5
5
  Author: openai-sdk-helpers maintainers
6
6
  License: MIT
@@ -39,6 +39,7 @@ application-specific prompts and tools to the consuming project.
39
39
  predictable inputs and outputs.
40
40
  - **Vector and web search flows** that coordinate planning, execution, and
41
41
  reporting.
42
+ - **Reusable text agents** for summarization and translation tasks.
42
43
 
43
44
  ## Installation
44
45
 
@@ -48,6 +49,9 @@ Install the package directly from PyPI to reuse it across projects:
48
49
  pip install openai-sdk-helpers
49
50
  ```
50
51
 
52
+ Type information ships with the published wheel via `py.typed`, so external
53
+ projects can rely on the bundled annotations without adding custom stubs.
54
+
51
55
  For local development, install with editable sources and the optional dev
52
56
  dependencies:
53
57
 
@@ -74,9 +78,39 @@ report = vector_search.run_agent_sync("Explain quantum entanglement for beginner
74
78
  print(report.report)
75
79
  ```
76
80
 
77
- You can plug in your own prompt templates by placing matching `.jinja` files in
78
- the provided `prompt_dir` and naming them after the agent (for example,
79
- `vector_planner.jinja`).
81
+ ### Text utilities
82
+
83
+ Use the built-in text helpers when you need lightweight single-step agents.
84
+
85
+ ```python
86
+ from openai_sdk_helpers.agent import (
87
+ SummarizerAgent,
88
+ TranslatorAgent,
89
+ ValidatorAgent,
90
+ )
91
+
92
+
93
+ summarizer = SummarizerAgent(default_model="gpt-4o-mini")
94
+ translator = TranslatorAgent(default_model="gpt-4o-mini")
95
+ validator = ValidatorAgent(default_model="gpt-4o-mini")
96
+
97
+ summary = summarizer.run_sync("Long-form content to condense")
98
+ translation = translator.run_sync("Bonjour", target_language="English")
99
+ guardrails = validator.run_sync(
100
+ "Share meeting notes with names removed", agent_output=summary.text
101
+ )
102
+ ```
103
+
104
+ Prompt templates are optional for the built-in text helpers. They already ship
105
+ with defaults under `src/openai_sdk_helpers/prompt`, so you do **not** need to
106
+ create placeholder files when installing from PyPI. Only pass a `prompt_dir`
107
+ when you have real replacements you want to load.
108
+
109
+ The vector search workflow expects real prompts for each agent (for example,
110
+ `vector_planner.jinja`, `vector_search.jinja`, and `vector_writer.jinja`). If
111
+ you point `prompt_dir` at a folder that does not contain those files, agent
112
+ construction fails with a `FileNotFoundError`. Skip `prompt_dir` entirely unless
113
+ you have working templates ready.
80
114
 
81
115
  ### Centralized OpenAI configuration
82
116
 
@@ -129,6 +163,25 @@ pytest -q --cov=src --cov-report=term-missing --cov-fail-under=70
129
163
  - `src/openai_sdk_helpers/vector_storage`: Minimal vector store abstraction.
130
164
  - `tests/`: Unit tests covering core modules and structures.
131
165
 
166
+ ## Key modules
167
+
168
+ The package centers around a handful of cohesive building blocks:
169
+
170
+ - `openai_sdk_helpers.agent.project_manager.ProjectManager` coordinates prompt
171
+ creation, plan building, task execution, and summarization while persisting
172
+ intermediate artifacts to disk.
173
+ - `openai_sdk_helpers.agent.vector_search.VectorSearch` bundles the planners,
174
+ executors, and summarizers required to run a multi-turn vector search flow
175
+ from a single entry point.
176
+ - `openai_sdk_helpers.agent.summarizer.SummarizerAgent`,
177
+ `agent.translator.TranslatorAgent`, and `agent.validator.ValidatorAgent`
178
+ expose streamlined text-processing utilities that reuse shared prompt
179
+ templates.
180
+ - `openai_sdk_helpers.response` contains the response runners and helpers used
181
+ to normalize outputs from agents, including streaming responses.
182
+ - `openai_sdk_helpers.utils` holds JSON serialization helpers, logging
183
+ utilities, and common validation helpers used across modules.
184
+
132
185
  ## Contributing
133
186
 
134
187
  Contributions are welcome! Please accompany functional changes with relevant
@@ -23,6 +23,7 @@ application-specific prompts and tools to the consuming project.
23
23
  predictable inputs and outputs.
24
24
  - **Vector and web search flows** that coordinate planning, execution, and
25
25
  reporting.
26
+ - **Reusable text agents** for summarization and translation tasks.
26
27
 
27
28
  ## Installation
28
29
 
@@ -32,6 +33,9 @@ Install the package directly from PyPI to reuse it across projects:
32
33
  pip install openai-sdk-helpers
33
34
  ```
34
35
 
36
+ Type information ships with the published wheel via `py.typed`, so external
37
+ projects can rely on the bundled annotations without adding custom stubs.
38
+
35
39
  For local development, install with editable sources and the optional dev
36
40
  dependencies:
37
41
 
@@ -58,9 +62,39 @@ report = vector_search.run_agent_sync("Explain quantum entanglement for beginner
58
62
  print(report.report)
59
63
  ```
60
64
 
61
- You can plug in your own prompt templates by placing matching `.jinja` files in
62
- the provided `prompt_dir` and naming them after the agent (for example,
63
- `vector_planner.jinja`).
65
+ ### Text utilities
66
+
67
+ Use the built-in text helpers when you need lightweight single-step agents.
68
+
69
+ ```python
70
+ from openai_sdk_helpers.agent import (
71
+ SummarizerAgent,
72
+ TranslatorAgent,
73
+ ValidatorAgent,
74
+ )
75
+
76
+
77
+ summarizer = SummarizerAgent(default_model="gpt-4o-mini")
78
+ translator = TranslatorAgent(default_model="gpt-4o-mini")
79
+ validator = ValidatorAgent(default_model="gpt-4o-mini")
80
+
81
+ summary = summarizer.run_sync("Long-form content to condense")
82
+ translation = translator.run_sync("Bonjour", target_language="English")
83
+ guardrails = validator.run_sync(
84
+ "Share meeting notes with names removed", agent_output=summary.text
85
+ )
86
+ ```
87
+
88
+ Prompt templates are optional for the built-in text helpers. They already ship
89
+ with defaults under `src/openai_sdk_helpers/prompt`, so you do **not** need to
90
+ create placeholder files when installing from PyPI. Only pass a `prompt_dir`
91
+ when you have real replacements you want to load.
92
+
93
+ The vector search workflow expects real prompts for each agent (for example,
94
+ `vector_planner.jinja`, `vector_search.jinja`, and `vector_writer.jinja`). If
95
+ you point `prompt_dir` at a folder that does not contain those files, agent
96
+ construction fails with a `FileNotFoundError`. Skip `prompt_dir` entirely unless
97
+ you have working templates ready.
64
98
 
65
99
  ### Centralized OpenAI configuration
66
100
 
@@ -113,6 +147,25 @@ pytest -q --cov=src --cov-report=term-missing --cov-fail-under=70
113
147
  - `src/openai_sdk_helpers/vector_storage`: Minimal vector store abstraction.
114
148
  - `tests/`: Unit tests covering core modules and structures.
115
149
 
150
+ ## Key modules
151
+
152
+ The package centers around a handful of cohesive building blocks:
153
+
154
+ - `openai_sdk_helpers.agent.project_manager.ProjectManager` coordinates prompt
155
+ creation, plan building, task execution, and summarization while persisting
156
+ intermediate artifacts to disk.
157
+ - `openai_sdk_helpers.agent.vector_search.VectorSearch` bundles the planners,
158
+ executors, and summarizers required to run a multi-turn vector search flow
159
+ from a single entry point.
160
+ - `openai_sdk_helpers.agent.summarizer.SummarizerAgent`,
161
+ `agent.translator.TranslatorAgent`, and `agent.validator.ValidatorAgent`
162
+ expose streamlined text-processing utilities that reuse shared prompt
163
+ templates.
164
+ - `openai_sdk_helpers.response` contains the response runners and helpers used
165
+ to normalize outputs from agents, including streaming responses.
166
+ - `openai_sdk_helpers.utils` holds JSON serialization helpers, logging
167
+ utilities, and common validation helpers used across modules.
168
+
116
169
  ## Contributing
117
170
 
118
171
  Contributions are welcome! Please accompany functional changes with relevant
@@ -0,0 +1,62 @@
1
+ """Shared AI helpers and base structures."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from .structure import *
6
+ from .prompt import PromptRenderer
7
+ from .config import OpenAISettings
8
+ from .vector_storage import *
9
+ from .agent import (
10
+ AgentBase,
11
+ AgentConfig,
12
+ AgentEnum,
13
+ ProjectManager,
14
+ SummarizerAgent,
15
+ TranslatorAgent,
16
+ ValidatorAgent,
17
+ VectorSearch,
18
+ WebAgentSearch,
19
+ )
20
+ from .response import (
21
+ ResponseBase,
22
+ ResponseMessage,
23
+ ResponseMessages,
24
+ ResponseToolCall,
25
+ )
26
+
27
+ __all__ = [
28
+ "BaseStructure",
29
+ "SchemaOptions",
30
+ "spec_field",
31
+ "PromptRenderer",
32
+ "OpenAISettings",
33
+ "VectorStorage",
34
+ "VectorStorageFileInfo",
35
+ "VectorStorageFileStats",
36
+ "assistant_tool_definition",
37
+ "assistant_format",
38
+ "response_tool_definition",
39
+ "response_format",
40
+ "SummaryStructure",
41
+ "PromptStructure",
42
+ "AgentBlueprint",
43
+ "TaskStructure",
44
+ "PlanStructure",
45
+ "AgentEnum",
46
+ "AgentBase",
47
+ "AgentConfig",
48
+ "ProjectManager",
49
+ "SummarizerAgent",
50
+ "TranslatorAgent",
51
+ "ValidatorAgent",
52
+ "VectorSearch",
53
+ "WebAgentSearch",
54
+ "ExtendedSummaryStructure",
55
+ "WebSearchStructure",
56
+ "VectorSearchStructure",
57
+ "ValidationResultStructure",
58
+ "ResponseBase",
59
+ "ResponseMessage",
60
+ "ResponseMessages",
61
+ "ResponseToolCall",
62
+ ]
@@ -0,0 +1,31 @@
1
+ """Shared agent helpers built on the OpenAI Agents SDK."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from .base import AgentBase
6
+ from .config import AgentConfig
7
+ from ..structure.plan.enum import AgentEnum
8
+ from .project_manager import ProjectManager
9
+ from .runner import run_sync, run_async, run_streamed
10
+ from .summarizer import SummarizerAgent
11
+ from .translator import TranslatorAgent
12
+ from .validation import ValidatorAgent
13
+ from .utils import run_coroutine_agent_sync
14
+ from .vector_search import VectorSearch
15
+ from .web_search import WebAgentSearch
16
+
17
+ __all__ = [
18
+ "AgentBase",
19
+ "AgentConfig",
20
+ "AgentEnum",
21
+ "ProjectManager",
22
+ "run_sync",
23
+ "run_async",
24
+ "run_streamed",
25
+ "run_coroutine_agent_sync",
26
+ "SummarizerAgent",
27
+ "TranslatorAgent",
28
+ "ValidatorAgent",
29
+ "VectorSearch",
30
+ "WebAgentSearch",
31
+ ]
@@ -11,10 +11,11 @@ from agents import Agent, Runner, RunResult, RunResultStreaming
11
11
  from agents.run_context import RunContextWrapper
12
12
  from agents.tool import FunctionTool
13
13
  from jinja2 import Template
14
+ from .runner import run_sync, run_streamed, run_async
14
15
 
15
16
 
16
17
  class AgentConfigLike(Protocol):
17
- """Protocol describing the configuration attributes for BaseAgent."""
18
+ """Protocol describing the configuration attributes for AgentBase."""
18
19
 
19
20
  name: str
20
21
  description: Optional[str]
@@ -26,24 +27,26 @@ class AgentConfigLike(Protocol):
26
27
  model_settings: Optional[Any]
27
28
 
28
29
 
29
- class BaseAgent:
30
+ class AgentBase:
30
31
  """Factory for creating and configuring specialized agents.
31
32
 
32
33
  Methods
33
34
  -------
34
35
  from_config(config, run_context_wrapper)
35
- Instantiate a ``BaseAgent`` from configuration.
36
+ Instantiate a ``AgentBase`` from configuration.
36
37
  build_prompt_from_jinja(run_context_wrapper)
37
38
  Render the agent prompt using Jinja and optional context.
38
39
  get_prompt(run_context_wrapper, _)
39
40
  Render the agent prompt using the provided run context.
40
41
  get_agent()
41
42
  Construct the configured :class:`agents.Agent` instance.
42
- run(agent_input, agent_context, output_type)
43
+ run(input, context, output_type)
44
+ Execute the agent asynchronously (alias of ``run_async``).
45
+ run_async(input, context, output_type)
43
46
  Execute the agent asynchronously and optionally cast the result.
44
- run_sync(agent_input, agent_context, output_type)
47
+ run_sync(input, context, output_type)
45
48
  Execute the agent synchronously.
46
- run_streamed(agent_input, agent_context, output_type)
49
+ run_streamed(input, context, output_type)
47
50
  Return a streaming result for the agent execution.
48
51
  as_tool()
49
52
  Return the agent as a callable tool.
@@ -56,7 +59,7 @@ class BaseAgent:
56
59
  prompt_dir: Optional[Path] = None,
57
60
  default_model: Optional[str] = None,
58
61
  ) -> None:
59
- """Initialize the ``BaseAgent`` using a configuration object.
62
+ """Initialize the ``AgentBase`` using a configuration object.
60
63
 
61
64
  Parameters
62
65
  ----------
@@ -88,10 +91,14 @@ class BaseAgent:
88
91
  else:
89
92
  prompt_path = None
90
93
 
91
- if prompt_path is not None and prompt_path.exists():
94
+ if prompt_path is None:
95
+ self._template = Template("")
96
+ elif prompt_path.exists():
92
97
  self._template = Template(prompt_path.read_text())
93
98
  else:
94
- self._template = Template("")
99
+ raise FileNotFoundError(
100
+ f"Prompt template for agent '{name}' not found at {prompt_path}."
101
+ )
95
102
 
96
103
  self.agent_name = name
97
104
  self.description = description
@@ -110,8 +117,8 @@ class BaseAgent:
110
117
  run_context_wrapper: Optional[RunContextWrapper[Dict[str, Any]]] = None,
111
118
  prompt_dir: Optional[Path] = None,
112
119
  default_model: Optional[str] = None,
113
- ) -> "BaseAgent":
114
- """Create a :class:`BaseAgent` instance from configuration.
120
+ ) -> "AgentBase":
121
+ """Create a :class:`AgentBase` instance from configuration.
115
122
 
116
123
  Parameters
117
124
  ----------
@@ -126,7 +133,7 @@ class BaseAgent:
126
133
 
127
134
  Returns
128
135
  -------
129
- BaseAgent
136
+ AgentBase
130
137
  Instantiated agent.
131
138
  """
132
139
  return cls(
@@ -136,7 +143,7 @@ class BaseAgent:
136
143
  default_model=default_model,
137
144
  )
138
145
 
139
- def _build_instructions_from_jinja(self) -> str:
146
+ def _build_prompt_from_jinja(self) -> str:
140
147
  """Return the rendered instructions prompt for this agent.
141
148
 
142
149
  Returns
@@ -200,7 +207,7 @@ class BaseAgent:
200
207
  """
201
208
  agent_config: Dict[str, Any] = {
202
209
  "name": self.agent_name,
203
- "instructions": self._build_instructions_from_jinja(),
210
+ "instructions": self._build_prompt_from_jinja(),
204
211
  "model": self.model,
205
212
  }
206
213
  if self._output_type:
@@ -212,19 +219,19 @@ class BaseAgent:
212
219
 
213
220
  return Agent(**agent_config)
214
221
 
215
- async def run(
222
+ async def run_async(
216
223
  self,
217
- agent_input: str,
218
- agent_context: Optional[Dict[str, Any]] = None,
224
+ input: str,
225
+ context: Optional[Dict[str, Any]] = None,
219
226
  output_type: Optional[Any] = None,
220
227
  ) -> Any:
221
228
  """Execute the agent asynchronously.
222
229
 
223
230
  Parameters
224
231
  ----------
225
- agent_input
232
+ input
226
233
  Prompt or query for the agent.
227
- agent_context
234
+ context
228
235
  Optional dictionary passed to the agent. Default ``None``.
229
236
  output_type
230
237
  Optional type used to cast the final output. Default ``None``.
@@ -236,26 +243,26 @@ class BaseAgent:
236
243
  """
237
244
  if self._output_type is not None and output_type is None:
238
245
  output_type = self._output_type
239
- return await _run_agent(
246
+ return await run_async(
240
247
  agent=self.get_agent(),
241
- agent_input=agent_input,
242
- agent_context=agent_context,
248
+ input=input,
249
+ context=context,
243
250
  output_type=output_type,
244
251
  )
245
252
 
246
253
  def run_sync(
247
254
  self,
248
- agent_input: str,
249
- agent_context: Optional[Dict[str, Any]] = None,
255
+ input: str,
256
+ context: Optional[Dict[str, Any]] = None,
250
257
  output_type: Optional[Any] = None,
251
258
  ) -> Any:
252
259
  """Run the agent synchronously.
253
260
 
254
261
  Parameters
255
262
  ----------
256
- agent_input
263
+ input
257
264
  Prompt or query for the agent.
258
- agent_context
265
+ context
259
266
  Optional dictionary passed to the agent. Default ``None``.
260
267
  output_type
261
268
  Optional type used to cast the final output. Default ``None``.
@@ -265,30 +272,26 @@ class BaseAgent:
265
272
  Any
266
273
  Agent result, optionally converted to ``output_type``.
267
274
  """
268
- result = _run_agent_sync(
269
- self.get_agent(),
270
- agent_input,
271
- agent_context=agent_context,
275
+ return run_sync(
276
+ agent=self.get_agent(),
277
+ input=input,
278
+ context=context,
279
+ output_type=output_type,
272
280
  )
273
- if self._output_type and not output_type:
274
- output_type = self._output_type
275
- if output_type:
276
- return result.final_output_as(output_type)
277
- return result
278
281
 
279
282
  def run_streamed(
280
283
  self,
281
- agent_input: str,
282
- agent_context: Optional[Dict[str, Any]] = None,
284
+ input: str,
285
+ context: Optional[Dict[str, Any]] = None,
283
286
  output_type: Optional[Any] = None,
284
287
  ) -> RunResultStreaming:
285
288
  """Return a streaming result for the agent execution.
286
289
 
287
290
  Parameters
288
291
  ----------
289
- agent_input
292
+ input
290
293
  Prompt or query for the agent.
291
- agent_context
294
+ context
292
295
  Optional dictionary passed to the agent. Default ``None``.
293
296
  output_type
294
297
  Optional type used to cast the final output. Default ``None``.
@@ -298,10 +301,10 @@ class BaseAgent:
298
301
  RunResultStreaming
299
302
  Streaming output wrapper from the agent execution.
300
303
  """
301
- result = _run_agent_streamed(
304
+ result = run_streamed(
302
305
  agent=self.get_agent(),
303
- agent_input=agent_input,
304
- context=agent_context,
306
+ input=input,
307
+ context=context,
305
308
  )
306
309
  if self._output_type and not output_type:
307
310
  output_type = self._output_type
@@ -324,109 +327,4 @@ class BaseAgent:
324
327
  return tool_obj
325
328
 
326
329
 
327
- async def _run_agent(
328
- agent: Agent,
329
- agent_input: str,
330
- agent_context: Optional[Dict[str, Any]] = None,
331
- output_type: Optional[Any] = None,
332
- ) -> Any:
333
- """Run an ``Agent`` asynchronously.
334
-
335
- Parameters
336
- ----------
337
- agent
338
- Configured agent instance to execute.
339
- agent_input
340
- Prompt or query string for the agent.
341
- agent_context
342
- Optional context dictionary passed to the agent. Default ``None``.
343
- output_type
344
- Optional type used to cast the final output. Default ``None``.
345
-
346
- Returns
347
- -------
348
- Any
349
- Agent response, optionally converted to ``output_type``.
350
- """
351
- result = await Runner.run(agent, agent_input, context=agent_context)
352
- if output_type is not None:
353
- result = result.final_output_as(output_type)
354
- return result
355
-
356
-
357
- def _run_agent_sync(
358
- agent: Agent,
359
- agent_input: str,
360
- agent_context: Optional[Dict[str, Any]] = None,
361
- ) -> RunResult:
362
- """Run an ``Agent`` synchronously.
363
-
364
- Parameters
365
- ----------
366
- agent
367
- Configured agent instance to execute.
368
- agent_input
369
- Prompt or query string for the agent.
370
- agent_context
371
- Optional context dictionary passed to the agent. Default ``None``.
372
-
373
- Returns
374
- -------
375
- RunResult
376
- Result from the agent execution.
377
- """
378
- coro = Runner.run(agent, agent_input, context=agent_context)
379
- try:
380
- loop = asyncio.get_running_loop()
381
- except RuntimeError:
382
- return asyncio.run(coro)
383
-
384
- if loop.is_running():
385
- result: RunResult | None = None
386
-
387
- def _thread_runner() -> None:
388
- nonlocal result
389
- result = asyncio.run(coro)
390
-
391
- thread = threading.Thread(target=_thread_runner, daemon=True)
392
- thread.start()
393
- thread.join()
394
- if result is None:
395
- raise RuntimeError("Agent execution did not return a result.")
396
- return result
397
-
398
- return loop.run_until_complete(coro)
399
-
400
-
401
- def _run_agent_streamed(
402
- agent: Agent,
403
- agent_input: str,
404
- context: Optional[Dict[str, Any]] = None,
405
- ) -> RunResultStreaming:
406
- """Run an ``Agent`` synchronously and return a streaming result.
407
-
408
- Parameters
409
- ----------
410
- agent
411
- Configured agent to execute.
412
- agent_input
413
- Prompt or query string for the agent.
414
- context
415
- Optional context dictionary passed to the agent. Default ``None``.
416
-
417
- Returns
418
- -------
419
- RunResultStreaming
420
- Instance for streaming outputs.
421
- """
422
- result = Runner.run_streamed(agent, agent_input, context=context)
423
- return result
424
-
425
-
426
- __all__ = [
427
- "AgentConfigLike",
428
- "BaseAgent",
429
- "_run_agent",
430
- "_run_agent_sync",
431
- "_run_agent_streamed",
432
- ]
330
+ __all__ = ["AgentConfigLike", "AgentBase"]
@@ -1,4 +1,4 @@
1
- """Configuration helpers for ``BaseAgent``."""
1
+ """Configuration helpers for ``AgentBase``."""
2
2
 
3
3
  from __future__ import annotations
4
4
 
@@ -11,7 +11,7 @@ from ..structure import BaseStructure
11
11
 
12
12
 
13
13
  class AgentConfig(BaseStructure):
14
- """Configuration required to build a :class:`BaseAgent`.
14
+ """Configuration required to build a :class:`AgentBase`.
15
15
 
16
16
  Methods
17
17
  -------