From abb7aa605ae84c33df8a3fe99ceddc7163a190a2 Mon Sep 17 00:00:00 2001 From: Kye Gomez Date: Wed, 29 Jan 2025 13:52:01 -0500 Subject: [PATCH] [DOCKERFILE] --- .gitignore | 1 + Dockerfile | 2 ++ pyproject.toml | 2 +- simple_example.py | 6 +++--- swarms/agents/tool_agent.py | 2 -- swarms/structs/agent.py | 2 +- swarms/structs/swarm_matcher.py | 3 --- swarms/tools/json_former.py | 2 -- swarms/utils/litellm_tokenizer.py | 3 ++- swarms/utils/pdf_to_text.py | 3 ++- 10 files changed, 12 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 418d9a8e2..28e8b8d58 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ static/generated runs Financial-Analysis-Agent_state.json experimental +ffn_alternatives artifacts_five encryption errors diff --git a/Dockerfile b/Dockerfile index 20567ff64..d9ec88b31 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ # Install swarms packages RUN pip install --no-cache-dir swarm-models swarms +RUN pip install transformers torch litellm tiktoken openai pandas numpy pypdf + # Production stage FROM python:3.11-slim-bullseye diff --git a/pyproject.toml b/pyproject.toml index f63108343..f8061da3c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "swarms" -version = "7.0.1" +version = "7.0.3" description = "Swarms - TGSC" license = "MIT" authors = ["Kye Gomez "] diff --git a/simple_example.py b/simple_example.py index 0d6166a32..7f8aff8f2 100644 --- a/simple_example.py +++ b/simple_example.py @@ -2,8 +2,8 @@ Agent( agent_name="Stock-Analysis-Agent", - model_name="gpt-4o-mini", + model_name="groq/deepseek-r1-distill-llama-70b", max_loops="auto", interactive=True, - streaming_on=True, -).run("What are 5 hft algorithms") + streaming_on=False, +).run("What are the best ways to analyze macroeconomic data?") diff --git a/swarms/agents/tool_agent.py b/swarms/agents/tool_agent.py index b686f3b0a..2d19ec262 100644 --- a/swarms/agents/tool_agent.py +++ b/swarms/agents/tool_agent.py @@ -1,12 +1,10 @@ from typing import Any, Optional, Callable from swarms.tools.json_former import Jsonformer from swarms.utils.loguru_logger import initialize_logger -from swarms.utils.lazy_loader import lazy_import_decorator logger = initialize_logger(log_folder="tool_agent") -@lazy_import_decorator class ToolAgent: """ Represents a tool agent that performs a specific task using a model and tokenizer. diff --git a/swarms/structs/agent.py b/swarms/structs/agent.py index e0427d44d..c242c59cf 100644 --- a/swarms/structs/agent.py +++ b/swarms/structs/agent.py @@ -563,7 +563,7 @@ def __init__( max_loops=self.max_loops, steps=self.short_memory.to_dict(), full_history=self.short_memory.get_str(), - total_tokens=count_tokens(self.short_memory.get_str()), + total_tokens=count_tokens(text=self.short_memory.get_str()), stopping_token=self.stopping_token, interactive=self.interactive, dynamic_temperature_enabled=self.dynamic_temperature_enabled, diff --git a/swarms/structs/swarm_matcher.py b/swarms/structs/swarm_matcher.py index d1594c951..32f5c834d 100644 --- a/swarms/structs/swarm_matcher.py +++ b/swarms/structs/swarm_matcher.py @@ -8,7 +8,6 @@ from swarms.utils.auto_download_check_packages import ( auto_check_and_download_package, ) -from swarms.utils.lazy_loader import lazy_import_decorator from swarms.utils.loguru_logger import initialize_logger logger = initialize_logger(log_folder="swarm_matcher") @@ -29,7 +28,6 @@ class SwarmMatcherConfig(BaseModel): ) -@lazy_import_decorator class SwarmMatcher: """ A class for matching tasks to swarm types based on their descriptions. @@ -271,7 +269,6 @@ def initialize_swarm_types(matcher: SwarmMatcher): logger.debug("Swarm types initialized") -@lazy_import_decorator def swarm_matcher(task: str, *args, **kwargs): """ Runs the SwarmMatcher example with predefined tasks and swarm types. diff --git a/swarms/tools/json_former.py b/swarms/tools/json_former.py index f4dde3871..fb24566bb 100644 --- a/swarms/tools/json_former.py +++ b/swarms/tools/json_former.py @@ -1,7 +1,6 @@ import json from typing import Any, Dict, List, Union -from swarms.utils.lazy_loader import lazy_import_decorator from pydantic import BaseModel from swarms.tools.logits_processor import ( NumberStoppingCriteria, @@ -24,7 +23,6 @@ GENERATION_MARKER = "|GENERATION|" -@lazy_import_decorator class Jsonformer: """ Initializes the FormatTools class. diff --git a/swarms/utils/litellm_tokenizer.py b/swarms/utils/litellm_tokenizer.py index 2d7cae4c7..8bfc34402 100644 --- a/swarms/utils/litellm_tokenizer.py +++ b/swarms/utils/litellm_tokenizer.py @@ -6,7 +6,8 @@ def count_tokens(text: str, model: str = "gpt-4o") -> int: try: from litellm import encode except ImportError: - subprocess.run(["pip", "install", "litellm"]) + import sys + subprocess.run([sys.executable, "-m", "pip", "install", "litellm"]) from litellm import encode return len(encode(model=model, text=text)) diff --git a/swarms/utils/pdf_to_text.py b/swarms/utils/pdf_to_text.py index 8df8e0659..74d79cade 100644 --- a/swarms/utils/pdf_to_text.py +++ b/swarms/utils/pdf_to_text.py @@ -4,8 +4,9 @@ import pypdf except ImportError: import subprocess + import sys - subprocess.check_call(["python", "-m", "pip", "install", "pypdf"]) + subprocess.check_call([sys.executable, "-m", "pip", "install", "pypdf"]) import pypdf