pull/707/head
Kye Gomez 4 months ago
parent 75b196862f
commit 17e2933b29

@ -29,8 +29,6 @@ from pydantic import BaseModel, Field
from swarms.structs.agent import Agent
# Original API, drafting OpenTelemetry Integrations in this directory
# Load environment variables
load_dotenv()

@ -1,3 +1,5 @@
name: agentapi
service:
readiness_probe:
path: /docs
@ -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
@ -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:

@ -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"
@ -17,7 +16,7 @@ logger.add(LOG_PATH,
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."""
@ -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.")

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

@ -111,6 +111,9 @@ class ExecutionContext:
history: List[Dict[str, Any]] = field(default_factory=list)
def func():
pass
hints = get_type_hints(func)

@ -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
@ -309,7 +309,7 @@ class AsyncWorkflow(BaseWorkflow):
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,
@ -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,
),

@ -123,7 +123,7 @@ class GroupChat:
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.
@ -133,13 +133,13 @@ class GroupChat:
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,
@ -237,7 +237,7 @@ class GroupChat:
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
)

@ -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():
@ -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
@ -130,7 +130,7 @@ if __name__ == "__main__":
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,

Loading…
Cancel
Save