pytest-llm-assert 0.2.0__py3-none-any.whl → 0.2.2__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.
- pytest_llm_assert/core.py +23 -24
- {pytest_llm_assert-0.2.0.dist-info → pytest_llm_assert-0.2.2.dist-info}/METADATA +1 -1
- pytest_llm_assert-0.2.2.dist-info/RECORD +9 -0
- pytest_llm_assert-0.2.0.dist-info/RECORD +0 -9
- {pytest_llm_assert-0.2.0.dist-info → pytest_llm_assert-0.2.2.dist-info}/WHEEL +0 -0
- {pytest_llm_assert-0.2.0.dist-info → pytest_llm_assert-0.2.2.dist-info}/entry_points.txt +0 -0
- {pytest_llm_assert-0.2.0.dist-info → pytest_llm_assert-0.2.2.dist-info}/licenses/LICENSE +0 -0
pytest_llm_assert/core.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import functools
|
|
5
6
|
import json
|
|
6
7
|
import os
|
|
7
8
|
import re
|
|
@@ -19,6 +20,27 @@ if TYPE_CHECKING:
|
|
|
19
20
|
from typing import Any
|
|
20
21
|
|
|
21
22
|
|
|
23
|
+
@functools.cache
|
|
24
|
+
def _get_azure_ad_token_provider() -> Callable[[], str] | None:
|
|
25
|
+
"""Get Azure AD token provider for Entra ID authentication.
|
|
26
|
+
|
|
27
|
+
Uses LiteLLM's built-in helper which leverages DefaultAzureCredential.
|
|
28
|
+
Cached at module level to avoid recreating credentials on each call.
|
|
29
|
+
"""
|
|
30
|
+
try:
|
|
31
|
+
from litellm.secret_managers.get_azure_ad_token_provider import (
|
|
32
|
+
get_azure_ad_token_provider,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
return get_azure_ad_token_provider()
|
|
36
|
+
except ImportError:
|
|
37
|
+
# azure-identity not installed
|
|
38
|
+
return None
|
|
39
|
+
except Exception:
|
|
40
|
+
# Credential not available
|
|
41
|
+
return None
|
|
42
|
+
|
|
43
|
+
|
|
22
44
|
@dataclass(slots=True)
|
|
23
45
|
class LLMResponse:
|
|
24
46
|
"""Response details from the last LLM call.
|
|
@@ -93,7 +115,7 @@ class LLMAssert:
|
|
|
93
115
|
|
|
94
116
|
# Auto-configure Azure Entra ID when no API key is provided
|
|
95
117
|
if self._is_azure_model() and not self._has_azure_api_key():
|
|
96
|
-
self._azure_ad_token_provider =
|
|
118
|
+
self._azure_ad_token_provider = _get_azure_ad_token_provider()
|
|
97
119
|
|
|
98
120
|
def _is_azure_model(self) -> bool:
|
|
99
121
|
"""Check if the model is an Azure OpenAI model."""
|
|
@@ -103,29 +125,6 @@ class LLMAssert:
|
|
|
103
125
|
"""Check if an Azure API key is available."""
|
|
104
126
|
return bool(self.api_key or os.environ.get("AZURE_API_KEY"))
|
|
105
127
|
|
|
106
|
-
@staticmethod
|
|
107
|
-
def _get_azure_ad_token_provider() -> Callable[[], str] | None:
|
|
108
|
-
"""Get Azure AD token provider for Entra ID authentication.
|
|
109
|
-
|
|
110
|
-
Uses LiteLLM's built-in helper which leverages DefaultAzureCredential:
|
|
111
|
-
- Azure CLI credentials (az login)
|
|
112
|
-
- Managed Identity
|
|
113
|
-
- Environment variables (AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, ...)
|
|
114
|
-
- Visual Studio Code credentials
|
|
115
|
-
"""
|
|
116
|
-
try:
|
|
117
|
-
from litellm.secret_managers.get_azure_ad_token_provider import (
|
|
118
|
-
get_azure_ad_token_provider,
|
|
119
|
-
)
|
|
120
|
-
|
|
121
|
-
return get_azure_ad_token_provider()
|
|
122
|
-
except ImportError:
|
|
123
|
-
# azure-identity not installed
|
|
124
|
-
return None
|
|
125
|
-
except Exception:
|
|
126
|
-
# Credential not available
|
|
127
|
-
return None
|
|
128
|
-
|
|
129
128
|
@property
|
|
130
129
|
def system_prompt(self) -> str:
|
|
131
130
|
"""Get the system prompt used for LLM assertions."""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytest-llm-assert
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Simple LLM-powered assertions for any pytest test
|
|
5
5
|
Project-URL: Homepage, https://github.com/sbroenne/pytest-llm-assert
|
|
6
6
|
Project-URL: Documentation, https://github.com/sbroenne/pytest-llm-assert#readme
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
pytest_llm_assert/__init__.py,sha256=OcOVlsvqZBBxMzrQssLbaWVkc4qKSvdOMtLVibzDfFQ,233
|
|
2
|
+
pytest_llm_assert/core.py,sha256=0JOttHcZrJF2rA3xwG8BaCBIiEWvQCxFvT5HsYROygg,7983
|
|
3
|
+
pytest_llm_assert/plugin.py,sha256=g3sotHAeUXMuOsFQdaoIbn0CY24i-1CPv0EglrC5qtE,1327
|
|
4
|
+
pytest_llm_assert/prompts/system_prompt.md,sha256=RhSaYrpOjVcVwuG_af_Q50kHFhqXGOCKzubSYBXFzTA,181
|
|
5
|
+
pytest_llm_assert-0.2.2.dist-info/METADATA,sha256=PDLTGM1cYknujIreiKa06IuwprnBcrEb4FfNJdmi8oY,4723
|
|
6
|
+
pytest_llm_assert-0.2.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
7
|
+
pytest_llm_assert-0.2.2.dist-info/entry_points.txt,sha256=YEYg83TT6znVYdvFvZHJEOJ8XsZbcrqV9pY8uM-ThQE,49
|
|
8
|
+
pytest_llm_assert-0.2.2.dist-info/licenses/LICENSE,sha256=wHrdHpzRm4rdlyMdj-sQw7aou6kHPujW0VmRBEhInJ8,1072
|
|
9
|
+
pytest_llm_assert-0.2.2.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
pytest_llm_assert/__init__.py,sha256=OcOVlsvqZBBxMzrQssLbaWVkc4qKSvdOMtLVibzDfFQ,233
|
|
2
|
-
pytest_llm_assert/core.py,sha256=B3lah5pPZ3VMbtzZ3bBtdJ2o8r_mZb7_aw375_hBC2Q,8145
|
|
3
|
-
pytest_llm_assert/plugin.py,sha256=g3sotHAeUXMuOsFQdaoIbn0CY24i-1CPv0EglrC5qtE,1327
|
|
4
|
-
pytest_llm_assert/prompts/system_prompt.md,sha256=RhSaYrpOjVcVwuG_af_Q50kHFhqXGOCKzubSYBXFzTA,181
|
|
5
|
-
pytest_llm_assert-0.2.0.dist-info/METADATA,sha256=SdFu02CtgVAK14bwjP10clZgxFLQF8yEtiIm5Ct6BJE,4723
|
|
6
|
-
pytest_llm_assert-0.2.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
7
|
-
pytest_llm_assert-0.2.0.dist-info/entry_points.txt,sha256=YEYg83TT6znVYdvFvZHJEOJ8XsZbcrqV9pY8uM-ThQE,49
|
|
8
|
-
pytest_llm_assert-0.2.0.dist-info/licenses/LICENSE,sha256=wHrdHpzRm4rdlyMdj-sQw7aou6kHPujW0VmRBEhInJ8,1072
|
|
9
|
-
pytest_llm_assert-0.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|