"docs/vscode:/vscode.git/clone" did not exist on "31e3488a5199b62880542919498bb24b72a7b901"
test_inference_api.py 879 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import pytest

from text_generation import (
    InferenceAPIClient,
    InferenceAPIAsyncClient,
    Client,
    AsyncClient,
)
from text_generation.errors import NotSupportedError
from text_generation.inference_api import get_supported_models


def test_get_supported_models():
    assert isinstance(get_supported_models(), list)


17
18
def test_client(flan_t5_xxl):
    client = InferenceAPIClient(flan_t5_xxl)
19
20
21
22
23
24
25
26
    assert isinstance(client, Client)


def test_client_unsupported_model(unsupported_model):
    with pytest.raises(NotSupportedError):
        InferenceAPIClient(unsupported_model)


27
28
def test_async_client(flan_t5_xxl):
    client = InferenceAPIAsyncClient(flan_t5_xxl)
29
30
31
32
33
34
    assert isinstance(client, AsyncClient)


def test_async_client_unsupported_model(unsupported_model):
    with pytest.raises(NotSupportedError):
        InferenceAPIAsyncClient(unsupported_model)