open-swarm 0.1.1745125921__py3-none-any.whl → 0.1.1745125927__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {open_swarm-0.1.1745125921.dist-info → open_swarm-0.1.1745125927.dist-info}/METADATA +1 -1
- {open_swarm-0.1.1745125921.dist-info → open_swarm-0.1.1745125927.dist-info}/RECORD +5 -12
- swarm/blueprints/family_ties/apps.py +0 -11
- swarm/blueprints/family_ties/blueprint_family_ties.py +0 -189
- swarm/blueprints/family_ties/models.py +0 -19
- swarm/blueprints/family_ties/serializers.py +0 -7
- swarm/blueprints/family_ties/settings.py +0 -16
- swarm/blueprints/family_ties/urls.py +0 -10
- swarm/blueprints/family_ties/views.py +0 -26
- {open_swarm-0.1.1745125921.dist-info → open_swarm-0.1.1745125927.dist-info}/WHEEL +0 -0
- {open_swarm-0.1.1745125921.dist-info → open_swarm-0.1.1745125927.dist-info}/entry_points.txt +0 -0
- {open_swarm-0.1.1745125921.dist-info → open_swarm-0.1.1745125927.dist-info}/licenses/LICENSE +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: open-swarm
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.1745125927
|
4
4
|
Summary: Open Swarm: Orchestrating AI Agent Swarms with Django
|
5
5
|
Project-URL: Homepage, https://github.com/yourusername/open-swarm
|
6
6
|
Project-URL: Documentation, https://github.com/yourusername/open-swarm/blob/main/README.md
|
@@ -32,13 +32,6 @@ swarm/blueprints/django_chat/urls.py,sha256=TTTF3pgymvCYbuxpwi4WRBPv8ftQNH4pEoUR
|
|
32
32
|
swarm/blueprints/django_chat/views.py,sha256=MUKjXXjXsq8jMZtAb4RR9g2mEYrwFemN6Bqxpeyi7p4,1299
|
33
33
|
swarm/blueprints/django_chat/templates/django_chat/django_chat_webpage.html,sha256=wAEOI4Wg0JJ8drXaOcr2Pel6lW3JSHmyIpbocLS5tI8,1649
|
34
34
|
swarm/blueprints/echocraft/blueprint_echocraft.py,sha256=9XNyuMZIBrm9kpnv1aq_W3h-9Zr2dVdzchI2uFXslg0,10988
|
35
|
-
swarm/blueprints/family_ties/apps.py,sha256=EjV7AxDNsLM4gsLr_qMEiLAVbERuo1ZsdU9vPtOEYAY,287
|
36
|
-
swarm/blueprints/family_ties/blueprint_family_ties.py,sha256=AkYz9_O7QSBhoZAG1jaFlTXEouL1eUfa0y6hw9MqSro,9762
|
37
|
-
swarm/blueprints/family_ties/models.py,sha256=C3_okdVVYuu9xOpoKRsaLoGrM2775cS_cU4UKYAkJ9s,903
|
38
|
-
swarm/blueprints/family_ties/serializers.py,sha256=kH3T6OgXjF534bO3gfAUr6GpXZ5Jx0BQkK58nvuEcqA,325
|
39
|
-
swarm/blueprints/family_ties/settings.py,sha256=5zcVsq7ny3GLWcJnOplZW4fMFNtyC3ba0ZOESRD2gh4,425
|
40
|
-
swarm/blueprints/family_ties/urls.py,sha256=awRZHb1gb1p3I6YZzfKMGSydd6kYPTLgax2jZ1ocS4U,294
|
41
|
-
swarm/blueprints/family_ties/views.py,sha256=FbPkDNlFEixtRFbSpkr51IyJ28FRkXa1W5xyO_KeXH0,1081
|
42
35
|
swarm/blueprints/flock/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
43
36
|
swarm/blueprints/geese/blueprint_geese.py,sha256=uP0gPHFACI18a_cY5f89ndqccNrK3YxjQPgA85T8Cms,9339
|
44
37
|
swarm/blueprints/mcp_demo/blueprint_mcp_demo.py,sha256=bTHupSUdg9OzaRoTu9obGsxk48f9o3wUCLqVWeWYW-w,17695
|
@@ -278,8 +271,8 @@ swarm/views/message_views.py,sha256=sDUnXyqKXC8WwIIMAlWf00s2_a2T9c75Na5FvYMJwBM,
|
|
278
271
|
swarm/views/model_views.py,sha256=aAbU4AZmrOTaPeKMWtoKK7FPYHdaN3Zbx55JfKzYTRY,2937
|
279
272
|
swarm/views/utils.py,sha256=8Usc0g0L0NPegNAyY20tJBNBy-JLwODf4VmxV0yUtpw,3627
|
280
273
|
swarm/views/web_views.py,sha256=T1CKe-Nyv1C8aDt6QFTGWo_dkH7ojWAvS_QW9mZnZp0,7371
|
281
|
-
open_swarm-0.1.
|
282
|
-
open_swarm-0.1.
|
283
|
-
open_swarm-0.1.
|
284
|
-
open_swarm-0.1.
|
285
|
-
open_swarm-0.1.
|
274
|
+
open_swarm-0.1.1745125927.dist-info/METADATA,sha256=AjVBunlRv-LH1Al4Uq4n8OAcX0z_cwCsF31SqMCqoN0,26977
|
275
|
+
open_swarm-0.1.1745125927.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
276
|
+
open_swarm-0.1.1745125927.dist-info/entry_points.txt,sha256=fo28d0_zJrytRsh8QqkdlWQT_9lyAwYUx1WuSTDI3HM,177
|
277
|
+
open_swarm-0.1.1745125927.dist-info/licenses/LICENSE,sha256=BU9bwRlnOt_JDIb6OT55Q4leLZx9RArDLTFnlDIrBEI,1062
|
278
|
+
open_swarm-0.1.1745125927.dist-info/RECORD,,
|
@@ -1,11 +0,0 @@
|
|
1
|
-
from django.apps import AppConfig
|
2
|
-
import logging
|
3
|
-
|
4
|
-
logger = logging.getLogger(__name__)
|
5
|
-
|
6
|
-
class FamilyTiesConfig(AppConfig):
|
7
|
-
name = 'blueprints.family_ties'
|
8
|
-
verbose_name = "Family Ties Blueprint"
|
9
|
-
|
10
|
-
def ready(self):
|
11
|
-
logger.debug(f"Registering {self.name} via AppConfig")
|
@@ -1,189 +0,0 @@
|
|
1
|
-
import logging
|
2
|
-
import os
|
3
|
-
import sys
|
4
|
-
from typing import Dict, Any, List, ClassVar, Optional
|
5
|
-
|
6
|
-
# Ensure src is in path for BlueprintBase import
|
7
|
-
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
|
8
|
-
src_path = os.path.join(project_root, 'src')
|
9
|
-
if src_path not in sys.path: sys.path.insert(0, src_path)
|
10
|
-
|
11
|
-
from typing import Optional
|
12
|
-
from pathlib import Path
|
13
|
-
try:
|
14
|
-
from agents import Agent, Tool, function_tool, Runner
|
15
|
-
from agents.mcp import MCPServer
|
16
|
-
from agents.models.interface import Model
|
17
|
-
from agents.models.openai_chatcompletions import OpenAIChatCompletionsModel
|
18
|
-
from openai import AsyncOpenAI
|
19
|
-
from swarm.core.blueprint_base import BlueprintBase
|
20
|
-
except ImportError as e:
|
21
|
-
print(f"ERROR: Import failed in FamilyTiesBlueprint: {e}. Check dependencies.")
|
22
|
-
print(f"sys.path: {sys.path}")
|
23
|
-
sys.exit(1)
|
24
|
-
|
25
|
-
logger = logging.getLogger(__name__)
|
26
|
-
|
27
|
-
# --- Agent Instructions ---
|
28
|
-
# Keep instructions defined globally for clarity
|
29
|
-
|
30
|
-
SHARED_INSTRUCTIONS = """
|
31
|
-
You are part of the Grifton family WordPress team. Peter coordinates, Brian manages WordPress.
|
32
|
-
Roles:
|
33
|
-
- PeterGrifton (Coordinator): User interface, planning, delegates WP tasks via `BrianGrifton` Agent Tool.
|
34
|
-
- BrianGrifton (WordPress Manager): Uses `server-wp-mcp` MCP tool (likely function `wp_call_endpoint`) to manage content based on Peter's requests.
|
35
|
-
Respond ONLY to the agent who tasked you.
|
36
|
-
"""
|
37
|
-
|
38
|
-
peter_instructions = (
|
39
|
-
f"{SHARED_INSTRUCTIONS}\n\n"
|
40
|
-
"YOUR ROLE: PeterGrifton, Coordinator. You handle user requests about WordPress.\n"
|
41
|
-
"1. Understand the user's goal (create post, edit post, list sites, etc.).\n"
|
42
|
-
"2. Delegate the task to Brian using the `BrianGrifton` agent tool.\n"
|
43
|
-
"3. Provide ALL necessary details to Brian (content, title, site ID, endpoint details if known, method like GET/POST).\n"
|
44
|
-
"4. Relay Brian's response (success, failure, IDs, data) back to the user clearly."
|
45
|
-
)
|
46
|
-
|
47
|
-
brian_instructions = (
|
48
|
-
f"{SHARED_INSTRUCTIONS}\n\n"
|
49
|
-
"YOUR ROLE: BrianGrifton, WordPress Manager. You interact with WordPress sites via the `server-wp-mcp` tool.\n"
|
50
|
-
"1. Receive tasks from Peter.\n"
|
51
|
-
"2. Determine the correct WordPress REST API endpoint and parameters required (e.g., `site`, `endpoint`, `method`, `params`).\n"
|
52
|
-
"3. Call the MCP tool function (likely named `wp_call_endpoint` or similar provided by the MCP server) with the correct JSON arguments.\n"
|
53
|
-
"4. Report the outcome (success confirmation, data returned, or error message) precisely back to Peter."
|
54
|
-
)
|
55
|
-
|
56
|
-
# --- Define the Blueprint ---
|
57
|
-
class FamilyTiesBlueprint(BlueprintBase):
|
58
|
-
def __init__(self, blueprint_id: str, config_path: Optional[Path] = None, **kwargs):
|
59
|
-
super().__init__(blueprint_id, config_path=config_path, **kwargs)
|
60
|
-
|
61
|
-
"""Manages WordPress content with a Peter/Brian agent team using the `server-wp-mcp` server."""
|
62
|
-
metadata: ClassVar[Dict[str, Any]] = {
|
63
|
-
"name": "FamilyTiesBlueprint", # Standardized name
|
64
|
-
"title": "Family Ties / ChaosCrew WP Manager",
|
65
|
-
"description": "Manages WordPress content using Peter (coordinator) and Brian (WP manager via MCP).",
|
66
|
-
"version": "1.2.0", # Incremented version
|
67
|
-
"author": "Open Swarm Team (Refactored)",
|
68
|
-
"tags": ["wordpress", "cms", "multi-agent", "mcp"],
|
69
|
-
"required_mcp_servers": ["server-wp-mcp"], # Brian needs this
|
70
|
-
"env_vars": ["WP_SITES_PATH"] # Informational: MCP server needs this
|
71
|
-
}
|
72
|
-
|
73
|
-
# Caches
|
74
|
-
_openai_client_cache: Dict[str, AsyncOpenAI] = {}
|
75
|
-
_model_instance_cache: Dict[str, Model] = {}
|
76
|
-
|
77
|
-
# --- Model Instantiation Helper --- (Standard helper)
|
78
|
-
def _get_model_instance(self, profile_name: str) -> Model:
|
79
|
-
"""Retrieves or creates an LLM Model instance."""
|
80
|
-
# ... (Implementation is the same as in previous refactors) ...
|
81
|
-
if profile_name in self._model_instance_cache:
|
82
|
-
logger.debug(f"Using cached Model instance for profile '{profile_name}'.")
|
83
|
-
return self._model_instance_cache[profile_name]
|
84
|
-
logger.debug(f"Creating new Model instance for profile '{profile_name}'.")
|
85
|
-
profile_data = self.get_llm_profile(profile_name)
|
86
|
-
if not profile_data:
|
87
|
-
logger.critical(f"LLM profile '{profile_name}' (or 'default') not found.")
|
88
|
-
raise ValueError(f"Missing LLM profile configuration for '{profile_name}' or 'default'.")
|
89
|
-
provider = profile_data.get("provider", "openai").lower()
|
90
|
-
model_name = profile_data.get("model")
|
91
|
-
if not model_name:
|
92
|
-
logger.critical(f"LLM profile '{profile_name}' missing 'model' key.")
|
93
|
-
raise ValueError(f"Missing 'model' key in LLM profile '{profile_name}'.")
|
94
|
-
if provider != "openai":
|
95
|
-
logger.error(f"Unsupported LLM provider '{provider}'.")
|
96
|
-
raise ValueError(f"Unsupported LLM provider: {provider}")
|
97
|
-
client_cache_key = f"{provider}_{profile_data.get('base_url')}"
|
98
|
-
if client_cache_key not in self._openai_client_cache:
|
99
|
-
client_kwargs = { "api_key": profile_data.get("api_key"), "base_url": profile_data.get("base_url") }
|
100
|
-
filtered_kwargs = {k: v for k, v in client_kwargs.items() if v is not None}
|
101
|
-
log_kwargs = {k:v for k,v in filtered_kwargs.items() if k != 'api_key'}
|
102
|
-
logger.debug(f"Creating new AsyncOpenAI client for '{profile_name}': {log_kwargs}")
|
103
|
-
try: self._openai_client_cache[client_cache_key] = AsyncOpenAI(**filtered_kwargs)
|
104
|
-
except Exception as e: raise ValueError(f"Failed to init OpenAI client: {e}") from e
|
105
|
-
client = self._openai_client_cache[client_cache_key]
|
106
|
-
logger.debug(f"Instantiating OpenAIChatCompletionsModel(model='{model_name}') for '{profile_name}'.")
|
107
|
-
try:
|
108
|
-
model_instance = OpenAIChatCompletionsModel(model=model_name, openai_client=client)
|
109
|
-
self._model_instance_cache[profile_name] = model_instance
|
110
|
-
return model_instance
|
111
|
-
except Exception as e: raise ValueError(f"Failed to init LLM provider: {e}") from e
|
112
|
-
|
113
|
-
def create_starting_agent(self, mcp_servers: List[MCPServer]) -> Agent:
|
114
|
-
"""Creates the Family Ties agent team and returns PeterGrifton (Coordinator)."""
|
115
|
-
logger.debug("Creating Family Ties agent team...")
|
116
|
-
self._model_instance_cache = {}
|
117
|
-
self._openai_client_cache = {}
|
118
|
-
|
119
|
-
default_profile_name = self.config.get("llm_profile", "default")
|
120
|
-
logger.debug(f"Using LLM profile '{default_profile_name}' for Family Ties agents.")
|
121
|
-
model_instance = self._get_model_instance(default_profile_name)
|
122
|
-
|
123
|
-
# Filter for the required MCP server
|
124
|
-
wp_mcp_server = next((s for s in mcp_servers if s.name == "server-wp-mcp"), None)
|
125
|
-
if not wp_mcp_server:
|
126
|
-
# This case should be prevented by BlueprintBase MCP check, but good practice
|
127
|
-
logger.error("Required MCP server 'server-wp-mcp' not found/started. Brian will be non-functional.")
|
128
|
-
# Optionally raise an error or allow degraded functionality
|
129
|
-
# raise ValueError("Critical MCP server 'server-wp-mcp' failed to start.")
|
130
|
-
|
131
|
-
# Instantiate Brian, passing the specific MCP server
|
132
|
-
brian_agent = Agent(
|
133
|
-
name="BrianGrifton",
|
134
|
-
model=model_instance,
|
135
|
-
instructions=brian_instructions,
|
136
|
-
tools=[], # Brian uses MCP tools provided by the server
|
137
|
-
mcp_servers=[wp_mcp_server] if wp_mcp_server else []
|
138
|
-
)
|
139
|
-
|
140
|
-
# Instantiate Peter, giving Brian as a tool
|
141
|
-
peter_agent = Agent(
|
142
|
-
name="PeterGrifton",
|
143
|
-
model=model_instance,
|
144
|
-
instructions=peter_instructions,
|
145
|
-
tools=[
|
146
|
-
brian_agent.as_tool(
|
147
|
-
tool_name="BrianGrifton",
|
148
|
-
tool_description="Delegate WordPress tasks (create/edit/list posts/sites, etc.) to Brian."
|
149
|
-
)
|
150
|
-
],
|
151
|
-
mcp_servers=[] # Peter doesn't directly use MCPs
|
152
|
-
)
|
153
|
-
logger.debug("Agents created: PeterGrifton (Coordinator), BrianGrifton (WordPress Manager).")
|
154
|
-
return peter_agent # Peter is the entry point
|
155
|
-
|
156
|
-
async def run(self, messages: List[Dict[str, Any]], **kwargs) -> Any:
|
157
|
-
"""Main execution entry point for the FamilyTies blueprint."""
|
158
|
-
logger.info("FamilyTiesBlueprint run method called.")
|
159
|
-
instruction = messages[-1].get("content", "") if messages else ""
|
160
|
-
async for chunk in self._run_non_interactive(instruction, **kwargs):
|
161
|
-
yield chunk
|
162
|
-
logger.info("FamilyTiesBlueprint run method finished.")
|
163
|
-
|
164
|
-
async def _run_non_interactive(self, instruction: str, **kwargs) -> Any:
|
165
|
-
logger.info(f"Running FamilyTies non-interactively with instruction: '{instruction[:100]}...'")
|
166
|
-
mcp_servers = kwargs.get("mcp_servers", [])
|
167
|
-
agent = self.create_starting_agent(mcp_servers=mcp_servers)
|
168
|
-
# Use Runner.run as a classmethod for portability
|
169
|
-
from agents import Runner
|
170
|
-
import os
|
171
|
-
model_name = os.getenv("LITELLM_MODEL") or os.getenv("DEFAULT_LLM") or "gpt-3.5-turbo"
|
172
|
-
try:
|
173
|
-
for chunk in Runner.run(agent, instruction):
|
174
|
-
yield chunk
|
175
|
-
except Exception as e:
|
176
|
-
logger.error(f"Error during non-interactive run: {e}", exc_info=True)
|
177
|
-
yield {"messages": [{"role": "assistant", "content": f"An error occurred: {e}"}]}
|
178
|
-
|
179
|
-
if __name__ == "__main__":
|
180
|
-
import asyncio
|
181
|
-
import json
|
182
|
-
messages = [
|
183
|
-
{"role": "user", "content": "Who are my relatives?"}
|
184
|
-
]
|
185
|
-
blueprint = FamilyTiesBlueprint(blueprint_id="demo-1")
|
186
|
-
async def run_and_print():
|
187
|
-
async for response in blueprint.run(messages):
|
188
|
-
print(json.dumps(response, indent=2))
|
189
|
-
asyncio.run(run_and_print())
|
@@ -1,19 +0,0 @@
|
|
1
|
-
from django.db import models
|
2
|
-
|
3
|
-
class AgentInstruction(models.Model):
|
4
|
-
agent_name = models.CharField(max_length=50, unique=True, help_text="Unique name (e.g., 'PeterGriffin').")
|
5
|
-
instruction_text = models.TextField(help_text="Instructions for the agent.")
|
6
|
-
model = models.CharField(max_length=50, default="default", help_text="LLM model.")
|
7
|
-
env_vars = models.TextField(blank=True, null=True, help_text="JSON env variables.")
|
8
|
-
mcp_servers = models.TextField(blank=True, null=True, help_text="JSON MCP servers.")
|
9
|
-
created_at = models.DateTimeField(auto_now_add=True)
|
10
|
-
updated_at = models.DateTimeField(auto_now=True)
|
11
|
-
|
12
|
-
class Meta:
|
13
|
-
app_label = "blueprints_chc"
|
14
|
-
db_table = "swarm_agent_instruction_chc"
|
15
|
-
verbose_name = "Agent Instruction"
|
16
|
-
verbose_name_plural = "Agent Instructions"
|
17
|
-
|
18
|
-
def __str__(self):
|
19
|
-
return f"{self.agent_name} Instruction"
|
@@ -1,7 +0,0 @@
|
|
1
|
-
from rest_framework import serializers
|
2
|
-
from blueprints.chc.models import AgentInstruction
|
3
|
-
|
4
|
-
class AgentInstructionSerializer(serializers.ModelSerializer):
|
5
|
-
class Meta:
|
6
|
-
model = AgentInstruction
|
7
|
-
fields = ['id', 'agent_name', 'instruction_text', 'model', 'env_vars', 'mcp_servers', 'created_at', 'updated_at']
|
@@ -1,16 +0,0 @@
|
|
1
|
-
import logging
|
2
|
-
from django.apps import AppConfig
|
3
|
-
|
4
|
-
logger = logging.getLogger(__name__)
|
5
|
-
|
6
|
-
def update_installed_apps(settings):
|
7
|
-
blueprint_app = "blueprints.chc"
|
8
|
-
if blueprint_app not in settings.get("INSTALLED_APPS", []):
|
9
|
-
settings["INSTALLED_APPS"].append(blueprint_app)
|
10
|
-
|
11
|
-
try:
|
12
|
-
update_installed_apps(globals())
|
13
|
-
except Exception as e:
|
14
|
-
logger.error("CHC update failed: %s", e)
|
15
|
-
|
16
|
-
CORS_ALLOW_ALL_ORIGINS = True
|
@@ -1,10 +0,0 @@
|
|
1
|
-
from django.urls import path, include
|
2
|
-
from rest_framework.routers import DefaultRouter
|
3
|
-
from .views import AgentInstructionViewSet
|
4
|
-
|
5
|
-
router = DefaultRouter()
|
6
|
-
router.register(r'instructions', AgentInstructionViewSet, basename='instructions')
|
7
|
-
|
8
|
-
urlpatterns = [
|
9
|
-
path('', include(router.urls)),
|
10
|
-
]
|
@@ -1,26 +0,0 @@
|
|
1
|
-
from rest_framework.viewsets import ModelViewSet
|
2
|
-
from rest_framework.permissions import AllowAny
|
3
|
-
import os
|
4
|
-
from swarm.auth import EnvOrTokenAuthentication
|
5
|
-
from blueprints.chc.models import AgentInstruction
|
6
|
-
from blueprints.chc.serializers import AgentInstructionSerializer
|
7
|
-
|
8
|
-
class AgentInstructionViewSet(ModelViewSet):
|
9
|
-
authentication_classes = [EnvOrTokenAuthentication]
|
10
|
-
permission_classes = [AllowAny]
|
11
|
-
queryset = AgentInstruction.objects.all()
|
12
|
-
serializer_class = AgentInstructionSerializer
|
13
|
-
|
14
|
-
def get_permissions(self):
|
15
|
-
if os.getenv("ENABLE_API_AUTH", "false").lower() in ("true", "1", "t"):
|
16
|
-
from rest_framework.permissions import IsAuthenticated
|
17
|
-
return [IsAuthenticated()]
|
18
|
-
return [AllowAny()]
|
19
|
-
|
20
|
-
def perform_authentication(self, request):
|
21
|
-
super().perform_authentication(request)
|
22
|
-
if not request.user or not request.user.is_authenticated:
|
23
|
-
from rest_framework.exceptions import AuthenticationFailed
|
24
|
-
raise AuthenticationFailed("Invalid token.")
|
25
|
-
|
26
|
-
__all__ = ["AgentInstructionViewSet"]
|
File without changes
|
{open_swarm-0.1.1745125921.dist-info → open_swarm-0.1.1745125927.dist-info}/entry_points.txt
RENAMED
File without changes
|
{open_swarm-0.1.1745125921.dist-info → open_swarm-0.1.1745125927.dist-info}/licenses/LICENSE
RENAMED
File without changes
|