Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Commit 032f52b

Browse files
committed
Fixing mypy issues and bumping version
1 parent 09b1d60 commit 032f52b

File tree

15 files changed

+188
-146
lines changed

15 files changed

+188
-146
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525
- Added base entity for CRUD testing
2626
- Added topic tests
2727

28+
## [0.1.3] - 2025-02-19
29+
30+
### Added
31+
- Added new test set capabilities
32+
- Added PromptSynthesizer for generating test sets from prompts
33+
- Added example usage for PromptSynthesizer
34+
2835
[0.1.0]: https://github.com/username/repository/releases/tag/v0.1.0
2936
[0.1.1]: https://github.com/username/repository/releases/tag/v0.1.1
3037
[0.1.2]: https://github.com/username/repository/releases/tag/v0.1.2
38+
[0.1.3]: https://github.com/username/repository/releases/tag/v0.1.3

poetry.lock

Lines changed: 18 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "rhesis-sdk"
3-
version = "0.1.2"
3+
version = "0.1.3"
44
description = "SDK for testing and validating LLM applications"
55
authors = ["Engineering Team <engineering@rhesis.ai>", "Harry Cruz <harry@rhesis.ai>", "Nicolai Bohn <nicolai@rhesis.ai>"]
66
license = "MIT"
@@ -62,6 +62,7 @@ requests = "^2.31.0"
6262
pyarrow = ">=17.0.0"
6363
tiktoken = "^0.9.0"
6464
tqdm = "^4.67.1"
65+
types-tqdm = "^4.67.0.20241221"
6566

6667
[build-system]
6768
requires = ["poetry-core>=1.0.0"]

requirements-dev.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ babel==2.16.0 ; python_version <= "3.11" and python_version >= "3.10" or python_
55
certifi==2024.12.14 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
66
cffi==1.17.1 ; python_version <= "3.11" and implementation_name == "pypy" and python_version >= "3.10" or python_version >= "3.12" and implementation_name == "pypy"
77
charset-normalizer==3.4.1 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
8-
colorama==0.4.6 ; python_version <= "3.11" and sys_platform == "win32" and python_version >= "3.10" or python_version >= "3.12" and sys_platform == "win32"
8+
colorama==0.4.6 ; python_version <= "3.11" and sys_platform == "win32" and python_version >= "3.10" or python_version <= "3.11" and platform_system == "Windows" and python_version >= "3.10" or python_version >= "3.12" and sys_platform == "win32" or python_version >= "3.12" and platform_system == "Windows"
99
comm==0.2.2 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
1010
debugpy==1.8.12 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
1111
decorator==5.1.1 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
@@ -44,6 +44,7 @@ python-dateutil==2.9.0.post0 ; python_version <= "3.11" and python_version >= "3
4444
python-dotenv==1.0.1 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
4545
pywin32==308 ; python_version <= "3.11" and sys_platform == "win32" and platform_python_implementation != "PyPy" and python_version >= "3.10" or python_version >= "3.12" and sys_platform == "win32" and platform_python_implementation != "PyPy"
4646
pyzmq==26.2.0 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
47+
regex==2024.11.6 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
4748
requests==2.32.3 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
4849
six==1.17.0 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
4950
snowballstemmer==2.2.0 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
@@ -58,11 +59,14 @@ sphinxcontrib-jsmath==1.0.1 ; python_version <= "3.11" and python_version >= "3.
5859
sphinxcontrib-qthelp==2.0.0 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
5960
sphinxcontrib-serializinghtml==2.0.0 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
6061
stack-data==0.6.3 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
62+
tiktoken==0.9.0 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
6163
tomli==2.2.1 ; python_version >= "3.10" and python_version < "3.11"
6264
tornado==6.4.2 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
65+
tqdm==4.67.1 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
6366
traitlets==5.14.3 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
6467
types-pytz==2024.2.0.20241221 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
6568
types-requests==2.32.0.20241016 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
69+
types-tqdm==4.67.0.20241221 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
6670
typing-extensions==4.12.2 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
6771
urllib3==2.3.0 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
6872
wcwidth==0.2.13 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"

requirements.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ asttokens==3.0.0 ; python_version <= "3.11" and python_version >= "3.10" or pyth
33
certifi==2024.12.14 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
44
cffi==1.17.1 ; python_version <= "3.11" and implementation_name == "pypy" and python_version >= "3.10" or python_version >= "3.12" and implementation_name == "pypy"
55
charset-normalizer==3.4.1 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
6-
colorama==0.4.6 ; python_version <= "3.11" and sys_platform == "win32" and python_version >= "3.10" or python_version >= "3.12" and sys_platform == "win32"
6+
colorama==0.4.6 ; python_version <= "3.11" and sys_platform == "win32" and python_version >= "3.10" or python_version <= "3.11" and platform_system == "Windows" and python_version >= "3.10" or python_version >= "3.12" and sys_platform == "win32" or python_version >= "3.12" and platform_system == "Windows"
77
comm==0.2.2 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
88
debugpy==1.8.12 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
99
decorator==5.1.1 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
@@ -32,10 +32,15 @@ python-dateutil==2.9.0.post0 ; python_version <= "3.11" and python_version >= "3
3232
python-dotenv==1.0.1 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
3333
pywin32==308 ; python_version <= "3.11" and sys_platform == "win32" and platform_python_implementation != "PyPy" and python_version >= "3.10" or python_version >= "3.12" and sys_platform == "win32" and platform_python_implementation != "PyPy"
3434
pyzmq==26.2.0 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
35+
regex==2024.11.6 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
3536
requests==2.32.3 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
3637
six==1.17.0 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
3738
stack-data==0.6.3 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
39+
tiktoken==0.9.0 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
3840
tornado==6.4.2 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
41+
tqdm==4.67.1 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
3942
traitlets==5.14.3 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
43+
types-requests==2.32.0.20241016 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
44+
types-tqdm==4.67.0.20241221 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
4045
urllib3==2.3.0 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"
4146
wcwidth==0.2.13 ; python_version <= "3.11" and python_version >= "3.10" or python_version >= "3.12"

