From daf3c9e6a667ee94ccf4b3becc65cc311db45040 Mon Sep 17 00:00:00 2001 From: Kye Date: Wed, 15 Nov 2023 17:04:19 -0500 Subject: [PATCH] CLEAN UP: NON EXISTENT TESTS Former-commit-id: ef9d4b40a3ac7abe923a21b34ff263f11b1b143d --- example.py | 4 +- playground/models/nougat.py | 2 +- playground/models/palm.py | 2 +- playground/models/speecht5.py | 1 - playground/models/ssd.py | 2 +- playground/models/vilt.py | 4 +- playground/models/yi_200k.py | 2 +- pyproject.toml | 2 +- swarms/__init__.py | 1 + swarms/models/__init__.py | 5 +- swarms/swarms/__init__.py | 1 + tests/swarms/groupchat.py | 2 +- tests/swarms/scalable_groupchat.py | 61 --------------------- tests/swarms/swarms.py | 85 ------------------------------ 14 files changed, 16 insertions(+), 158 deletions(-) delete mode 100644 tests/swarms/scalable_groupchat.py delete mode 100644 tests/swarms/swarms.py diff --git a/example.py b/example.py index de26cde8..35972f85 100644 --- a/example.py +++ b/example.py @@ -10,6 +10,7 @@ llm = OpenAIChat( # max_tokens=100, ) + @tool def search_api(query: str): """ @@ -18,13 +19,12 @@ def search_api(query: str): pass - ## Initialize the workflow flow = Flow( llm=llm, max_loops=5, dashboard=True, - tools = [search_api] + tools=[search_api] # stopping_condition=None, # You can define a stopping condition as needed. # loop_interval=1, # retry_attempts=3, diff --git a/playground/models/nougat.py b/playground/models/nougat.py index ad4ef2fc..198fee38 100644 --- a/playground/models/nougat.py +++ b/playground/models/nougat.py @@ -2,4 +2,4 @@ from swarms.models.nougat import Nougat nougat = Nougat() -out = nougat("path/to/image.png") \ No newline at end of file +out = nougat("path/to/image.png") diff --git a/playground/models/palm.py b/playground/models/palm.py index 513e114f..9bcd6f7f 100644 --- a/playground/models/palm.py +++ b/playground/models/palm.py @@ -2,4 +2,4 @@ from swarms.models.palm import PALM palm = PALM() -out = palm("path/to/image.png") \ No newline at end of file +out = palm("path/to/image.png") diff --git a/playground/models/speecht5.py b/playground/models/speecht5.py index 38e2300b..a02e88b5 100644 --- a/playground/models/speecht5.py +++ b/playground/models/speecht5.py @@ -6,4 +6,3 @@ result = speechT5("Hello, how are you?") speechT5.save_speech(result) print("Speech saved successfully!") - diff --git a/playground/models/ssd.py b/playground/models/ssd.py index 6ff090a8..2234b9c8 100644 --- a/playground/models/ssd.py +++ b/playground/models/ssd.py @@ -6,4 +6,4 @@ task = "A painting of a dog" neg_prompt = "ugly, blurry, poor quality" image_url = model(task, neg_prompt) -print(image_url) \ No newline at end of file +print(image_url) diff --git a/playground/models/vilt.py b/playground/models/vilt.py index 373154bb..127514e0 100644 --- a/playground/models/vilt.py +++ b/playground/models/vilt.py @@ -2,4 +2,6 @@ from swarms.models.vilt import Vilt model = Vilt() -output = model("What is this image", "http://images.cocodataset.org/val2017/000000039769.jpg") +output = model( + "What is this image", "http://images.cocodataset.org/val2017/000000039769.jpg" +) diff --git a/playground/models/yi_200k.py b/playground/models/yi_200k.py index f2f56853..5396fa1e 100644 --- a/playground/models/yi_200k.py +++ b/playground/models/yi_200k.py @@ -2,4 +2,4 @@ from swarms.models.yi_200k import Yi200k models = Yi200k() -out = models("What is the weather like today?") \ No newline at end of file +out = models("What is the weather like today?") diff --git a/pyproject.toml b/pyproject.toml index 5cf2abc2..8ae5b4dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "swarms" -version = "2.3.2" +version = "2.3.4" description = "Swarms - Pytorch" license = "MIT" authors = ["Kye Gomez "] diff --git a/swarms/__init__.py b/swarms/__init__.py index f875f0a1..c89a5538 100644 --- a/swarms/__init__.py +++ b/swarms/__init__.py @@ -10,5 +10,6 @@ from swarms.agents import * # noqa: E402, F403 from swarms.swarms import * # noqa: E402, F403 from swarms.structs import * # noqa: E402, F403 from swarms.models import * # noqa: E402, F403 + # from swarms.chunkers import * # noqa: E402, F403 from swarms.workers import * # noqa: E402, F403 diff --git a/swarms/models/__init__.py b/swarms/models/__init__.py index 4595cd53..f509087c 100644 --- a/swarms/models/__init__.py +++ b/swarms/models/__init__.py @@ -16,7 +16,8 @@ from swarms.models.mpt import MPT7B # noqa: E402 # MultiModal Models from swarms.models.idefics import Idefics # noqa: E402 -from swarms.models.kosmos_two import Kosmos # noqa: E402 + +# from swarms.models.kosmos_two import Kosmos # noqa: E402 from swarms.models.vilt import Vilt # noqa: E402 from swarms.models.nougat import Nougat # noqa: E402 from swarms.models.layoutlm_document_qa import LayoutLMDocumentQA # noqa: E402 @@ -34,7 +35,7 @@ __all__ = [ "OpenAIChat", "Zephyr", "Idefics", - "Kosmos", + # "Kosmos", "Vilt", "Nougat", "LayoutLMDocumentQA", diff --git a/swarms/swarms/__init__.py b/swarms/swarms/__init__.py index 1b11361b..5872eb23 100644 --- a/swarms/swarms/__init__.py +++ b/swarms/swarms/__init__.py @@ -1,5 +1,6 @@ from swarms.swarms.dialogue_simulator import DialogueSimulator from swarms.swarms.autoscaler import AutoScaler + # from swarms.swarms.orchestrate import Orchestrator from swarms.swarms.god_mode import GodMode from swarms.swarms.simple_swarm import SimpleSwarm diff --git a/tests/swarms/groupchat.py b/tests/swarms/groupchat.py index f81c415a..b25e7f91 100644 --- a/tests/swarms/groupchat.py +++ b/tests/swarms/groupchat.py @@ -3,7 +3,7 @@ import pytest from swarms.models import OpenAIChat from swarms.models.anthropic import Anthropic from swarms.structs.flow import Flow -from swarms.swarms.flow import GroupChat, GroupChatManager +from swarms.swarms.groupchat import GroupChat, GroupChatManager llm = OpenAIChat() llm2 = Anthropic() diff --git a/tests/swarms/scalable_groupchat.py b/tests/swarms/scalable_groupchat.py deleted file mode 100644 index bae55faf..00000000 --- a/tests/swarms/scalable_groupchat.py +++ /dev/null @@ -1,61 +0,0 @@ -from unittest.mock import patch -from swarms.swarms.scalable_groupchat import ScalableGroupChat - - -def test_scalablegroupchat_initialization(): - scalablegroupchat = ScalableGroupChat( - worker_count=5, collection_name="swarm", api_key="api_key" - ) - assert isinstance(scalablegroupchat, ScalableGroupChat) - assert len(scalablegroupchat.workers) == 5 - assert scalablegroupchat.collection_name == "swarm" - assert scalablegroupchat.api_key == "api_key" - - -@patch("chromadb.utils.embedding_functions.OpenAIEmbeddingFunction") -def test_scalablegroupchat_embed(mock_openaiembeddingfunction): - scalablegroupchat = ScalableGroupChat( - worker_count=5, collection_name="swarm", api_key="api_key" - ) - scalablegroupchat.embed("input", "model_name") - assert mock_openaiembeddingfunction.call_count == 1 - - -@patch("swarms.swarms.scalable_groupchat.ScalableGroupChat.collection.query") -def test_scalablegroupchat_retrieve_results(mock_query): - scalablegroupchat = ScalableGroupChat( - worker_count=5, collection_name="swarm", api_key="api_key" - ) - scalablegroupchat.retrieve_results(1) - assert mock_query.call_count == 1 - - -@patch("swarms.swarms.scalable_groupchat.ScalableGroupChat.collection.add") -def test_scalablegroupchat_update_vector_db(mock_add): - scalablegroupchat = ScalableGroupChat( - worker_count=5, collection_name="swarm", api_key="api_key" - ) - scalablegroupchat.update_vector_db({"vector": "vector", "task_id": "task_id"}) - assert mock_add.call_count == 1 - - -@patch("swarms.swarms.scalable_groupchat.ScalableGroupChat.collection.add") -def test_scalablegroupchat_append_to_db(mock_add): - scalablegroupchat = ScalableGroupChat( - worker_count=5, collection_name="swarm", api_key="api_key" - ) - scalablegroupchat.append_to_db("result") - assert mock_add.call_count == 1 - - -@patch("swarms.swarms.scalable_groupchat.ScalableGroupChat.collection.add") -@patch("swarms.swarms.scalable_groupchat.ScalableGroupChat.embed") -@patch("swarms.swarms.scalable_groupchat.ScalableGroupChat.run") -def test_scalablegroupchat_chat(mock_run, mock_embed, mock_add): - scalablegroupchat = ScalableGroupChat( - worker_count=5, collection_name="swarm", api_key="api_key" - ) - scalablegroupchat.chat(sender_id=1, receiver_id=2, message="Hello, Agent 2!") - assert mock_embed.call_count == 1 - assert mock_add.call_count == 1 - assert mock_run.call_count == 1 diff --git a/tests/swarms/swarms.py b/tests/swarms/swarms.py deleted file mode 100644 index dc6f9c36..00000000 --- a/tests/swarms/swarms.py +++ /dev/null @@ -1,85 +0,0 @@ -import pytest -import logging -from unittest.mock import patch -from swarms.swarms.swarms import ( - HierarchicalSwarm, -) # replace with your actual module name - - -@pytest.fixture -def swarm(): - return HierarchicalSwarm( - model_id="gpt-4", - openai_api_key="some_api_key", - use_vectorstore=True, - embedding_size=1024, - use_async=False, - human_in_the_loop=True, - model_type="openai", - boss_prompt="boss", - worker_prompt="worker", - temperature=0.5, - max_iterations=100, - logging_enabled=True, - ) - - -@pytest.fixture -def swarm_no_logging(): - return HierarchicalSwarm(logging_enabled=False) - - -def test_swarm_init(swarm): - assert swarm.model_id == "gpt-4" - assert swarm.openai_api_key == "some_api_key" - assert swarm.use_vectorstore - assert swarm.embedding_size == 1024 - assert not swarm.use_async - assert swarm.human_in_the_loop - assert swarm.model_type == "openai" - assert swarm.boss_prompt == "boss" - assert swarm.worker_prompt == "worker" - assert swarm.temperature == 0.5 - assert swarm.max_iterations == 100 - assert swarm.logging_enabled - assert isinstance(swarm.logger, logging.Logger) - - -def test_swarm_no_logging_init(swarm_no_logging): - assert not swarm_no_logging.logging_enabled - assert swarm_no_logging.logger.disabled - - -@patch("your_module.OpenAI") -@patch("your_module.HuggingFaceLLM") -def test_initialize_llm(mock_huggingface, mock_openai, swarm): - swarm.initialize_llm("openai") - mock_openai.assert_called_once_with(openai_api_key="some_api_key", temperature=0.5) - - swarm.initialize_llm("huggingface") - mock_huggingface.assert_called_once_with(model_id="gpt-4", temperature=0.5) - - -@patch("your_module.HierarchicalSwarm.initialize_llm") -def test_initialize_tools(mock_llm, swarm): - mock_llm.return_value = "mock_llm_class" - tools = swarm.initialize_tools("openai") - assert "mock_llm_class" in tools - - -@patch("your_module.HierarchicalSwarm.initialize_llm") -def test_initialize_tools_with_extra_tools(mock_llm, swarm): - mock_llm.return_value = "mock_llm_class" - tools = swarm.initialize_tools("openai", extra_tools=["tool1", "tool2"]) - assert "tool1" in tools - assert "tool2" in tools - - -@patch("your_module.OpenAIEmbeddings") -@patch("your_module.FAISS") -def test_initialize_vectorstore(mock_faiss, mock_openai_embeddings, swarm): - mock_openai_embeddings.return_value.embed_query = "embed_query" - swarm.initialize_vectorstore() - mock_faiss.assert_called_once_with( - "embed_query", instance_of(faiss.IndexFlatL2), instance_of(InMemoryDocstore), {} - )