File tree Expand file tree Collapse file tree 3 files changed +9
-8
lines changed Expand file tree Collapse file tree 3 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -644,7 +644,7 @@ def __new__(
644644 prompt_arg : Any | None = agent_kwargs .get ("prompt" )
645645 resolved_instructions = _resolve_agent_instructions (instructions , prompt_arg )
646646
647- if resolved_instructions is None and prompt_arg is None :
647+ if resolved_instructions is None :
648648 raise ValueError (
649649 "GuardrailAgent requires either 'instructions' or 'prompt' to initialize the underlying Agent."
650650 )
Original file line number Diff line number Diff line change 1212import types
1313from collections .abc import Iterator
1414from dataclasses import dataclass
15+ from pathlib import Path
1516from types import SimpleNamespace
1617from typing import Any
1718
@@ -55,6 +56,11 @@ class _DummyResponse:
5556 delta : str | None = None
5657
5758
59+ _GUARDRAILS_PACKAGE_STUB = types .ModuleType ("guardrails" )
60+ _GUARDRAILS_PACKAGE_STUB .__path__ = [str (Path (__file__ ).resolve ().parents [1 ] / "src" / "guardrails" )]
61+ sys .modules .setdefault ("guardrails" , _GUARDRAILS_PACKAGE_STUB )
62+
63+
5864_STUB_OPENAI_MODULE = types .ModuleType ("openai" )
5965_STUB_OPENAI_MODULE .AsyncOpenAI = _StubAsyncOpenAI
6066_STUB_OPENAI_MODULE .OpenAI = _StubSyncOpenAI
Original file line number Diff line number Diff line change 66import types
77from collections .abc import Callable
88from dataclasses import dataclass
9- from pathlib import Path
109from types import SimpleNamespace
1110from typing import Any
1211
1312import pytest
1413
15- guardrails_pkg = types .ModuleType ("guardrails" )
16- guardrails_pkg .__path__ = [str (Path (__file__ ).resolve ().parents [2 ] / "src" / "guardrails" )]
17- sys .modules .setdefault ("guardrails" , guardrails_pkg )
18-
19- from guardrails ._openai_utils import SAFETY_IDENTIFIER_HEADER , SAFETY_IDENTIFIER_VALUE # noqa: E402
20- from guardrails .types import GuardrailResult # noqa: E402
14+ from guardrails ._openai_utils import SAFETY_IDENTIFIER_HEADER , SAFETY_IDENTIFIER_VALUE
15+ from guardrails .types import GuardrailResult
2116
2217# ---------------------------------------------------------------------------
2318# Stub agents SDK module so guardrails.agents can import required symbols.
You can’t perform that action at this time.
0 commit comments