Skip to content

Commit

Permalink
[7.1.2] - many files deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
kyegomez committed Feb 5, 2025
1 parent 2e6b2df commit 0a39f2d
Show file tree
Hide file tree
Showing 29 changed files with 530 additions and 1,298 deletions.
34 changes: 34 additions & 0 deletions majority_voting_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from swarms import Agent
from swarms.prompts.finance_agent_sys_prompt import (
FINANCIAL_AGENT_SYS_PROMPT,
)
from swarms.structs.majority_voting import MajorityVoting
from dotenv import load_dotenv

load_dotenv()


# Initialize the agent
agent = Agent(
agent_name="Financial-Analysis-Agent",
agent_description="Personal finance advisor agent",
system_prompt=FINANCIAL_AGENT_SYS_PROMPT,
max_loops=1,
model_name="gpt-4o",
dynamic_temperature_enabled=True,
user_name="swarms_corp",
retry_attempts=3,
context_length=8192,
return_step_meta=False,
output_type="str", # "json", "dict", "csv" OR "string" "yaml" and
auto_generate_prompt=False, # Auto generate prompt for the agent based on name, description, and system prompt, task
max_tokens=4000, # max output tokens
saved_state_path="agent_00.json",
interactive=False,
)

swarm = MajorityVoting(agents=[agent, agent, agent])

swarm.run(
"Create a table of super high growth opportunities for AI. I have $40k to invest in ETFs, index funds, and more. Please create a table in markdown.",
)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "swarms"
version = "7.1.1"
version = "7.1.2"
description = "Swarms - TGSC"
license = "MIT"
authors = ["Kye Gomez <[email protected]>"]
Expand Down
18 changes: 18 additions & 0 deletions swarms/agents/openai_assistant.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from concurrent.futures import ThreadPoolExecutor
import json
import os
import subprocess
Expand Down Expand Up @@ -316,3 +317,20 @@ def run(self, task: str, *args, **kwargs) -> str:
def call(self, task: str, *args, **kwargs) -> str:
"""Alias for run() to maintain compatibility with different agent interfaces."""
return self.run(task, *args, **kwargs)

def batch_run(
self, tasks: List[str], *args, **kwargs
) -> List[Any]:
"""Run a batch of tasks using the OpenAI Assistant."""
return [self.run(task, *args, **kwargs) for task in tasks]

def run_concurrently(
self, tasks: List[str], *args, **kwargs
) -> List[Any]:
"""Run a batch of tasks concurrently using the OpenAI Assistant."""
with ThreadPoolExecutor(
max_workers=os.cpu_count()
) as executor:
return list(
executor.map(self.run, tasks, *args, **kwargs)
)
2 changes: 1 addition & 1 deletion swarms/cli/onboarding_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from swarms.utils.loguru_logger import initialize_logger


from swarms.telemetry.capture_sys_data import (
from swarms.telemetry.main import (
capture_system_data,
log_agent_data,
)
Expand Down
2 changes: 1 addition & 1 deletion swarms/prompts/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
)
from pydantic.v1 import validator

from swarms.telemetry.capture_sys_data import (
from swarms.telemetry.main import (
capture_system_data,
log_agent_data,
)
Expand Down
17 changes: 1 addition & 16 deletions swarms/structs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,7 @@
star_swarm,
)
from swarms.structs.task import Task
from swarms.structs.utils import (
detect_markdown,
distribute_tasks,
extract_key_from_json,
extract_tokens_from_text,
find_agent_by_id,
find_token_in_text,
parse_tasks,
)


__all__ = [
"Agent",
Expand All @@ -107,13 +99,6 @@
"RoundRobinSwarm",
"SequentialWorkflow",
"Task",
"detect_markdown",
"distribute_tasks",
"extract_key_from_json",
"extract_tokens_from_text",
"find_agent_by_id",
"find_token_in_text",
"parse_tasks",
"MixtureOfAgents",
"GraphWorkflow",
"Node",
Expand Down
2 changes: 1 addition & 1 deletion swarms/structs/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
from swarms.utils.wrapper_clusterop import (
exec_callable_with_clusterops,
)
from swarms.telemetry.capture_sys_data import log_agent_data
from swarms.telemetry.main import log_agent_data
from swarms.agents.agent_print import agent_print
from swarms.utils.litellm_tokenizer import count_tokens

Expand Down
Loading

0 comments on commit 0a39f2d

Please sign in to comment.