Skip to content

Commit

Permalink
Merge branch 'development' into feat/supported-forms-and-confguration
Browse files Browse the repository at this point in the history
  • Loading branch information
adubovik authored Jan 9, 2025
2 parents a4bb814 + 138d419 commit 3ccc50c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions aidial_sdk/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def __init__(
display_message: Optional[str] = None,
headers: Optional[Dict[str, str]] = None,
) -> None:
super().__init__(message)
status_code = int(status_code)

self.message = message
Expand Down
31 changes: 31 additions & 0 deletions tests/test_exception.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from typing import List, Tuple

import pytest

from aidial_sdk.exceptions import HTTPException, TruncatePromptSystemError

test_cases: List[Tuple[HTTPException, str]] = [
(
HTTPException(
message="message",
status_code=400,
type="type",
param="param",
code="code",
display_message="display_message",
headers={"header": "value"},
),
"message",
),
(
TruncatePromptSystemError(1, 20),
"The requested maximum prompt tokens is 1. "
"However, the system messages resulted in 20 tokens. "
"Please reduce the length of the system messages or increase the maximum prompt tokens.",
),
]


@pytest.mark.parametrize("exc, expected", test_cases)
def test_str_exception(exc: HTTPException, expected: str):
assert str(exc) == expected

0 comments on commit 3ccc50c

Please sign in to comment.