src/rhesis/entities/base_entity.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import functools
22
import requests
3-
from typing import Optional, Dict, Any, Callable, TypeVar, cast, Type
3+
from typing import Optional, Dict, Any, Callable, TypeVar, cast
44
from rhesis.client import Client
55
from datetime import datetime
66
import logging
@@ -12,19 +12,28 @@
1212

1313
def handle_http_errors(func: Callable[..., T]) -> Callable[..., Optional[T]]:
1414
"""Decorator to handle HTTP errors in API requests."""
15+
1516
@functools.wraps(func)
16-
def wrapper(self_or_cls, *args: Any, **kwargs: Any) -> Optional[T]:
17+
def wrapper(self_or_cls: Any, *args: Any, **kwargs: Any) -> Optional[T]:
1718
try:
1819
return func(self_or_cls, *args, **kwargs)
1920
except requests.exceptions.HTTPError as e:
2021
logger.error(f"HTTP error occurred: {e}")
21-
logger.error(f"Response content: {e.response.content.decode()}")
22+
# Handle potential string or bytes content
23+
content = e.response.content
24+
if isinstance(content, bytes):
25+
content = content.decode()
26+
logger.error(f"Response content: {content}")
2227
logger.error(f"Request URL: {e.response.request.url}")
2328
logger.error(f"Request method: {e.response.request.method}")
2429
logger.error(f"Request headers: {e.response.request.headers}")
2530
if e.response.request.body:
26-
logger.error(f"Request body: {e.response.request.body.decode()}")
31+
body = e.response.request.body
32+
if isinstance(body, bytes):
33+
body = body.decode()
34+
logger.error(f"Request body: {body}")
2735
return None
36+
2837
return wrapper
2938

3039

@@ -59,35 +68,29 @@ def __init__(self, **fields: Any) -> None:
5968
def save(self) -> Optional[Dict[str, Any]]:
6069
"""Save the entity to the database."""
6170
try:
62-
# Use all fields except 'id' for the request body
63-
data = {k: v for k, v in self.fields.items() if k != 'id'}
64-
71+
data = {k: v for k, v in self.fields.items() if k != "id"}
72+
6573
if "id" in self.fields:
66-
# Update existing entity
6774
url = f"{self.client.get_url(self.endpoint)}/{self.fields['id']}/"
6875
try:
6976
response = requests.put(
7077
url,
7178
json=data,
7279
headers=self.headers,
7380
)
74-
if response.status_code == 200:
75-
return response.json()
7681
response.raise_for_status()
82+
return dict(response.json())
7783
except requests.exceptions.RequestException:
7884
raise
7985
else:
80-
# Create new entity
8186
url = f"{self.client.get_url(self.endpoint)}/"
8287
response = requests.post(
8388
url,
8489
json=data,
8590
headers=self.headers,
8691
)
87-
if response.status_code == 200:
88-
return response.json()
8992
response.raise_for_status()
90-
return None
93+
return dict(response.json())
9194
except requests.exceptions.HTTPError:
9295
return None
9396

@@ -150,7 +153,7 @@ def all(cls, **kwargs: Any) -> Optional[list[Any]]:
150153
"Content-Type": "application/json",
151154
}
152155
url = f"{client.get_url(cls.endpoint)}/"
153-
156+
154157
try:
155158
response = requests.get(
156159
url,
@@ -165,7 +168,7 @@ def all(cls, **kwargs: Any) -> Optional[list[Any]]:
165168
response.raise_for_status()
166169
except requests.exceptions.RequestException:
167170
raise
168-
171+
169172
return None
170173

171174
@handle_http_errors
@@ -206,10 +209,10 @@ def get_by_id(cls, id: str) -> Dict[str, Any]:
206209
entity_dict = cls.fields.get(id)
207210
if entity_dict is None:
208211
raise ValueError(
209-
f"Cannot get {cls.__name__}: "
212+
f"Cannot get {cls.__class__.__name__}: "
210213
f"entity with id {id} does not exist in database"
211214
)
212-
return cast(Dict[str, Any], entity_dict)
215+
return dict(entity_dict)
213216

214217
def _validate_update(self) -> None:
215218
"""Validate entity before update."""

0 commit comments

Comments
 (0)