|
20 | 20 |
|
21 | 21 | from .mocks import MockAsyncOpenAILlm, MockOpenAILlm |
22 | 22 |
|
23 | | -# def test_openai_callable_retries_on_retryable_errors(mocker): |
24 | | -# llm = MockCustomLlm() |
25 | | -# fail_retryable_spy = mocker.spy(llm, "fail_retryable") |
26 | | -# |
27 | | -# arbitrary_callable = ArbitraryCallable(llm.fail_retryable, prompt="Hello") |
28 | | -# response = arbitrary_callable() |
29 | | -# |
30 | | -# assert fail_retryable_spy.call_count == 2 |
31 | | -# assert isinstance(response, LLMResponse) is True |
32 | | -# assert response.output == "Hello world!" |
33 | | -# assert response.prompt_token_count is None |
34 | | -# assert response.response_token_count is None |
35 | | - |
36 | 23 |
|
37 | 24 | @pytest.mark.skipif(not OPENAI_VERSION.startswith("0"), reason="OpenAI v0 only") |
38 | 25 | def test_openai_callable_does_not_retry_on_non_retryable_errors(mocker): |
@@ -65,22 +52,6 @@ def test_openai_callable_does_not_retry_on_success(mocker): |
65 | 52 | assert response.response_token_count is None |
66 | 53 |
|
67 | 54 |
|
68 | | -# @pytest.mark.asyncio |
69 | | -# async def test_async_openai_callable_retries_on_retryable_errors(mocker): |
70 | | -# llm = MockAsyncCustomLlm() |
71 | | -# fail_retryable_spy = mocker.spy(llm, "fail_retryable") |
72 | | -# |
73 | | -# arbitrary_callable = AsyncArbitraryCallable(llm.fail_retryable, prompt="Hello") |
74 | | -# response = await arbitrary_callable() |
75 | | -# |
76 | | -# assert fail_retryable_spy.call_count == 2 |
77 | | -# assert isinstance(response, LLMResponse) is True |
78 | | -# assert response.output == "Hello world!" |
79 | | -# assert response.prompt_token_count is None |
80 | | -# assert response.response_token_count is None |
81 | | - |
82 | | - |
83 | | -# Passing |
84 | 55 | @pytest.mark.skipif(not OPENAI_VERSION.startswith("0"), reason="OpenAI v0 only") |
85 | 56 | @pytest.mark.asyncio |
86 | 57 | async def test_async_openai_callable_does_not_retry_on_non_retryable_errors(mocker): |
@@ -664,19 +635,19 @@ def test_get_llm_ask_cohere(): |
664 | 635 |
|
665 | 636 |
|
666 | 637 | @pytest.mark.skipif( |
667 | | - not importlib.util.find_spec("anthropic.resources"), |
668 | | - reason="antrhopic is not installed", |
| 638 | + not importlib.util.find_spec("anthropic"), |
| 639 | + reason="anthropic is not installed", |
669 | 640 | ) |
670 | 641 | def test_get_llm_ask_anthropic(): |
671 | | - from anthropic import Anthropic |
672 | | - |
673 | | - from guardrails.llm_providers import AnthropicCallable |
| 642 | + if importlib.util.find_spec("anthropic"): |
| 643 | + from anthropic import Anthropic |
674 | 644 |
|
675 | | - anthropic_client = Anthropic(api_key="my_api_key") |
| 645 | + from guardrails.llm_providers import AnthropicCallable |
676 | 646 |
|
677 | | - prompt_callable = get_llm_ask(anthropic_client.completions.create) |
| 647 | + anthropic_client = Anthropic(api_key="my_api_key") |
| 648 | + prompt_callable = get_llm_ask(anthropic_client.completions.create) |
678 | 649 |
|
679 | | - assert isinstance(prompt_callable, AnthropicCallable) |
| 650 | + assert isinstance(prompt_callable, AnthropicCallable) |
680 | 651 |
|
681 | 652 |
|
682 | 653 | @pytest.mark.skipif( |
|
0 commit comments