Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

delete unused test (#8116)

Chen Qian6efbb5dada00
diff --git a/tests/adapters/test_json_adapter.py b/tests/adapters/test_json_adapter.py
index d2e79c63f..b0242416b 100644
--- a/tests/adapters/test_json_adapter.py
+++ b/tests/adapters/test_json_adapter.py
@@ -42,11 +42,6 @@ def test_json_adapter_passes_structured_output_when_supported_by_model():
assert response_format is not None
assert issubclass(response_format, pydantic.BaseModel)
assert response_format.model_fields.keys() == {"output1", "output2", "output3", "output4_unannotated"}
- # for field_name in response_format.model_fields:
- # assert dict(response_format.model_fields[field_name].__repr_args__()) == clean_schema_extra(
- # field_name=field_name,
- # field_info=TestSignature.output_fields[field_name],
- # )
# Configure DSPy to use a model from a fake provider that doesn't support structured outputs
dspy.configure(lm=dspy.LM(model="fakeprovider/fakemodel"), adapter=dspy.JSONAdapter())
diff --git a/tests/modules/test_aws_models.py b/tests/modules/test_aws_models.py
deleted file mode 100644
index 5e4381069..000000000
--- a/tests/modules/test_aws_models.py
+++ /dev/null
@@ -1,70 +0,0 @@
-# """Tests for AWS models.
-# Note: Requires configuration of your AWS credentials with the AWS CLI and creating sagemaker endpoints.
-# TODO: Create mock fixtures for pytest to remove the need for AWS credentials and endpoints.
-# """
-
-# import dsp
-# import dspy
-
-
-# def get_lm(lm_provider: str, model_path: str, **kwargs) -> dsp.modules.lm.LM:
-# """get the language model"""
-# # extract model vendor and name from model name
-# # Model path format is <MODEL_VENDOR>/<MODEL_NAME_OR_ENDPOINT>
-# model_vendor = model_path.split("/")[0]
-# model_name = model_path.split("/")[1]
-
-# if lm_provider == "Bedrock":
-# bedrock = dspy.Bedrock(region_name="us-west-2")
-# if model_vendor == "mistral":
-# return dspy.AWSMistral(bedrock, model_name, **kwargs)
-# elif model_vendor == "anthropic":
-# return dspy.AWSAnthropic(bedrock, model_name, **kwargs)
-# elif model_vendor == "meta":
-# return dspy.AWSMeta(bedrock, model_name, **kwargs)
-# else:
-# raise ValueError(
-# "Model vendor missing or unsupported: Model path format is <MODEL_VENDOR>/<MODEL_NAME_OR_ENDPOINT>"
-# )
-# elif lm_provider == "Sagemaker":
-# sagemaker = dspy.Sagemaker(region_name="us-west-2")
-# if model_vendor == "mistral":
-# return dspy.AWSMistral(sagemaker, model_name, **kwargs)
-# elif model_vendor == "meta":
-# return dspy.AWSMeta(sagemaker, model_name, **kwargs)
-# else:
-# raise ValueError(
-# "Model vendor missing or unsupported: Model path format is <MODEL_VENDOR>/<MODEL_NAME_OR_ENDPOINT>"
-# )
-# else:
-# raise ValueError(f"Unsupported model: {model_name}")
-
-
-# def run_tests():
-# """Test the providers and models"""
-# # Configure your AWS credentials with the AWS CLI before running this script
-# provider_model_tuples = [
-# ("Bedrock", "mistral/mistral.mixtral-8x7b-instruct-v0:1"),
-# ("Bedrock", "anthropic/anthropic.claude-3-haiku-20240307-v1:0"),
-# ("Bedrock", "anthropic/anthropic.claude-3-sonnet-20240229-v1:0"),
-# ("Bedrock", "meta/meta.llama2-70b-chat-v1"),
-# ("Bedrock", "meta/meta.llama3-8b-instruct-v1:0"),
-# ("Bedrock", "meta/meta.llama3-70b-instruct-v1:0"),
-# # ('Sagemaker', 'mistral/<YOUR_ENDPOINT_NAME>'), # REPLACE YOUR_ENDPOINT_NAME with your sagemaker endpoint
-# ]
-
-# predict_func = dspy.Predict("question -> answer")
-# for provider, model_path in provider_model_tuples:
-# print(f"Provider: {provider}, Model: {model_path}")
-# lm = get_lm(provider, model_path)
-# with dspy.context(lm=lm):
-# question = "What is the capital of France?"
-# answer = predict_func(question=question).answer
-# print(f"Question: {question}\nAnswer: {answer}")
-# print("---------------------------------")
-# lm.inspect_history()
-# print("---------------------------------\n")
-
-
-# if __name__ == "__main__":
-# run_tests()
diff --git a/tests/modules/test_cloudflare_models.py b/tests/modules/test_cloudflare_models.py
deleted file mode 100644
index 2ab222c86..000000000
--- a/tests/modules/test_cloudflare_models.py
+++ /dev/null
@@ -1,61 +0,0 @@
-"""Tests for Cloudflare models.
-Note: Requires configuration of your Cloudflare account_id and api_key.
-"""
-
-import dspy
-
-models = {
- "@cf/qwen/qwen1.5-0.5b-chat": "https://huggingface.co/qwen/qwen1.5-0.5b-chat",
- "@hf/meta-llama/meta-llama-3-8b-instruct": "https://llama.meta.com",
- "@hf/nexusflow/starling-lm-7b-beta": "https://huggingface.co/Nexusflow/Starling-LM-7B-beta",
- "@cf/meta/llama-3-8b-instruct": "https://llama.meta.com",
- "@hf/thebloke/neural-chat-7b-v3-1-awq": "",
- "@cf/meta/llama-2-7b-chat-fp16": "https://ai.meta.com/llama/",
- "@cf/mistral/mistral-7b-instruct-v0.1": "https://mistral.ai/news/announcing-mistral-7b/",
- "@cf/tinyllama/tinyllama-1.1b-chat-v1.0": "https://huggingface.co/TinyLlama/TinyLlama-1.1B-Chat-v1.0",
- "@hf/mistral/mistral-7b-instruct-v0.2": "https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2",
- "@cf/fblgit/una-cybertron-7b-v2-bf16": "",
- "@hf/thebloke/codellama-7b-instruct-awq": "https://huggingface.co/TheBloke/CodeLlama-7B-Instruct-AWQ",
- "@cf/thebloke/discolm-german-7b-v1-awq": "https://huggingface.co/TheBloke/DiscoLM_German_7b_v1-AWQ",
- "@cf/meta/llama-2-7b-chat-int8": "https://ai.meta.com/llama/",
- "@hf/thebloke/mistral-7b-instruct-v0.1-awq": "https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.1-AWQ",
- "@hf/thebloke/openchat_3.5-awq": "",
- "@cf/qwen/qwen1.5-7b-chat-awq": "https://huggingface.co/qwen/qwen1.5-7b-chat-awq",
- "@hf/thebloke/llama-2-13b-chat-awq": "https://huggingface.co/TheBloke/Llama-2-13B-chat-AWQ",
- "@hf/thebloke/deepseek-coder-6.7b-base-awq": "",
- "@hf/thebloke/openhermes-2.5-mistral-7b-awq": "",
- "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": "",
- "@cf/deepseek-ai/deepseek-math-7b-instruct": "https://huggingface.co/deepseek-ai/deepseek-math-7b-instruct",
- "@cf/tiiuae/falcon-7b-instruct": "https://huggingface.co/tiiuae/falcon-7b-instruct",
- "@hf/nousresearch/hermes-2-pro-mistral-7b": "https://huggingface.co/NousResearch/Hermes-2-Pro-Mistral-7B",
- "@hf/thebloke/zephyr-7b-beta-awq": "https://huggingface.co/TheBloke/zephyr-7B-beta-AWQ",
- "@cf/qwen/qwen1.5-1.8b-chat": "https://huggingface.co/qwen/qwen1.5-1.8b-chat",
- "@cf/defog/sqlcoder-7b-2": "https://huggingface.co/defog/sqlcoder-7b-2",
- "@cf/microsoft/phi-2": "https://huggingface.co/microsoft/phi-2",
- "@hf/google/gemma-7b-it": "https://ai.google.dev/gemma/docs",
-}
-
-
-def get_lm(name: str): # -> dspy.LM:
- return dspy.CloudflareAI(model=name)
-
-
-def run_tests():
- """Test the providers and models"""
- # Configure your AWS credentials with the AWS CLI before running this script
- models
-
- predict_func = dspy.Predict("question -> answer")
- for model_name in models.keys():
- lm = get_lm(model_name)
- with dspy.context(lm=lm):
- question = "What is the capital of France?"
- answer = predict_func(question=question).answer
- print(f"Question: {question}\nAnswer: {answer}")
- print("---------------------------------")
- lm.inspect_history()
- print("---------------------------------\n")
-
-
-if __name__ == "__main__":
- run_tests()
diff --git a/tests/modules/test_hf_model.py b/tests/modules/test_hf_model.py
deleted file mode 100644
index 26d143be9..000000000
--- a/tests/modules/test_hf_model.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# from pytest_mock.plugin import MockerFixture
-# from transformers import AutoModelForSeq2SeqLM
-
-# import dspy
-
-
-# class MockConfig:
-# def __init__(self, architectures: list[str]):
-# self.architectures = architectures
-
-
-# # def test_load_gated_model(mocker: MockerFixture):
-# # conf = MockConfig(architectures=["ConditionalGeneration"])
-# # mocker.patch("transformers.AutoModelForSeq2SeqLM.from_pretrained")
-# # mocker.patch("transformers.AutoConfig.from_pretrained", return_value=conf)
-# # mocker.patch("transformers.AutoTokenizer.from_pretrained")
-
-# # some_token = "asdfasdfasdf"
-# # model = "google/gemma-7b"
-# # _ = dspy.HFModel(model, token=some_token)
-# # AutoModelForSeq2SeqLM.from_pretrained.assert_called_with(model, device_map="auto", token=some_token)
-
-
-# # def test_load_ungated_model(mocker: MockerFixture):
-# # conf = MockConfig(architectures=["ConditionalGeneration"])
-# # # Mock the environment to ensure no default token is used
-# # mocker.patch.dict('os.environ', {}, clear=True) # Clear environment variables
-# # mocker.patch("transformers.AutoModelForSeq2SeqLM.from_pretrained")
-# # mocker.patch("transformers.AutoConfig.from_pretrained", return_value=conf)
-# # mocker.patch("transformers.AutoTokenizer.from_pretrained")
-# # _ = dspy.HFModel("openai-community/gpt2")
-# # # no token used in automodel
-# # AutoModelForSeq2SeqLM.from_pretrained.assert_called_with("openai-community/gpt2", device_map="auto", token=None)
diff --git a/tests/modules/vectorizer/test_fastembed.py b/tests/modules/vectorizer/test_fastembed.py
deleted file mode 100644
index 6d2ba7647..000000000
--- a/tests/modules/vectorizer/test_fastembed.py
+++ /dev/null
@@ -1,43 +0,0 @@
-# from dsp.modules.sentence_vectorizer import FastEmbedVectorizer
-# import pytest
-
-# from dspy.primitives.example import Example
-
-# # Skip the test if the 'fastembed' package is not installed
-# pytest.importorskip("fastembed", reason="'fastembed' is not installed. Use `pip install fastembed` to install it.")
-
-
-# @pytest.mark.parametrize(
-# "n_dims,model_name", [(384, "BAAI/bge-small-en-v1.5"), (512, "jinaai/jina-embeddings-v2-small-en")]
-# )
-# def test_fastembed_with_examples(n_dims, model_name):
-# vectorizer = FastEmbedVectorizer(model_name)
-
-# examples = [
-# Example(query="What's the price today?", response="The price is $10.00").with_inputs("query", "response"),
-# Example(query="What's the weather today?", response="The weather is sunny").with_inputs("query", "response"),
-# Example(query="Who was leading the team?", response="It was Jim. Rather enthusiastic guy.").with_inputs(
-# "query", "response"
-# ),
-# ]
-
-# embeddings = vectorizer(examples)
-
-# assert embeddings.shape == (len(examples), n_dims)
-
-
-# @pytest.mark.parametrize(
-# "n_dims,model_name", [(384, "BAAI/bge-small-en-v1.5"), (512, "jinaai/jina-embeddings-v2-small-en")]
-# )
-# def test_fastembed_with_strings(n_dims, model_name):
-# vectorizer = FastEmbedVectorizer(model_name)
-
-# inputs = [
-# "Jonathan Kent is a fictional character appearing in American comic books published by DC Comics.",
-# "Clark Kent is a fictional character appearing in American comic books published by DC Comics.",
-# "Martha Kent is a fictional character appearing in American comic books published by DC Comics.",
-# ]
-
-# embeddings = vectorizer(inputs)
-
-# assert embeddings.shape == (len(inputs), n_dims)