openai-sdk-helpers 0.4.0__tar.gz → 0.4.1__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.
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/PKG-INFO +1 -1
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/pyproject.toml +1 -1
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/__init__.py +2 -2
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/base.py +26 -6
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/config.py +9 -9
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/response/config.py +21 -8
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/streamlit_app/__init__.py +4 -4
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/streamlit_app/config.py +44 -33
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/__init__.py +2 -2
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/registry.py +31 -4
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/.gitignore +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/LICENSE +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/README.md +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/__init__.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/coordination.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/prompt_utils.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/runner.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/search/__init__.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/search/base.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/search/vector.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/search/web.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/summarizer.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/translator.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/utils.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/validation.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/cli.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/config.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/context_manager.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/deprecation.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/enums/__init__.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/enums/base.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/environment.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/errors.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/files_api.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/logging_config.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/prompt/__init__.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/prompt/base.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/prompt/summarizer.jinja +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/prompt/translator.jinja +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/prompt/validator.jinja +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/py.typed +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/response/__init__.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/response/base.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/response/files.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/response/messages.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/response/runner.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/response/tool_call.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/response/vector_store.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/retry.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/streamlit_app/app.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/streamlit_app/streamlit_web_search.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/__init__.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/agent_blueprint.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/base.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/plan/__init__.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/plan/enum.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/plan/helpers.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/plan/plan.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/plan/task.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/plan/types.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/prompt.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/responses.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/summary.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/translation.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/validation.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/vector_search.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/web_search.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/tools.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/types.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/async_utils.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/coercion.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/deprecation.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/encoding.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/instructions.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/json/__init__.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/json/base_model.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/json/data_class.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/json/ref.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/json/utils.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/output_validation.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/path_utils.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/validation.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/vector_storage/__init__.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/vector_storage/cleanup.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/vector_storage/storage.py +0 -0
- {openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/vector_storage/types.py +0 -0
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/__init__.py
RENAMED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
from .base import AgentBase
|
|
6
|
-
from .config import AgentConfiguration,
|
|
6
|
+
from .config import AgentConfiguration, AgentRegistry, get_default_registry
|
|
7
7
|
from ..structure.plan.enum import AgentEnum
|
|
8
8
|
from .coordination import CoordinatorAgent
|
|
9
9
|
from .runner import run_sync, run_async, run_streamed
|
|
@@ -18,7 +18,7 @@ from .search.web import WebAgentSearch
|
|
|
18
18
|
__all__ = [
|
|
19
19
|
"AgentBase",
|
|
20
20
|
"AgentConfiguration",
|
|
21
|
-
"
|
|
21
|
+
"AgentRegistry",
|
|
22
22
|
"get_default_registry",
|
|
23
23
|
"AgentEnum",
|
|
24
24
|
"CoordinatorAgent",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
from pathlib import Path
|
|
6
|
-
from typing import Any, Dict, Optional, Protocol, cast
|
|
6
|
+
from typing import Any, Callable, Dict, Optional, Protocol, cast
|
|
7
7
|
import uuid
|
|
8
8
|
|
|
9
9
|
from agents import (
|
|
@@ -30,7 +30,7 @@ from ..utils import (
|
|
|
30
30
|
from .runner import run_async, run_streamed, run_sync
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
class
|
|
33
|
+
class AgentConfigurationProtocol(Protocol):
|
|
34
34
|
"""Protocol describing the configuration attributes for AgentBase."""
|
|
35
35
|
|
|
36
36
|
@property
|
|
@@ -188,7 +188,7 @@ class AgentBase(DataclassJSONSerializable):
|
|
|
188
188
|
def __init__(
|
|
189
189
|
self,
|
|
190
190
|
*,
|
|
191
|
-
config:
|
|
191
|
+
config: AgentConfigurationProtocol,
|
|
192
192
|
run_context_wrapper: Optional[RunContextWrapper[Dict[str, Any]]] = None,
|
|
193
193
|
data_path: Path | str | None = None,
|
|
194
194
|
prompt_dir: Optional[Path] = None,
|
|
@@ -198,7 +198,7 @@ class AgentBase(DataclassJSONSerializable):
|
|
|
198
198
|
|
|
199
199
|
Parameters
|
|
200
200
|
----------
|
|
201
|
-
config :
|
|
201
|
+
config : AgentConfigurationProtocol
|
|
202
202
|
Configuration describing this agent.
|
|
203
203
|
run_context_wrapper : RunContextWrapper or None, default=None
|
|
204
204
|
Optional wrapper providing runtime context for prompt rendering.
|
|
@@ -428,7 +428,7 @@ class AgentBase(DataclassJSONSerializable):
|
|
|
428
428
|
"model": self.model,
|
|
429
429
|
}
|
|
430
430
|
if self._output_structure:
|
|
431
|
-
agent_config["
|
|
431
|
+
agent_config["output_type"] = self._output_structure
|
|
432
432
|
if self._tools:
|
|
433
433
|
agent_config["tools"] = self._tools
|
|
434
434
|
if self._model_settings:
|
|
@@ -575,6 +575,26 @@ class AgentBase(DataclassJSONSerializable):
|
|
|
575
575
|
)
|
|
576
576
|
return tool_obj
|
|
577
577
|
|
|
578
|
+
def as_response_tool(self) -> tuple[dict[str, Callable[..., Any]], dict[str, Any]]:
|
|
579
|
+
"""Return the agent as a callable response tool.
|
|
580
|
+
|
|
581
|
+
Returns
|
|
582
|
+
-------
|
|
583
|
+
Tool
|
|
584
|
+
Tool instance wrapping this agent for response generation.
|
|
585
|
+
"""
|
|
586
|
+
tool_handler = {self.name: self.run_sync}
|
|
587
|
+
tool_definition = {
|
|
588
|
+
"type": "function",
|
|
589
|
+
"name": self.name,
|
|
590
|
+
"description": self.description,
|
|
591
|
+
"strict": True,
|
|
592
|
+
"additionalProperties": False,
|
|
593
|
+
}
|
|
594
|
+
if self.output_structure:
|
|
595
|
+
tool_definition["parameters"] = self.output_structure.get_schema()
|
|
596
|
+
return tool_handler, tool_definition
|
|
597
|
+
|
|
578
598
|
def __enter__(self) -> AgentBase:
|
|
579
599
|
"""Enter the context manager for resource management.
|
|
580
600
|
|
|
@@ -651,4 +671,4 @@ class AgentBase(DataclassJSONSerializable):
|
|
|
651
671
|
log(f"Saved messages to {target}")
|
|
652
672
|
|
|
653
673
|
|
|
654
|
-
__all__ = ["
|
|
674
|
+
__all__ = ["AgentConfigurationProtocol", "AgentBase"]
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/config.py
RENAMED
|
@@ -10,20 +10,20 @@ from agents import Agent, Handoff, InputGuardrail, OutputGuardrail, Session
|
|
|
10
10
|
from agents.model_settings import ModelSettings
|
|
11
11
|
|
|
12
12
|
from ..utils.json.data_class import DataclassJSONSerializable
|
|
13
|
-
from ..utils.registry import
|
|
13
|
+
from ..utils.registry import RegistryBase
|
|
14
14
|
from ..utils.instructions import resolve_instructions_from_path
|
|
15
15
|
from ..structure.base import StructureBase
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
class
|
|
18
|
+
class AgentRegistry(RegistryBase["AgentConfiguration"]):
|
|
19
19
|
"""Registry for managing AgentConfiguration instances.
|
|
20
20
|
|
|
21
|
-
Inherits from
|
|
21
|
+
Inherits from RegistryBase to provide centralized storage and retrieval
|
|
22
22
|
of agent configurations, enabling reusable agent specs across the application.
|
|
23
23
|
|
|
24
24
|
Examples
|
|
25
25
|
--------
|
|
26
|
-
>>> registry =
|
|
26
|
+
>>> registry = AgentRegistry()
|
|
27
27
|
>>> config = AgentConfiguration(
|
|
28
28
|
... name="test_agent",
|
|
29
29
|
... model="gpt-4o-mini",
|
|
@@ -65,7 +65,7 @@ class AgentConfigurationRegistry(BaseRegistry["AgentConfiguration"]):
|
|
|
65
65
|
|
|
66
66
|
Examples
|
|
67
67
|
--------
|
|
68
|
-
>>> registry =
|
|
68
|
+
>>> registry = AgentRegistry()
|
|
69
69
|
>>> count = registry.load_from_directory("./agents")
|
|
70
70
|
>>> print(f"Loaded {count} configurations")
|
|
71
71
|
"""
|
|
@@ -74,12 +74,12 @@ class AgentConfigurationRegistry(BaseRegistry["AgentConfiguration"]):
|
|
|
74
74
|
return super().load_from_directory(path, config_class=config_class)
|
|
75
75
|
|
|
76
76
|
|
|
77
|
-
def get_default_registry() ->
|
|
77
|
+
def get_default_registry() -> AgentRegistry:
|
|
78
78
|
"""Return the global default registry instance.
|
|
79
79
|
|
|
80
80
|
Returns
|
|
81
81
|
-------
|
|
82
|
-
|
|
82
|
+
AgentRegistry
|
|
83
83
|
Singleton registry for application-wide configuration storage.
|
|
84
84
|
|
|
85
85
|
Examples
|
|
@@ -424,6 +424,6 @@ class AgentConfiguration(DataclassJSONSerializable):
|
|
|
424
424
|
|
|
425
425
|
|
|
426
426
|
# Global default registry instance
|
|
427
|
-
_default_registry =
|
|
427
|
+
_default_registry = AgentRegistry()
|
|
428
428
|
|
|
429
|
-
__all__ = ["AgentConfiguration", "
|
|
429
|
+
__all__ = ["AgentConfiguration", "AgentRegistry", "get_default_registry"]
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/response/config.py
RENAMED
|
@@ -10,17 +10,17 @@ from ..config import OpenAISettings
|
|
|
10
10
|
from ..structure.base import StructureBase
|
|
11
11
|
from ..response.base import ResponseBase, ToolHandler
|
|
12
12
|
from ..utils.json.data_class import DataclassJSONSerializable
|
|
13
|
-
from ..utils.registry import
|
|
13
|
+
from ..utils.registry import RegistryBase
|
|
14
14
|
from ..utils.instructions import resolve_instructions_from_path
|
|
15
15
|
|
|
16
16
|
TIn = TypeVar("TIn", bound="StructureBase")
|
|
17
17
|
TOut = TypeVar("TOut", bound="StructureBase")
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
class ResponseRegistry(
|
|
20
|
+
class ResponseRegistry(RegistryBase["ResponseConfiguration"]):
|
|
21
21
|
"""Registry for managing ResponseConfiguration instances.
|
|
22
22
|
|
|
23
|
-
Inherits from
|
|
23
|
+
Inherits from RegistryBase to provide centralized storage and retrieval
|
|
24
24
|
of response configurations, enabling reusable response specs across the application.
|
|
25
25
|
|
|
26
26
|
Examples
|
|
@@ -108,8 +108,6 @@ class ResponseConfiguration(DataclassJSONSerializable, Generic[TIn, TOut]):
|
|
|
108
108
|
-------
|
|
109
109
|
__post_init__()
|
|
110
110
|
Validate configuration invariants and enforce StructureBase subclassing.
|
|
111
|
-
instructions_text
|
|
112
|
-
Return the resolved instruction content as a string.
|
|
113
111
|
to_json()
|
|
114
112
|
Return a JSON-compatible dict representation (inherited from JSONSerializable).
|
|
115
113
|
to_json_file(filepath)
|
|
@@ -138,6 +136,7 @@ class ResponseConfiguration(DataclassJSONSerializable, Generic[TIn, TOut]):
|
|
|
138
136
|
output_structure: Optional[Type[TOut]]
|
|
139
137
|
system_vector_store: Optional[list[str]] = None
|
|
140
138
|
add_output_instructions: bool = True
|
|
139
|
+
add_web_search_tool: bool = False
|
|
141
140
|
|
|
142
141
|
def __post_init__(self) -> None:
|
|
143
142
|
"""
|
|
@@ -185,7 +184,7 @@ class ResponseConfiguration(DataclassJSONSerializable, Generic[TIn, TOut]):
|
|
|
185
184
|
raise TypeError("Configuration.tools must be a Sequence or None")
|
|
186
185
|
|
|
187
186
|
@property
|
|
188
|
-
def
|
|
187
|
+
def get_resolved_instructions(self) -> str:
|
|
189
188
|
"""Return the resolved instruction text.
|
|
190
189
|
|
|
191
190
|
Returns
|
|
@@ -204,6 +203,20 @@ class ResponseConfiguration(DataclassJSONSerializable, Generic[TIn, TOut]):
|
|
|
204
203
|
|
|
205
204
|
return resolved_instructions
|
|
206
205
|
|
|
206
|
+
@property
|
|
207
|
+
def get_resolved_tools(self) -> list:
|
|
208
|
+
"""Return the complete list of tools, including optional web search tool.
|
|
209
|
+
|
|
210
|
+
Returns
|
|
211
|
+
-------
|
|
212
|
+
list
|
|
213
|
+
List of tool definitions, including web search tool if enabled.
|
|
214
|
+
"""
|
|
215
|
+
tools = self.tools or []
|
|
216
|
+
if self.add_web_search_tool:
|
|
217
|
+
tools = tools + [{"type": "web_search"}]
|
|
218
|
+
return tools
|
|
219
|
+
|
|
207
220
|
def gen_response(
|
|
208
221
|
self,
|
|
209
222
|
*,
|
|
@@ -229,8 +242,8 @@ class ResponseConfiguration(DataclassJSONSerializable, Generic[TIn, TOut]):
|
|
|
229
242
|
"""
|
|
230
243
|
return ResponseBase[TOut](
|
|
231
244
|
name=self.name,
|
|
232
|
-
instructions=self.
|
|
233
|
-
tools=self.
|
|
245
|
+
instructions=self.get_resolved_instructions,
|
|
246
|
+
tools=self.get_resolved_tools,
|
|
234
247
|
output_structure=self.output_structure,
|
|
235
248
|
system_vector_store=self.system_vector_store,
|
|
236
249
|
data_path=data_path,
|
|
@@ -8,23 +8,23 @@ Classes
|
|
|
8
8
|
-------
|
|
9
9
|
StreamlitAppConfig
|
|
10
10
|
Validated configuration for Streamlit chat applications.
|
|
11
|
+
StreamlitAppRegistry
|
|
12
|
+
Registry for storing Streamlit app configurations.
|
|
11
13
|
|
|
12
14
|
Functions
|
|
13
15
|
---------
|
|
14
|
-
load_app_config
|
|
15
|
-
Load and validate configuration from a Python module.
|
|
16
16
|
_load_configuration
|
|
17
17
|
Load configuration with user-friendly error handling for Streamlit UI.
|
|
18
18
|
"""
|
|
19
19
|
|
|
20
20
|
from .config import (
|
|
21
21
|
StreamlitAppConfig,
|
|
22
|
+
StreamlitAppRegistry,
|
|
22
23
|
_load_configuration,
|
|
23
|
-
load_app_config,
|
|
24
24
|
)
|
|
25
25
|
|
|
26
26
|
__all__ = [
|
|
27
27
|
"StreamlitAppConfig",
|
|
28
|
+
"StreamlitAppRegistry",
|
|
28
29
|
"_load_configuration",
|
|
29
|
-
"load_app_config",
|
|
30
30
|
]
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/streamlit_app/config.py
RENAMED
|
@@ -15,7 +15,7 @@ from pydantic import ConfigDict, Field, field_validator, model_validator
|
|
|
15
15
|
|
|
16
16
|
from openai_sdk_helpers.response.base import ResponseBase
|
|
17
17
|
from openai_sdk_helpers.structure.base import StructureBase
|
|
18
|
-
from openai_sdk_helpers.utils import ensure_list
|
|
18
|
+
from openai_sdk_helpers.utils import RegistryBase, ensure_list
|
|
19
19
|
from ..utils.json import BaseModelJSONSerializable
|
|
20
20
|
|
|
21
21
|
|
|
@@ -29,6 +29,8 @@ class StreamlitAppConfig(BaseModelJSONSerializable):
|
|
|
29
29
|
|
|
30
30
|
Attributes
|
|
31
31
|
----------
|
|
32
|
+
name : str
|
|
33
|
+
Unique configuration identifier. Default is ``"streamlit_app"``.
|
|
32
34
|
response : ResponseBase, type[ResponseBase], Callable, or None
|
|
33
35
|
Response handler as an instance, class, or callable factory.
|
|
34
36
|
display_title : str
|
|
@@ -48,8 +50,6 @@ class StreamlitAppConfig(BaseModelJSONSerializable):
|
|
|
48
50
|
Return configured system vector stores as a list.
|
|
49
51
|
create_response()
|
|
50
52
|
Instantiate and return the configured ResponseBase.
|
|
51
|
-
load_app_config(config_path)
|
|
52
|
-
Load, validate, and return configuration from a Python module.
|
|
53
53
|
|
|
54
54
|
Examples
|
|
55
55
|
--------
|
|
@@ -63,6 +63,10 @@ class StreamlitAppConfig(BaseModelJSONSerializable):
|
|
|
63
63
|
|
|
64
64
|
model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)
|
|
65
65
|
|
|
66
|
+
name: str = Field(
|
|
67
|
+
default="streamlit_app",
|
|
68
|
+
description="Unique configuration identifier used for registry lookup.",
|
|
69
|
+
)
|
|
66
70
|
response: ResponseBase[StructureBase] | type[ResponseBase] | Callable | None = (
|
|
67
71
|
Field(
|
|
68
72
|
default=None,
|
|
@@ -225,6 +229,39 @@ class StreamlitAppConfig(BaseModelJSONSerializable):
|
|
|
225
229
|
"""
|
|
226
230
|
return _instantiate_response(self.response)
|
|
227
231
|
|
|
232
|
+
|
|
233
|
+
class StreamlitAppRegistry(RegistryBase[StreamlitAppConfig]):
|
|
234
|
+
"""Registry for managing StreamlitAppConfig instances.
|
|
235
|
+
|
|
236
|
+
Inherits from RegistryBase to provide centralized storage and retrieval
|
|
237
|
+
of Streamlit app configurations, enabling reuse across applications.
|
|
238
|
+
|
|
239
|
+
Methods
|
|
240
|
+
-------
|
|
241
|
+
register(config)
|
|
242
|
+
Add a configuration to the registry.
|
|
243
|
+
get(name)
|
|
244
|
+
Retrieve a configuration by name.
|
|
245
|
+
list_names()
|
|
246
|
+
Return all registered configuration names.
|
|
247
|
+
clear()
|
|
248
|
+
Remove all registered configurations.
|
|
249
|
+
save_to_directory(path)
|
|
250
|
+
Export all registered configurations to JSON files.
|
|
251
|
+
load_from_directory(path)
|
|
252
|
+
Load configurations from JSON files in a directory.
|
|
253
|
+
load_app_config(config_path)
|
|
254
|
+
Load, validate, and return configuration from a Python module.
|
|
255
|
+
|
|
256
|
+
Examples
|
|
257
|
+
--------
|
|
258
|
+
>>> registry = StreamlitAppRegistry()
|
|
259
|
+
>>> config = StreamlitAppConfig(response=MyResponse)
|
|
260
|
+
>>> registry.register(config)
|
|
261
|
+
>>> registry.get(config.name)
|
|
262
|
+
StreamlitAppConfig(...)
|
|
263
|
+
"""
|
|
264
|
+
|
|
228
265
|
@staticmethod
|
|
229
266
|
def load_app_config(
|
|
230
267
|
config_path: Path,
|
|
@@ -258,7 +295,7 @@ class StreamlitAppConfig(BaseModelJSONSerializable):
|
|
|
258
295
|
Examples
|
|
259
296
|
--------
|
|
260
297
|
>>> from pathlib import Path
|
|
261
|
-
>>> config =
|
|
298
|
+
>>> config = StreamlitAppRegistry.load_app_config(
|
|
262
299
|
... Path("./my_config.py")
|
|
263
300
|
... )
|
|
264
301
|
"""
|
|
@@ -433,36 +470,10 @@ def _config_from_mapping(raw_config: dict) -> StreamlitAppConfig:
|
|
|
433
470
|
return StreamlitAppConfig(**config_kwargs)
|
|
434
471
|
|
|
435
472
|
|
|
436
|
-
def load_app_config(
|
|
437
|
-
config_path: Path,
|
|
438
|
-
) -> StreamlitAppConfig:
|
|
439
|
-
"""Load and validate Streamlit configuration from a Python module.
|
|
440
|
-
|
|
441
|
-
Convenience function that proxies to StreamlitAppConfig.load_app_config
|
|
442
|
-
for backward compatibility.
|
|
443
|
-
|
|
444
|
-
Parameters
|
|
445
|
-
----------
|
|
446
|
-
config_path : Path
|
|
447
|
-
Filesystem path to the configuration module.
|
|
448
|
-
|
|
449
|
-
Returns
|
|
450
|
-
-------
|
|
451
|
-
StreamlitAppConfig
|
|
452
|
-
Validated configuration loaded from the module.
|
|
453
|
-
|
|
454
|
-
Examples
|
|
455
|
-
--------
|
|
456
|
-
>>> from pathlib import Path
|
|
457
|
-
>>> config = load_app_config(Path("./my_config.py"))
|
|
458
|
-
"""
|
|
459
|
-
return StreamlitAppConfig.load_app_config(config_path=config_path)
|
|
460
|
-
|
|
461
|
-
|
|
462
473
|
def _load_configuration(config_path: Path) -> StreamlitAppConfig:
|
|
463
474
|
"""Load configuration with user-friendly error handling for Streamlit.
|
|
464
475
|
|
|
465
|
-
Wraps
|
|
476
|
+
Wraps StreamlitAppRegistry.load_app_config with exception handling that
|
|
466
477
|
displays errors in the Streamlit UI and halts execution gracefully.
|
|
467
478
|
|
|
468
479
|
Parameters
|
|
@@ -487,7 +498,7 @@ def _load_configuration(config_path: Path) -> StreamlitAppConfig:
|
|
|
487
498
|
than raising exceptions that crash the app.
|
|
488
499
|
"""
|
|
489
500
|
try:
|
|
490
|
-
return
|
|
501
|
+
return StreamlitAppRegistry.load_app_config(config_path=config_path)
|
|
491
502
|
except Exception as exc: # pragma: no cover - surfaced in UI
|
|
492
503
|
import streamlit as st # type: ignore[import-not-found]
|
|
493
504
|
|
|
@@ -498,6 +509,6 @@ def _load_configuration(config_path: Path) -> StreamlitAppConfig:
|
|
|
498
509
|
|
|
499
510
|
__all__ = [
|
|
500
511
|
"StreamlitAppConfig",
|
|
501
|
-
"
|
|
512
|
+
"StreamlitAppRegistry",
|
|
502
513
|
"_load_configuration",
|
|
503
514
|
]
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/__init__.py
RENAMED
|
@@ -55,7 +55,7 @@ from .json import (
|
|
|
55
55
|
get_module_qualname,
|
|
56
56
|
to_jsonable,
|
|
57
57
|
)
|
|
58
|
-
from .registry import
|
|
58
|
+
from .registry import RegistryBase
|
|
59
59
|
|
|
60
60
|
from .path_utils import check_filepath, ensure_directory
|
|
61
61
|
from openai_sdk_helpers.logging_config import log
|
|
@@ -135,5 +135,5 @@ __all__ = [
|
|
|
135
135
|
"create_file_data_url",
|
|
136
136
|
"is_image_file",
|
|
137
137
|
# Registry
|
|
138
|
-
"
|
|
138
|
+
"RegistryBase",
|
|
139
139
|
]
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/registry.py
RENAMED
|
@@ -4,15 +4,42 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import warnings
|
|
6
6
|
from pathlib import Path
|
|
7
|
-
from typing import Generic, TypeVar
|
|
7
|
+
from typing import Generic, Protocol, TypeVar
|
|
8
|
+
from typing_extensions import Self
|
|
8
9
|
|
|
9
|
-
from ..utils.json.data_class import DataclassJSONSerializable
|
|
10
10
|
from .path_utils import ensure_directory
|
|
11
11
|
|
|
12
|
-
T = TypeVar("T", bound=DataclassJSONSerializable)
|
|
13
12
|
|
|
13
|
+
class RegistrySerializable(Protocol):
|
|
14
|
+
"""Protocol describing serializable registry entries.
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
Methods
|
|
17
|
+
-------
|
|
18
|
+
to_json_file(filepath)
|
|
19
|
+
Write the instance to a JSON file path.
|
|
20
|
+
from_json_file(filepath)
|
|
21
|
+
Load an instance from a JSON file path.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
@property
|
|
25
|
+
def name(self) -> str:
|
|
26
|
+
"""Return the configuration name."""
|
|
27
|
+
...
|
|
28
|
+
|
|
29
|
+
def to_json_file(self, filepath: Path | str) -> str:
|
|
30
|
+
"""Write serialized JSON data to a file path."""
|
|
31
|
+
...
|
|
32
|
+
|
|
33
|
+
@classmethod
|
|
34
|
+
def from_json_file(cls, filepath: Path | str) -> Self:
|
|
35
|
+
"""Load an instance from a JSON file."""
|
|
36
|
+
...
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
T = TypeVar("T", bound=RegistrySerializable)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class RegistryBase(Generic[T]):
|
|
16
43
|
"""Base registry for managing configuration instances.
|
|
17
44
|
|
|
18
45
|
Provides centralized storage and retrieval of configurations,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/coordination.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/prompt_utils.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/runner.py
RENAMED
|
File without changes
|
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/search/base.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/search/vector.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/search/web.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/summarizer.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/translator.py
RENAMED
|
File without changes
|
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/agent/validation.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/context_manager.py
RENAMED
|
File without changes
|
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/enums/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/logging_config.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/prompt/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/prompt/summarizer.jinja
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/prompt/translator.jinja
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/prompt/validator.jinja
RENAMED
|
File without changes
|
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/response/__init__.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/response/base.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/response/files.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/response/messages.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/response/runner.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/response/tool_call.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/streamlit_app/app.py
RENAMED
|
File without changes
|
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/base.py
RENAMED
|
File without changes
|
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/plan/enum.py
RENAMED
|
File without changes
|
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/plan/plan.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/plan/task.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/plan/types.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/prompt.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/responses.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/summary.py
RENAMED
|
File without changes
|
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/validation.py
RENAMED
|
File without changes
|
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/structure/web_search.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/async_utils.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/coercion.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/deprecation.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/encoding.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/instructions.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/json/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/json/ref.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/json/utils.py
RENAMED
|
File without changes
|
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/path_utils.py
RENAMED
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/utils/validation.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openai_sdk_helpers-0.4.0 → openai_sdk_helpers-0.4.1}/src/openai_sdk_helpers/vector_storage/types.py
RENAMED
|
File without changes
|