-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve error handling for builtin assistants (#350)
- Loading branch information
Showing
12 changed files
with
76 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
from ragna import assistants | ||
from ragna._compat import anext | ||
from ragna.assistants._api import ApiAssistant | ||
from ragna.core import RagnaException | ||
from tests.utils import skip_on_windows | ||
|
||
API_ASSISTANTS = [ | ||
assistant | ||
for assistant in assistants.__dict__.values() | ||
if isinstance(assistant, type) | ||
and issubclass(assistant, ApiAssistant) | ||
and assistant is not ApiAssistant | ||
] | ||
|
||
|
||
@skip_on_windows | ||
@pytest.mark.parametrize("assistant", API_ASSISTANTS) | ||
async def test_api_call_error_smoke(mocker, assistant): | ||
mocker.patch.dict(os.environ, {assistant._API_KEY_ENV_VAR: "SENTINEL"}) | ||
|
||
chunks = assistant().answer(prompt="?", sources=[]) | ||
|
||
with pytest.raises(RagnaException, match="API call failed"): | ||
await anext(chunks) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import platform | ||
|
||
import pytest | ||
|
||
skip_on_windows = pytest.mark.skipif( | ||
platform.system() == "Windows", reason="Test is broken skipped on Windows" | ||
) |