Skip to content

Commit

Permalink
[CLEANUP]
Browse files Browse the repository at this point in the history
  • Loading branch information
kyegomez committed Dec 27, 2024
1 parent 75b1968 commit 17e2933
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 27 deletions.
2 changes: 0 additions & 2 deletions api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@

from swarms.structs.agent import Agent

# Original API, drafting OpenTelemetry Integrations in this directory

# Load environment variables
load_dotenv()

Expand Down
12 changes: 9 additions & 3 deletions api/skypilot.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: agentapi

service:
readiness_probe:
path: /docs
Expand All @@ -11,14 +13,19 @@ service:
upscale_delay_seconds: 180
downscale_delay_seconds: 600


envs:
WORKSPACE_DIR: "agent_workspace"
OPENAI_API_KEY: ""

resources:
ports: 8000 # FastAPI default port
cpus: 16
memory: 64
disk_size: 100
disk_size: 50
use_spot: true

workdir: /app
workdir: .

setup: |
git clone https://github.com/kyegomez/swarms.git
Expand All @@ -27,7 +34,6 @@ setup: |
pip install swarms
run: |
cd swarms/api
uvicorn main:app --host 0.0.0.0 --port 8000 --workers 4
# env:
Expand Down
13 changes: 6 additions & 7 deletions api/tests.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import asyncio
import json
import uuid
from datetime import datetime
import aiohttp
import os
import sys
from typing import Dict, Any, Optional
from typing import Any, Dict

import aiohttp
from loguru import logger
import os

# Configure loguru
LOG_PATH = "api_tests.log"
Expand All @@ -17,7 +16,7 @@
level="DEBUG"
)

BASE_URL = "https://dev.api.swarms.ai/v1" # Change this to match your server URL
BASE_URL = "https://api.swarms.ai/v1" # Change this to match your server URL

async def log_request_details(method: str, url: str, headers: dict, data: Any = None):
"""Log request details before sending."""
Expand Down Expand Up @@ -249,7 +248,7 @@ def main():
asyncio.run(run_tests())
except KeyboardInterrupt:
logger.warning("Test execution interrupted by user.")
except Exception as e:
except Exception:
logger.exception("Fatal error in test execution:")
finally:
logger.info("Test suite shutdown complete.")
Expand Down
4 changes: 2 additions & 2 deletions docs/swarms/structs/group_chat.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ A production-grade multi-agent system enabling sophisticated group conversations
| description | str | "" | Purpose description |
| agents | List[Agent] | [] | Participating agents |
| speaker_fn | Callable | round_robin | Speaker selection function |
| max_turns | int | 10 | Maximum conversation turns |
| max_loops | int | 10 | Maximum conversation turns |


## Table of Contents
Expand Down Expand Up @@ -272,7 +272,7 @@ analysis_team = GroupChat(
description="Comprehensive market analysis group",
agents=[data_analyst, market_expert, strategy_advisor],
speaker_fn=expertise_based,
max_turns=15
max_loops=15
)

# Run complex analysis
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions new_features_examples/multi_tool_usage_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ class ExecutionContext:
history: List[Dict[str, Any]] = field(default_factory=list)


def func():
pass

hints = get_type_hints(func)


Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions swarms/structs/async_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class SpeakerMessage(BaseModel):


class GroupChatConfig(BaseModel):
max_turns: int = 10
max_loops: int = 10
timeout_per_turn: float = 30.0
require_all_speakers: bool = False
allow_concurrent: bool = True
Expand Down Expand Up @@ -309,7 +309,7 @@ async def run_group_chat(
messages: List[SpeakerMessage] = []
current_turn = 0

while current_turn < self.group_chat_config.max_turns:
while current_turn < self.group_chat_config.max_loops:
turn_context = {
"turn": current_turn,
"history": messages,
Expand Down Expand Up @@ -627,7 +627,7 @@ def create_default_workflow(
verbose=True,
enable_group_chat=enable_group_chat,
group_chat_config=GroupChatConfig(
max_turns=5,
max_loops=5,
allow_concurrent=True,
require_all_speakers=False,
),
Expand Down
8 changes: 4 additions & 4 deletions swarms/structs/groupchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def __init__(
description: str = "A group chat for multiple agents",
agents: List[Agent] = [],
speaker_fn: SpeakerFunction = round_robin,
max_turns: int = 10,
max_loops: int = 10,
):
"""
Initialize the GroupChat.
Expand All @@ -133,13 +133,13 @@ def __init__(
description (str): Description of the purpose of the group chat.
agents (List[Agent]): A list of agents participating in the chat.
speaker_fn (SpeakerFunction): The function to determine which agent should speak next.
max_turns (int): Maximum number of turns in the chat.
max_loops (int): Maximum number of turns in the chat.
"""
self.name = name
self.description = description
self.agents = agents
self.speaker_fn = speaker_fn
self.max_turns = max_turns
self.max_loops = max_loops
self.chat_history = ChatHistory(
turns=[],
total_messages=0,
Expand Down Expand Up @@ -237,7 +237,7 @@ def run(self, task: str) -> ChatHistory:
f"Starting chat '{self.name}' with task: {task}"
)

for turn in range(self.max_turns):
for turn in range(self.max_loops):
current_turn = ChatTurn(
turn_number=turn, responses=[], task=task
)
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions tests/structs/test_groupchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ def test_expertise_based_speaking():
assert first_response.agent_name == agent.agent_name


def test_max_turns_limit():
max_turns = 3
chat = GroupChat(agents=setup_test_agents(), max_turns=max_turns)
def test_max_loops_limit():
max_loops = 3
chat = GroupChat(agents=setup_test_agents(), max_loops=max_loops)
history = chat.run("Test message")

assert len(history.turns) == max_turns
assert len(history.turns) == max_loops


def test_error_handling():
Expand Down Expand Up @@ -106,7 +106,7 @@ def test_large_agent_group():


def test_long_conversations():
chat = GroupChat(agents=setup_test_agents(), max_turns=50)
chat = GroupChat(agents=setup_test_agents(), max_loops=50)
history = chat.run("Long conversation test")

assert len(history.turns) == 50
Expand All @@ -130,7 +130,7 @@ def test_stress_batched_runs():
test_round_robin_speaking,
test_concurrent_processing,
test_expertise_based_speaking,
test_max_turns_limit,
test_max_loops_limit,
test_error_handling,
test_conversation_context,
test_large_agent_group,
Expand Down

0 comments on commit 17e2933

Please sign in to comment.