From 0d1fbb3e464904bade532a47ad5dc400bff833c9 Mon Sep 17 00:00:00 2001 From: Kye Date: Fri, 22 Dec 2023 21:41:43 -0500 Subject: [PATCH] [TESTS][CLEANUP] --- pyproject.toml | 2 +- swarms/models/base_llm.py | 2 +- swarms/structs/conversation.py | 1 - swarms/utils/__init__.py | 2 +- ..._decorator.py => llm_metrics_decorator.py} | 0 tests/swarms/test_godmode.py | 36 ------------------- tests/swarms/test_multi_agent_collab.py | 19 ---------- tests/utils/test_metrics_decorator.py | 2 +- 8 files changed, 4 insertions(+), 60 deletions(-) rename swarms/utils/{llm_metrcs_decorator.py => llm_metrics_decorator.py} (100%) delete mode 100644 tests/swarms/test_godmode.py diff --git a/pyproject.toml b/pyproject.toml index 06d02159..6d4cbea8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "swarms" -version = "2.9.9" +version = "2.3.0" description = "Swarms - Pytorch" license = "MIT" authors = ["Kye Gomez "] diff --git a/swarms/models/base_llm.py b/swarms/models/base_llm.py index 09316a24..15e50790 100644 --- a/swarms/models/base_llm.py +++ b/swarms/models/base_llm.py @@ -5,7 +5,7 @@ import time from abc import ABC, abstractmethod from typing import List, Optional -from swarms.utils.llm_metrcs_decorator import metrics_decorator +from swarms.utils.llm_metrics_decorator import metrics_decorator def count_tokens(text: str) -> int: diff --git a/swarms/structs/conversation.py b/swarms/structs/conversation.py index a5840488..8a7dea4a 100644 --- a/swarms/structs/conversation.py +++ b/swarms/structs/conversation.py @@ -187,7 +187,6 @@ class Conversation(BaseStructure): # Load the conversation history from a JSON file with open(filename, "r") as f: self.conversation_history = json.load(f) - def search_keyword_in_conversation(self, keyword: str): """Search for a keyword in the conversation history diff --git a/swarms/utils/__init__.py b/swarms/utils/__init__.py index ca149cc9..7dedefec 100644 --- a/swarms/utils/__init__.py +++ b/swarms/utils/__init__.py @@ -5,7 +5,7 @@ from swarms.utils.parse_code import ( ) from swarms.utils.pdf_to_text import pdf_to_text from swarms.utils.math_eval import math_eval -from swarms.utils.llm_metrcs_decorator import metrics_decorator +from swarms.utils.llm_metrics_decorator import metrics_decorator # from swarms.utils.phoenix_handler import phoenix_trace_decorator diff --git a/swarms/utils/llm_metrcs_decorator.py b/swarms/utils/llm_metrics_decorator.py similarity index 100% rename from swarms/utils/llm_metrcs_decorator.py rename to swarms/utils/llm_metrics_decorator.py diff --git a/tests/swarms/test_godmode.py b/tests/swarms/test_godmode.py deleted file mode 100644 index 8f528026..00000000 --- a/tests/swarms/test_godmode.py +++ /dev/null @@ -1,36 +0,0 @@ -from unittest.mock import patch -from swarms.swarms.god_mode import GodMode, LLM - - -def test_godmode_initialization(): - godmode = GodMode(llms=[LLM] * 5) - assert isinstance(godmode, GodMode) - assert len(godmode.llms) == 5 - - -def test_godmode_run(monkeypatch): - def mock_llm_run(self, task): - return "response" - - monkeypatch.setattr(LLM, "run", mock_llm_run) - godmode = GodMode(llms=[LLM] * 5) - responses = godmode.run("task1") - assert len(responses) == 5 - assert responses == [ - "response", - "response", - "response", - "response", - "response", - ] - - -@patch("builtins.print") -def test_godmode_print_responses(mock_print, monkeypatch): - def mock_llm_run(self, task): - return "response" - - monkeypatch.setattr(LLM, "run", mock_llm_run) - godmode = GodMode(llms=[LLM] * 5) - godmode.print_responses("task1") - assert mock_print.call_count == 1 diff --git a/tests/swarms/test_multi_agent_collab.py b/tests/swarms/test_multi_agent_collab.py index f56170e8..4d85a436 100644 --- a/tests/swarms/test_multi_agent_collab.py +++ b/tests/swarms/test_multi_agent_collab.py @@ -6,8 +6,6 @@ from swarms.structs import Agent from swarms.models import OpenAIChat from swarms.swarms.multi_agent_collab import ( MultiAgentCollaboration, - select_next_speaker_director, - select_speaker_round_table, ) # Sample agents for testing @@ -105,13 +103,6 @@ def test_set_interaction_rules(collaboration): assert collaboration.interaction_rules == rules -def test_set_interaction_rules(collaboration): - rules = {"rule1": "action1", "rule2": "action2"} - collaboration.set_interaction_rules(rules) - assert hasattr(collaboration, "interaction_rules") - assert collaboration.interaction_rules == rules - - def test_repr(collaboration): repr_str = repr(collaboration) assert isinstance(repr_str, str) @@ -145,16 +136,6 @@ def test_save(collaboration, tmp_path): # Add more tests here... -# Example of parameterized test for different selection functions -@pytest.mark.parametrize( - "selection_function", - [select_next_speaker_director, select_speaker_round_table], -) -def test_selection_functions(collaboration, selection_function): - collaboration.select_next_speaker = selection_function - assert callable(collaboration.select_next_speaker) - - # Add more parameterized tests for different scenarios... diff --git a/tests/utils/test_metrics_decorator.py b/tests/utils/test_metrics_decorator.py index 84a06eec..126c6465 100644 --- a/tests/utils/test_metrics_decorator.py +++ b/tests/utils/test_metrics_decorator.py @@ -1,5 +1,5 @@ import time -from swarms.utils.llm_metrcs_decorator import metrics_decorator +from swarms.utils.llm_metrics_decorator import metrics_decorator def test_metrics_decorator():