CLEAN UP: NON EXISTENT TESTS

Former-commit-id: ef9d4b40a3ac7abe923a21b34ff263f11b1b143d
clean-history
Kye 1 year ago
parent 2d05a09e1c
commit daf3c9e6a6

@ -10,6 +10,7 @@ llm = OpenAIChat(
# max_tokens=100, # max_tokens=100,
) )
@tool @tool
def search_api(query: str): def search_api(query: str):
""" """
@ -18,13 +19,12 @@ def search_api(query: str):
pass pass
## Initialize the workflow ## Initialize the workflow
flow = Flow( flow = Flow(
llm=llm, llm=llm,
max_loops=5, max_loops=5,
dashboard=True, dashboard=True,
tools = [search_api] tools=[search_api]
# stopping_condition=None, # You can define a stopping condition as needed. # stopping_condition=None, # You can define a stopping condition as needed.
# loop_interval=1, # loop_interval=1,
# retry_attempts=3, # retry_attempts=3,

@ -2,4 +2,4 @@ from swarms.models.nougat import Nougat
nougat = Nougat() nougat = Nougat()
out = nougat("path/to/image.png") out = nougat("path/to/image.png")

@ -2,4 +2,4 @@ from swarms.models.palm import PALM
palm = PALM() palm = PALM()
out = palm("path/to/image.png") out = palm("path/to/image.png")

@ -6,4 +6,3 @@ result = speechT5("Hello, how are you?")
speechT5.save_speech(result) speechT5.save_speech(result)
print("Speech saved successfully!") print("Speech saved successfully!")

@ -6,4 +6,4 @@ task = "A painting of a dog"
neg_prompt = "ugly, blurry, poor quality" neg_prompt = "ugly, blurry, poor quality"
image_url = model(task, neg_prompt) image_url = model(task, neg_prompt)
print(image_url) print(image_url)

@ -2,4 +2,6 @@ from swarms.models.vilt import Vilt
model = 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"
)

@ -2,4 +2,4 @@ from swarms.models.yi_200k import Yi200k
models = Yi200k() models = Yi200k()
out = models("What is the weather like today?") out = models("What is the weather like today?")

@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry] [tool.poetry]
name = "swarms" name = "swarms"
version = "2.3.2" version = "2.3.4"
description = "Swarms - Pytorch" description = "Swarms - Pytorch"
license = "MIT" license = "MIT"
authors = ["Kye Gomez <kye@apac.ai>"] authors = ["Kye Gomez <kye@apac.ai>"]

@ -10,5 +10,6 @@ from swarms.agents import * # noqa: E402, F403
from swarms.swarms import * # noqa: E402, F403 from swarms.swarms import * # noqa: E402, F403
from swarms.structs import * # noqa: E402, F403 from swarms.structs import * # noqa: E402, F403
from swarms.models import * # noqa: E402, F403 from swarms.models import * # noqa: E402, F403
# from swarms.chunkers import * # noqa: E402, F403 # from swarms.chunkers import * # noqa: E402, F403
from swarms.workers import * # noqa: E402, F403 from swarms.workers import * # noqa: E402, F403

@ -16,7 +16,8 @@ from swarms.models.mpt import MPT7B # noqa: E402
# MultiModal Models # MultiModal Models
from swarms.models.idefics import Idefics # noqa: E402 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.vilt import Vilt # noqa: E402
from swarms.models.nougat import Nougat # noqa: E402 from swarms.models.nougat import Nougat # noqa: E402
from swarms.models.layoutlm_document_qa import LayoutLMDocumentQA # noqa: E402 from swarms.models.layoutlm_document_qa import LayoutLMDocumentQA # noqa: E402
@ -34,7 +35,7 @@ __all__ = [
"OpenAIChat", "OpenAIChat",
"Zephyr", "Zephyr",
"Idefics", "Idefics",
"Kosmos", # "Kosmos",
"Vilt", "Vilt",
"Nougat", "Nougat",
"LayoutLMDocumentQA", "LayoutLMDocumentQA",

@ -1,5 +1,6 @@
from swarms.swarms.dialogue_simulator import DialogueSimulator from swarms.swarms.dialogue_simulator import DialogueSimulator
from swarms.swarms.autoscaler import AutoScaler from swarms.swarms.autoscaler import AutoScaler
# from swarms.swarms.orchestrate import Orchestrator # from swarms.swarms.orchestrate import Orchestrator
from swarms.swarms.god_mode import GodMode from swarms.swarms.god_mode import GodMode
from swarms.swarms.simple_swarm import SimpleSwarm from swarms.swarms.simple_swarm import SimpleSwarm

@ -3,7 +3,7 @@ import pytest
from swarms.models import OpenAIChat from swarms.models import OpenAIChat
from swarms.models.anthropic import Anthropic from swarms.models.anthropic import Anthropic
from swarms.structs.flow import Flow from swarms.structs.flow import Flow
from swarms.swarms.flow import GroupChat, GroupChatManager from swarms.swarms.groupchat import GroupChat, GroupChatManager
llm = OpenAIChat() llm = OpenAIChat()
llm2 = Anthropic() llm2 = Anthropic()

@ -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

@ -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), {}
)
Loading…
Cancel
Save