diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index d77def2d..b79aa956 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -31,8 +31,25 @@ jobs: - name: Lint formatting run: uv run black --check . + - name: Write secrets for expensive tests + env: + MODELLAB_FILE_DOWNLOAD_TOKEN: ${{ secrets.MODELLAB_FILE_DOWNLOAD_TOKEN }} + run: | + if [ -z "$MODELLAB_FILE_DOWNLOAD_TOKEN" ]; then + echo "MODELLAB_FILE_DOWNLOAD_TOKEN is not set on the Scheduled Testing environment." + exit 1 + fi + mkdir -p config + cat > config/secrets.toml << EOF + [modellab_files] + token = "${MODELLAB_FILE_DOWNLOAD_TOKEN}" + + [demo] + api_key = "12345" + EOF + - name: Test with pytest - run: uv run pytest + run: uv run pytest --expensive-tests - name: Run mypy run: uv run mypy --follow-imports silent --exclude modelbench src/modelgauge diff --git a/src/modelgauge/suts/anthropic_api.py b/src/modelgauge/suts/anthropic_api.py index 77403a3e..7ca5dd0e 100644 --- a/src/modelgauge/suts/anthropic_api.py +++ b/src/modelgauge/suts/anthropic_api.py @@ -12,12 +12,11 @@ from modelgauge.general import APIException from modelgauge.prompt import ChatRole, TextPrompt -from modelgauge.secret_values import InjectSecret, RequiredSecret, SecretDescription +from modelgauge.secret_values import RequiredSecret, SecretDescription from modelgauge.sut import REFUSAL_RESPONSE, PromptResponseSUT, SUTResponse from modelgauge.model_options import ModelOptions from modelgauge.sut_capabilities import AcceptsTextPrompt from modelgauge.sut_decorator import modelgauge_sut -from modelgauge.sut_registry import SUTS from modelgauge.suts.openai_client import OpenAIChatMessage, _ROLE_MAP logger = get_logger(__name__) @@ -122,10 +121,3 @@ def translate_response(self, request: AnthropicRequest, response: AnthropicMessa return SUTResponse(text=REFUSAL_RESPONSE) assert len(text_blocks) == 1, f"Expected a single text block in the response, got {len(text_blocks)}." return SUTResponse(text=text_blocks[0].text) - - -ANTHROPIC_SECRET = InjectSecret(AnthropicApiKey) - -for model in ["claude-3-5-sonnet-20241022", "claude-3-5-haiku-20241022", "claude-3-7-sonnet-20250219"]: - # UID is the model name. - SUTS.register(AnthropicSUT, model, model, ANTHROPIC_SECRET) diff --git a/src/modelgauge/suts/huggingface_api.py b/src/modelgauge/suts/huggingface_api.py index e35c6cfa..8690dafd 100644 --- a/src/modelgauge/suts/huggingface_api.py +++ b/src/modelgauge/suts/huggingface_api.py @@ -4,12 +4,10 @@ import tenacity from modelgauge.auth.huggingface_inference_token import HuggingFaceInferenceToken from modelgauge.prompt import TextPrompt -from modelgauge.secret_values import InjectSecret from modelgauge.sut import PromptResponseSUT, SUTResponse from modelgauge.model_options import ModelOptions from modelgauge.sut_capabilities import AcceptsTextPrompt from modelgauge.sut_decorator import modelgauge_sut -from modelgauge.sut_registry import SUTS from pydantic import BaseModel from tenacity import stop_after_attempt, wait_random_exponential @@ -63,20 +61,3 @@ def evaluate(self, request: HuggingFaceChatRequest) -> HuggingFaceResponse: def translate_response(self, request: HuggingFaceChatRequest, response: HuggingFaceResponse) -> SUTResponse: return SUTResponse(text=response.generated_text) - - -HF_SECRET = InjectSecret(HuggingFaceInferenceToken) - -SUTS.register( - HuggingFaceSUT, - "olmo-7b-0724-instruct-hf", - "https://flakwttqzmq493dw.us-east-1.aws.endpoints.huggingface.cloud", - HF_SECRET, -) - -SUTS.register( - HuggingFaceSUT, - "olmo-2-1124-7b-instruct-hf", - "https://l2m28ramsifovtf6.us-east-1.aws.endpoints.huggingface.cloud", - HF_SECRET, -) diff --git a/src/modelgauge/suts/huggingface_chat_completion.py b/src/modelgauge/suts/huggingface_chat_completion.py index 1578d8ac..8c04fc7b 100644 --- a/src/modelgauge/suts/huggingface_chat_completion.py +++ b/src/modelgauge/suts/huggingface_chat_completion.py @@ -255,43 +255,6 @@ class HuggingFaceChatCompletionServerlessThinkingSUT(ThinkingMixin, HuggingFaceC HF_SECRET = InjectSecret(HuggingFaceInferenceToken) -SUTS.register( - HuggingFaceChatCompletionDedicatedSUT, - "nvidia-llama-3-1-nemotron-nano-8b-v1", - "llama-3-1-nemotron-nano-8b-v-uhu", - None, - HF_SECRET, -) - -DEDICATED_SUTS_AND_SERVERS = { - "athene-v2-chat": "ijf", - "aya-expanse-8b": "rfn", - "gemma-2-9b-it": "plf", - "gemma-2-9b-it-simpo": "zop", - "gemma-3-12b-it": "mxk", - "granite-3-1-8b-instruct": "twe", - "llama-3-1-tulu-3-8b": "bzk", # check - "llama-3-1-tulu-3-70b": "ome", - "mistral-nemo-instruct-2407": "mgt", - "mixtral-8x22b-instruct-v0-1": "kog", - "olmo-2-1124-13b-instruct": "ibo", - "olmo-2-0325-32b-instruct": "yft", - "qwen1-5-110b-chat": "gek", - "qwen2-5-7b-instruct": "hgy", - "qwq-32b": "usw", - "yi-1-5-34b-chat": "nlm", # check -} - -for sut, endpoint in DEDICATED_SUTS_AND_SERVERS.items(): - SUTS.register( - HuggingFaceChatCompletionDedicatedSUT, - sut + "-hf", - sut + "-" + endpoint, - None, - HF_SECRET, - ) - - # Dedicated SUTs that require a model name to be specified in the requests. DEDICATED_SUTS_AND_SERVERS_AND_MODELS = { "llama-3-3-70b-instruct": ("iqc", "meta-llama/Llama-3.3-70B-Instruct"), @@ -331,27 +294,3 @@ class HuggingFaceChatCompletionServerlessThinkingSUT(ThinkingMixin, HuggingFaceC "together", HF_SECRET, ) -# Register serverless SUTs. -SUTS.register( - HuggingFaceChatCompletionServerlessSUT, - "cohere-c4ai-command-a-03-2025-hf", - "CohereLabs/c4ai-command-a-03-2025", - "cohere", - HF_SECRET, -) - -SUTS.register( - HuggingFaceChatCompletionServerlessSUT, - "meta-llama-3_1-8b-instruct-hf-nebius", - "meta-llama/Llama-3.1-8B-Instruct", - "nebius", - HF_SECRET, -) - -SUTS.register( - HuggingFaceChatCompletionServerlessSUT, - "google-gemma-3-27b-it-hf-nebius", - "google/gemma-3-27b-it", - "nebius", - HF_SECRET, -) diff --git a/src/modelgauge/suts/meta_llama_client.py b/src/modelgauge/suts/meta_llama_client.py index 16a4b78d..fd6c48d3 100644 --- a/src/modelgauge/suts/meta_llama_client.py +++ b/src/modelgauge/suts/meta_llama_client.py @@ -1,18 +1,16 @@ from typing import List, Optional -import requests # type: ignore from httpx import Timeout from llama_api_client import LlamaAPIClient from llama_api_client.types import CreateChatCompletionResponse, MessageTextContentItem, ModerationCreateResponse from modelgauge.prompt import TextPrompt from modelgauge.retry_decorator import retry -from modelgauge.secret_values import InjectSecret, RequiredSecret, SecretDescription +from modelgauge.secret_values import RequiredSecret, SecretDescription from modelgauge.sut import PromptResponseSUT, REFUSAL_RESPONSE, SUTResponse from modelgauge.model_options import ModelOptions from modelgauge.sut_capabilities import AcceptsTextPrompt from modelgauge.sut_decorator import modelgauge_sut -from modelgauge.sut_registry import SUTS from pydantic import BaseModel from requests.adapters import HTTPAdapter, Retry # type: ignore @@ -111,16 +109,3 @@ def translate_response(self, request: MetaLlamaChatRequest, response: MetaLlamaM text = response.sut_response.completion_message.content.text assert text is not None return SUTResponse(text=text) - - -# Unauthorized models: ["Llama-4-Scout-17B-16E-Instruct-FP8", "Llama-4-Maverick-17B-128E-Instruct-FP8"] -CHAT_MODELS = ["Llama-3.3-8B-Instruct"] - -for model_name in CHAT_MODELS: - SUTS.register(MetaLlamaSUT, "meta-" + model_name.lower() + "-llama", model_name, InjectSecret(MetaLlamaApiKey)) - SUTS.register( - MetaLlamaModeratedSUT, - "meta-" + model_name.lower() + "-moderated-llama", - model_name, - InjectSecret(MetaLlamaApiKey), - ) diff --git a/src/modelgauge/suts/openai_client.py b/src/modelgauge/suts/openai_client.py index 7f4d943a..20fd3366 100644 --- a/src/modelgauge/suts/openai_client.py +++ b/src/modelgauge/suts/openai_client.py @@ -319,14 +319,6 @@ def translate_response(self, request: OpenAIResponsesRequest, response: Response return SUTResponse(text=response.output_text, top_logprobs=top_logprobs) -SUTS.register( - OpenAIChatSUT, - "gpt-3.5-turbo", - "gpt-3.5-turbo", - InjectSecret(OpenAIApiKey), - InjectSecret(OpenAIOrganization), -) - SUTS.register( OpenAIChatSUT, "gpt-4o", @@ -334,19 +326,3 @@ def translate_response(self, request: OpenAIResponsesRequest, response: Response InjectSecret(OpenAIApiKey), InjectSecret(OpenAIOrganization), ) - -SUTS.register( - OpenAIChatSUT, - "gpt-4o-20250508", - "gpt-4o", - InjectSecret(OpenAIApiKey), - InjectSecret(OpenAIOrganization), -) - -SUTS.register( - OpenAIChatSUT, - "gpt-4o-mini", - "gpt-4o-mini", - InjectSecret(OpenAIApiKey), - InjectSecret(OpenAIOrganization), -) diff --git a/src/modelgauge/suts/together_client.py b/src/modelgauge/suts/together_client.py index 3ccffd18..05d5adfe 100644 --- a/src/modelgauge/suts/together_client.py +++ b/src/modelgauge/suts/together_client.py @@ -389,40 +389,4 @@ def evaluate(self, request: TogetherChatRequest) -> TogetherChatResponse: raise e -LANGUAGE_MODELS: dict[str, str] = { - # This was deprecated around 2024-08-29 - # You may add some once they are available. - # Leaving this empty dict in the code as an example to get you started. - # "llama-2-7b": "meta-llama/Llama-2-7b-hf", -} -for uid, model_name in LANGUAGE_MODELS.items(): - SUTS.register(TogetherCompletionsSUT, uid, model_name, InjectSecret(TogetherApiKey)) - -# Chat -CHAT_MODELS = { - "llama-3.1-8b-instruct-turbo-together": "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo", - "llama-3.1-405b-instruct-turbo-together": "meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo", - "llama-3.3-70b-instruct-turbo-together": "meta-llama/Llama-3.3-70B-Instruct-Turbo-Free", - "Mistral-7B-Instruct-v0.2": "mistralai/Mistral-7B-Instruct-v0.2", - "Mixtral-8x7B-Instruct-v0.1": "mistralai/Mixtral-8x7B-Instruct-v0.1", - "mistral-8x22b-instruct": "mistralai/Mixtral-8x22B-Instruct-v0.1", - "mistral-8x22b-instruct-nim": "mlc_ai_safety_2/nim/mistralai/mixtral-8x22b-instruct-v01-c5e6181e", - "deepseek-R1": "deepseek-ai/DeepSeek-R1", - "deepseek-v3-together": "deepseek-ai/DeepSeek-V3", - # No longer supported as of 2025-04-25 - # "llama-2-13b-chat": "meta-llama/Llama-2-13b-chat-hf", - # N/A serverless on together as of 2025-03-24 - # "deepseek-llm-67b-chat": "deepseek-ai/deepseek-llm-67b-chat", - "qwen2.5-7B-instruct-turbo-together": "Qwen/Qwen2.5-7B-Instruct-Turbo", - # "StripedHyena-Nous-7B": "togethercomputer/StripedHyena-Nous-7B", -} -for uid, model_name in CHAT_MODELS.items(): - SUTS.register(TogetherChatSUT, uid, model_name, InjectSecret(TogetherApiKey)) - -DEDICATED_CHAT_MODELS = {} -for uid, model_name in DEDICATED_CHAT_MODELS.items(): - SUTS.register( - TogetherDedicatedChatSUT, uid, model_name, InjectSecret(TogetherApiKey), InjectSecret(TogetherProjectId) - ) - SUTS.register(TogetherThinkingSUT, "deepseek-R1-thinking", "deepseek-ai/DeepSeek-R1", InjectSecret(TogetherApiKey)) diff --git a/tests/modelbench_tests/test_run.py b/tests/modelbench_tests/test_run.py index b162f3dc..d0c10501 100644 --- a/tests/modelbench_tests/test_run.py +++ b/tests/modelbench_tests/test_run.py @@ -601,7 +601,6 @@ def test_invalid_benchmark_versions_can_not_be_called(self, version, runner): assert result.exit_code == 2 assert "Invalid value for '--version'" in result.output - @pytest.mark.skip(reason="we have temporarily removed other languages") def test_calls_score_benchmark_with_correct_v1_locale(self, runner, mock_run_benchmarks, sut_uid): _ = runner(cli, ["benchmark", "general", "--locale", FR_FR, "--sut", sut_uid]) diff --git a/tests/modelgauge_tests/sut_tests/test_anthropic_sut_factory.py b/tests/modelgauge_tests/sut_tests/test_anthropic_sut_factory.py index 684bb3bd..7f87e79a 100644 --- a/tests/modelgauge_tests/sut_tests/test_anthropic_sut_factory.py +++ b/tests/modelgauge_tests/sut_tests/test_anthropic_sut_factory.py @@ -4,12 +4,10 @@ import pytest -from modelgauge.config import load_secrets_from_config from modelgauge.dynamic_sut_factory import ModelNotSupportedError from modelgauge.sut_definition import SUTDefinition from modelgauge.suts.anthropic_api import AnthropicSUT from modelgauge.suts.anthropic_sut_factory import AnthropicSUTFactory -from modelgauge_tests.utilities import expensive_tests class FakeModel(dict): @@ -73,11 +71,3 @@ def test_autocorrect_is_limited(factory): def test_list_suts(factory): suts = factory.list_suts() assert "anthropic/claude-sonnet-4-5-20250929:anthropic" in [s.uid for s in suts] - - -@expensive_tests -def test_connection(): - factory = AnthropicSUTFactory(load_secrets_from_config(path=".")) - sut_definition = SUTDefinition(model="claude-sonnet-4-5-20250929", driver="anthropic") - sut = factory.make_sut(sut_definition) - assert sut.uid == "claude-sonnet-4-5-20250929:anthropic" diff --git a/tests/modelgauge_tests/sut_tests/test_google_sut_factory.py b/tests/modelgauge_tests/sut_tests/test_google_sut_factory.py index 5f7d3408..871803f0 100644 --- a/tests/modelgauge_tests/sut_tests/test_google_sut_factory.py +++ b/tests/modelgauge_tests/sut_tests/test_google_sut_factory.py @@ -4,12 +4,11 @@ import pytest -from modelgauge.config import load_secrets_from_config from modelgauge.dynamic_sut_factory import ModelNotSupportedError from modelgauge.sut_definition import SUTDefinition from modelgauge.suts.google_genai import GoogleGenAiSUT from modelgauge.suts.google_sut_factory import GoogleSUTFactory -from modelgauge_tests.utilities import expensive_tests, FakeObject +from modelgauge_tests.utilities import FakeObject class FakeModelsResponse(list): @@ -93,11 +92,3 @@ def test_list_suts_excludes_interactions_only_models(factory): ) uids = [s.uid for s in factory.list_suts()] assert uids == ["google/gemini-2.5-flash:google"] - - -@expensive_tests -def test_connection(): - factory = GoogleSUTFactory(load_secrets_from_config(path=".")) - sut_definition = SUTDefinition(model="gemini-2.5-flash", driver="google") - sut = factory.make_sut(sut_definition) - assert sut.uid == "gemini-2.5-flash:google" diff --git a/tests/modelgauge_tests/sut_tests/test_huggingface_sut_factory.py b/tests/modelgauge_tests/sut_tests/test_huggingface_sut_factory.py index 66acf152..1e8d575f 100644 --- a/tests/modelgauge_tests/sut_tests/test_huggingface_sut_factory.py +++ b/tests/modelgauge_tests/sut_tests/test_huggingface_sut_factory.py @@ -2,7 +2,6 @@ import pytest -from modelgauge.config import load_secrets_from_config from modelgauge.dynamic_sut_factory import ProviderNotFoundError from modelgauge.sut_definition import SUTDefinition from modelgauge.suts.huggingface_chat_completion import ( @@ -13,7 +12,7 @@ HuggingFaceChatCompletionDedicatedSUTFactory, HuggingFaceChatCompletionServerlessSUTFactory, ) -from modelgauge_tests.utilities import expensive_tests, FakeObject +from modelgauge_tests.utilities import FakeObject RAW_SECRETS = {"hugging_face": {"token": "value"}} @@ -90,14 +89,3 @@ def test_dedicated_list_suts(): factory = HuggingFaceChatCompletionDedicatedSUTFactory(RAW_SECRETS) assert "google/gemma:hf-dedicated" in [s.uid for s in factory.list_suts()] - - -@expensive_tests -def test_connection(): - factory = HuggingFaceChatCompletionServerlessSUTFactory(load_secrets_from_config(path=".")) - sut_definition = SUTDefinition(model="gemma-3-27b-it", maker="google", driver="hfrelay", provider="nebius") - sut = factory.make_sut(sut_definition) - assert isinstance(sut, HuggingFaceChatCompletionServerlessSUT) - assert sut.uid == "google/gemma-3-27b-it:nebius:hfrelay" - assert sut.model == "google/gemma-3-27b-it" - assert sut.provider == "nebius" diff --git a/tests/modelgauge_tests/sut_tests/test_openai_sut_factory.py b/tests/modelgauge_tests/sut_tests/test_openai_sut_factory.py index f8067937..a1d1b901 100644 --- a/tests/modelgauge_tests/sut_tests/test_openai_sut_factory.py +++ b/tests/modelgauge_tests/sut_tests/test_openai_sut_factory.py @@ -3,12 +3,10 @@ import pytest from openai import OpenAI -from modelgauge.config import load_secrets_from_config from modelgauge.dynamic_sut_factory import ModelNotSupportedError from modelgauge.sut_definition import SUTDefinition from modelgauge.suts.openai_client import OpenAIResponsesSUT from modelgauge.suts.openai_sut_factory import OpenAISUTFactory -from modelgauge_tests.utilities import expensive_tests @pytest.fixture @@ -55,12 +53,3 @@ def test_make_unknown_sut_raises_error(openai_factory): sut_definition = SUTDefinition(model="bogus", maker="openai", driver="openai") with pytest.raises(ModelNotSupportedError): openai_factory.make_sut(sut_definition) - - -@expensive_tests -def test_connection(): - factory = OpenAISUTFactory(load_secrets_from_config(path=".")) - sut_definition = SUTDefinition(model="gpt-4o", maker="openai", driver="openai") - sut = factory.make_sut(sut_definition) - assert sut.uid == "openai/gpt-4o:openai" - assert sut.model == "gpt-4o" diff --git a/tests/modelgauge_tests/sut_tests/test_together_sut_factory.py b/tests/modelgauge_tests/sut_tests/test_together_sut_factory.py index 5d925b98..511f64c1 100644 --- a/tests/modelgauge_tests/sut_tests/test_together_sut_factory.py +++ b/tests/modelgauge_tests/sut_tests/test_together_sut_factory.py @@ -2,7 +2,6 @@ import pytest -from modelgauge.config import load_secrets_from_config from modelgauge.dynamic_sut_factory import ModelNotSupportedError from modelgauge.sut_definition import SUTDefinition from modelgauge.suts.together_client import TogetherChatSUT, TogetherDedicatedChatSUT @@ -10,7 +9,6 @@ TogetherDedicatedSUTFactory, TogetherServerlessSUTFactory, ) -from modelgauge_tests.utilities import expensive_tests @pytest.fixture @@ -98,14 +96,3 @@ def test_dedicated_make_sut_not_found(dedicated_factory, mocker): def test_dedicated_list_suts(dedicated_factory, mocker): # Data structures are squirrely, so we skip this for now assert dedicated_factory.list_suts() is None - - -@expensive_tests -def test_serverless_connection(): - factory = TogetherServerlessSUTFactory(load_secrets_from_config(path=".")) - sut_definition = SUTDefinition( - maker="meta-llama", model="Llama-3.3-70B-Instruct-Turbo", driver="together-serverless" - ) - sut = factory.make_sut(sut_definition) - assert sut.uid == "meta-llama/llama-3.3-70b-instruct-turbo:together-serverless" - assert sut.model == "meta-llama/Llama-3.3-70B-Instruct-Turbo" diff --git a/tests/modelgauge_tests/test_object_creation.py b/tests/modelgauge_tests/test_object_creation.py index 45eab891..2a0d19fb 100644 --- a/tests/modelgauge_tests/test_object_creation.py +++ b/tests/modelgauge_tests/test_object_creation.py @@ -4,22 +4,12 @@ from flaky import flaky # type: ignore from modelgauge.base_test import PromptResponseTest -from modelgauge.caching import SqlDictCache from modelgauge.config import load_secrets_from_config from modelgauge.dependency_helper import FromSourceDependencyHelper from modelgauge.load_namespaces import load_namespaces -from modelgauge.locales import EN_US # see "workaround" below -from modelgauge.prompt import TextPrompt from modelgauge.record_init import InitializationRecord -from modelgauge.sut import PromptResponseSUT, SUTResponse -from modelgauge.model_options import ModelOptions -from modelgauge.sut_capabilities import AcceptsTextPrompt from modelgauge.sut_registry import SUTS -from modelgauge.suts.baseten_api import BasetenSUT -from modelgauge.suts.huggingface_chat_completion import HuggingFaceChatCompletionDedicatedSUT -from modelgauge.suts.together_client import TogetherDedicatedChatSUT from modelgauge.test_registry import TESTS -from modelgauge.tests.safe_v1 import BaseSafeTestVersion1 # see "workaround" below from modelgauge_tests.fake_secrets import fake_all_secrets from modelgauge_tests.utilities import expensive_tests @@ -65,97 +55,3 @@ def test_all_suts_construct_and_record_init(sut_name): sut = SUTS.make_instance(sut_name, secrets=_FAKE_SECRETS) assert hasattr(sut, "initialization_record"), "SUT is probably missing @modelgauge_sut() decorator." assert isinstance(sut.initialization_record, InitializationRecord) - - -SUTS_THAT_WE_DONT_CARE_ABOUT_FAILING = { - "StripedHyena-Nous-7B", - "olmo-7b-0724-instruct-hf", - "olmo-2-1124-7b-instruct-hf", - # mistral-nemo-instruct-2407-hf removed from test because of a bug in HF's date parsing code - # https://github.com/huggingface/huggingface_hub/issues/2671 - # Remove mistral-nemo-instruct-2407-hf from this set once it's fixed. - "mistral-nemo-instruct-2407-hf", - # old, unused - "qwen2-5-7b-instruct-hf", - # out of nvidia credits, and maybe they don't want to test these anymore - "nvidia-nemotron-mini-4b-instruct", - "nvidia-nemotron-4-340b-instruct", - "nvidia-llama-3.1-nemotron-70b-instruct", - "nvidia-mistral-nemo-minitron-8b-8k-instruct", - # used to work, throws an auth error, maybe we don't care so much - "meta-llama-3.3-8b-instruct-moderated-llama", - # deprecated by anthropic: https://docs.claude.com/en/docs/about-claude/model-deprecations#2025-08-13%3A-claude-sonnet-3-5-models - "claude-3-5-sonnet-20241022", -} - -TOO_EXPENSIVE_SUT_CLASSES = { - BasetenSUT, # Dedicated server - HuggingFaceChatCompletionDedicatedSUT, # Dedicated server - TogetherDedicatedChatSUT, # Dedicated server -} - - -def suts_to_test(): - suts = [] - represented_classes = [] - for uid, sut_info in SUTS.items(): - if uid in SUTS_THAT_WE_DONT_CARE_ABOUT_FAILING: - continue - cls = sut_info.cls - if any([issubclass(cls, c) for c in TOO_EXPENSIVE_SUT_CLASSES]): - continue - if cls not in represented_classes: - represented_classes.append(cls) - suts.append(uid) - return suts - - -# This test can take a while, and we don't want a test run to fail -# just because an external service is being slow. So we set a somewhat -# high timeout value that gives the test a chance to complete most of the time, -# but still fails if the external service really is flaky or slow, so we can -# get a sense of a real user's experience. -@expensive_tests -@pytest.mark.timeout(TIMEOUT) -@pytest.mark.parametrize("sut_name", suts_to_test()) -def test_all_suts_can_evaluate(sut_name): - sut = SUTS.make_instance(sut_name, secrets=load_secrets_from_config(path=".")) - assert isinstance(sut, PromptResponseSUT), "Update this test to handle other types." - if AcceptsTextPrompt in sut.capabilities: - native_request = sut.translate_text_prompt( - TextPrompt(text="What is your name?"), - ModelOptions(max_tokens=3), - ) - else: - raise AssertionError("Update test to handle other kinds of prompts.") - native_response = sut.evaluate(native_request) - response = sut.translate_response(native_request, native_response) - assert isinstance(response, SUTResponse) - assert response.text is not None - - -@expensive_tests -@pytest.mark.timeout(TIMEOUT) -@pytest.mark.parametrize("sut_name", suts_to_test()) -def test_can_cache_all_sut_responses(sut_name, tmpdir): - sut = SUTS.make_instance(sut_name, secrets=load_secrets_from_config(path=".")) - assert isinstance(sut, PromptResponseSUT), "Update this test to handle other types." - if AcceptsTextPrompt in sut.capabilities: - native_request = sut.translate_text_prompt( - TextPrompt( - text="What is your name?", - ), - options=ModelOptions(max_tokens=3), - ) - else: - raise AssertionError("Update test to handle other kinds of prompts.") - try: - native_response = sut.evaluate(native_request) - except Exception as e: - pytest.skip("SUT failed to evaluate request.") - - with SqlDictCache(tmpdir, "sut_name") as cache: - assert cache._can_encode(native_request) - assert cache._can_encode(native_response) - cache.update_cache(native_request, native_response) - assert cache.get_cached_response(native_request) == native_response