open-swarm 0.1.1743070217__py3-none-any.whl → 0.1.1743364176__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.1743364176.dist-info/METADATA +286 -0
- open_swarm-0.1.1743364176.dist-info/RECORD +260 -0
- {open_swarm-0.1.1743070217.dist-info → open_swarm-0.1.1743364176.dist-info}/WHEEL +1 -2
- open_swarm-0.1.1743364176.dist-info/entry_points.txt +2 -0
- swarm/__init__.py +0 -2
- swarm/auth.py +53 -49
- swarm/blueprints/README.md +67 -0
- swarm/blueprints/burnt_noodles/blueprint_burnt_noodles.py +412 -0
- swarm/blueprints/chatbot/blueprint_chatbot.py +98 -0
- swarm/blueprints/chatbot/templates/chatbot/chatbot.html +33 -0
- swarm/blueprints/digitalbutlers/blueprint_digitalbutlers.py +183 -0
- swarm/blueprints/dilbot_universe/blueprint_dilbot_universe.py +285 -0
- swarm/blueprints/divine_code/__init__.py +0 -0
- swarm/blueprints/divine_code/apps.py +11 -0
- swarm/blueprints/divine_code/blueprint_divine_code.py +219 -0
- swarm/blueprints/django_chat/apps.py +6 -0
- swarm/blueprints/django_chat/blueprint_django_chat.py +84 -0
- swarm/blueprints/django_chat/templates/django_chat/django_chat_webpage.html +37 -0
- swarm/blueprints/django_chat/urls.py +8 -0
- swarm/blueprints/django_chat/views.py +32 -0
- swarm/blueprints/echocraft/blueprint_echocraft.py +44 -0
- swarm/blueprints/family_ties/apps.py +11 -0
- swarm/blueprints/family_ties/blueprint_family_ties.py +152 -0
- swarm/blueprints/family_ties/models.py +19 -0
- swarm/blueprints/family_ties/serializers.py +7 -0
- swarm/blueprints/family_ties/settings.py +16 -0
- swarm/blueprints/family_ties/urls.py +10 -0
- swarm/blueprints/family_ties/views.py +26 -0
- swarm/blueprints/flock/__init__.py +0 -0
- swarm/blueprints/gaggle/blueprint_gaggle.py +184 -0
- swarm/blueprints/gotchaman/blueprint_gotchaman.py +232 -0
- swarm/blueprints/mcp_demo/blueprint_mcp_demo.py +133 -0
- swarm/blueprints/messenger/templates/messenger/messenger.html +46 -0
- swarm/blueprints/mission_improbable/blueprint_mission_improbable.py +234 -0
- swarm/blueprints/monkai_magic/blueprint_monkai_magic.py +248 -0
- swarm/blueprints/nebula_shellz/blueprint_nebula_shellz.py +156 -0
- swarm/blueprints/omniplex/blueprint_omniplex.py +221 -0
- swarm/blueprints/rue_code/__init__.py +0 -0
- swarm/blueprints/rue_code/blueprint_rue_code.py +291 -0
- swarm/blueprints/suggestion/blueprint_suggestion.py +110 -0
- swarm/blueprints/unapologetic_press/blueprint_unapologetic_press.py +298 -0
- swarm/blueprints/whiskeytango_foxtrot/__init__.py +0 -0
- swarm/blueprints/whiskeytango_foxtrot/apps.py +11 -0
- swarm/blueprints/whiskeytango_foxtrot/blueprint_whiskeytango_foxtrot.py +256 -0
- swarm/extensions/blueprint/__init__.py +30 -15
- swarm/extensions/blueprint/agent_utils.py +16 -40
- swarm/extensions/blueprint/blueprint_base.py +141 -543
- swarm/extensions/blueprint/blueprint_discovery.py +112 -98
- swarm/extensions/blueprint/cli_handler.py +185 -0
- swarm/extensions/blueprint/config_loader.py +122 -0
- swarm/extensions/blueprint/django_utils.py +181 -79
- swarm/extensions/blueprint/interactive_mode.py +1 -1
- swarm/extensions/config/config_loader.py +83 -200
- swarm/extensions/launchers/build_swarm_wrapper.py +0 -0
- swarm/extensions/launchers/swarm_cli.py +199 -287
- swarm/llm/chat_completion.py +26 -55
- swarm/management/__init__.py +0 -0
- swarm/management/commands/__init__.py +0 -0
- swarm/management/commands/runserver.py +58 -0
- swarm/permissions.py +38 -0
- swarm/serializers.py +96 -5
- swarm/settings.py +95 -110
- swarm/static/contrib/fonts/fontawesome-webfont.ttf +7 -0
- swarm/static/contrib/fonts/fontawesome-webfont.woff +7 -0
- swarm/static/contrib/fonts/fontawesome-webfont.woff2 +7 -0
- swarm/static/contrib/markedjs/marked.min.js +6 -0
- swarm/static/contrib/tabler-icons/adjustments-horizontal.svg +27 -0
- swarm/static/contrib/tabler-icons/alert-triangle.svg +21 -0
- swarm/static/contrib/tabler-icons/archive.svg +21 -0
- swarm/static/contrib/tabler-icons/artboard.svg +27 -0
- swarm/static/contrib/tabler-icons/automatic-gearbox.svg +23 -0
- swarm/static/contrib/tabler-icons/box-multiple.svg +19 -0
- swarm/static/contrib/tabler-icons/carambola.svg +19 -0
- swarm/static/contrib/tabler-icons/copy.svg +20 -0
- swarm/static/contrib/tabler-icons/download.svg +21 -0
- swarm/static/contrib/tabler-icons/edit.svg +21 -0
- swarm/static/contrib/tabler-icons/filled/carambola.svg +13 -0
- swarm/static/contrib/tabler-icons/filled/paint.svg +13 -0
- swarm/static/contrib/tabler-icons/headset.svg +22 -0
- swarm/static/contrib/tabler-icons/layout-sidebar-left-collapse.svg +21 -0
- swarm/static/contrib/tabler-icons/layout-sidebar-left-expand.svg +21 -0
- swarm/static/contrib/tabler-icons/layout-sidebar-right-collapse.svg +21 -0
- swarm/static/contrib/tabler-icons/layout-sidebar-right-expand.svg +21 -0
- swarm/static/contrib/tabler-icons/message-chatbot.svg +22 -0
- swarm/static/contrib/tabler-icons/message-star.svg +22 -0
- swarm/static/contrib/tabler-icons/message-x.svg +23 -0
- swarm/static/contrib/tabler-icons/message.svg +21 -0
- swarm/static/contrib/tabler-icons/paperclip.svg +18 -0
- swarm/static/contrib/tabler-icons/playlist-add.svg +22 -0
- swarm/static/contrib/tabler-icons/robot.svg +26 -0
- swarm/static/contrib/tabler-icons/search.svg +19 -0
- swarm/static/contrib/tabler-icons/settings.svg +20 -0
- swarm/static/contrib/tabler-icons/thumb-down.svg +19 -0
- swarm/static/contrib/tabler-icons/thumb-up.svg +19 -0
- swarm/static/css/dropdown.css +22 -0
- swarm/static/htmx/htmx.min.js +0 -0
- swarm/static/js/dropdown.js +23 -0
- swarm/static/rest_mode/css/base.css +470 -0
- swarm/static/rest_mode/css/chat-history.css +286 -0
- swarm/static/rest_mode/css/chat.css +251 -0
- swarm/static/rest_mode/css/chatbot.css +74 -0
- swarm/static/rest_mode/css/chatgpt.css +62 -0
- swarm/static/rest_mode/css/colors/corporate.css +74 -0
- swarm/static/rest_mode/css/colors/pastel.css +81 -0
- swarm/static/rest_mode/css/colors/tropical.css +82 -0
- swarm/static/rest_mode/css/general.css +142 -0
- swarm/static/rest_mode/css/layout.css +167 -0
- swarm/static/rest_mode/css/layouts/messenger-layout.css +17 -0
- swarm/static/rest_mode/css/layouts/minimalist-layout.css +57 -0
- swarm/static/rest_mode/css/layouts/mobile-layout.css +8 -0
- swarm/static/rest_mode/css/messages.css +84 -0
- swarm/static/rest_mode/css/messenger.css +135 -0
- swarm/static/rest_mode/css/settings.css +91 -0
- swarm/static/rest_mode/css/simple.css +44 -0
- swarm/static/rest_mode/css/slack.css +58 -0
- swarm/static/rest_mode/css/style.css +156 -0
- swarm/static/rest_mode/css/theme.css +30 -0
- swarm/static/rest_mode/css/toast.css +40 -0
- swarm/static/rest_mode/js/auth.js +9 -0
- swarm/static/rest_mode/js/blueprint.js +41 -0
- swarm/static/rest_mode/js/blueprintUtils.js +12 -0
- swarm/static/rest_mode/js/chatLogic.js +79 -0
- swarm/static/rest_mode/js/debug.js +63 -0
- swarm/static/rest_mode/js/events.js +98 -0
- swarm/static/rest_mode/js/main.js +19 -0
- swarm/static/rest_mode/js/messages.js +264 -0
- swarm/static/rest_mode/js/messengerLogic.js +355 -0
- swarm/static/rest_mode/js/modules/apiService.js +84 -0
- swarm/static/rest_mode/js/modules/blueprintManager.js +162 -0
- swarm/static/rest_mode/js/modules/chatHistory.js +110 -0
- swarm/static/rest_mode/js/modules/debugLogger.js +14 -0
- swarm/static/rest_mode/js/modules/eventHandlers.js +107 -0
- swarm/static/rest_mode/js/modules/messageProcessor.js +120 -0
- swarm/static/rest_mode/js/modules/state.js +7 -0
- swarm/static/rest_mode/js/modules/userInteractions.js +29 -0
- swarm/static/rest_mode/js/modules/validation.js +23 -0
- swarm/static/rest_mode/js/rendering.js +119 -0
- swarm/static/rest_mode/js/settings.js +130 -0
- swarm/static/rest_mode/js/sidebar.js +94 -0
- swarm/static/rest_mode/js/simpleLogic.js +37 -0
- swarm/static/rest_mode/js/slackLogic.js +66 -0
- swarm/static/rest_mode/js/splash.js +76 -0
- swarm/static/rest_mode/js/theme.js +111 -0
- swarm/static/rest_mode/js/toast.js +36 -0
- swarm/static/rest_mode/js/ui.js +265 -0
- swarm/static/rest_mode/js/validation.js +57 -0
- swarm/static/rest_mode/svg/animated_spinner.svg +12 -0
- swarm/static/rest_mode/svg/arrow_down.svg +5 -0
- swarm/static/rest_mode/svg/arrow_left.svg +5 -0
- swarm/static/rest_mode/svg/arrow_right.svg +5 -0
- swarm/static/rest_mode/svg/arrow_up.svg +5 -0
- swarm/static/rest_mode/svg/attach.svg +8 -0
- swarm/static/rest_mode/svg/avatar.svg +7 -0
- swarm/static/rest_mode/svg/canvas.svg +6 -0
- swarm/static/rest_mode/svg/chat_history.svg +4 -0
- swarm/static/rest_mode/svg/close.svg +5 -0
- swarm/static/rest_mode/svg/copy.svg +4 -0
- swarm/static/rest_mode/svg/dark_mode.svg +3 -0
- swarm/static/rest_mode/svg/edit.svg +5 -0
- swarm/static/rest_mode/svg/layout.svg +9 -0
- swarm/static/rest_mode/svg/logo.svg +29 -0
- swarm/static/rest_mode/svg/logout.svg +5 -0
- swarm/static/rest_mode/svg/mobile.svg +5 -0
- swarm/static/rest_mode/svg/new_chat.svg +4 -0
- swarm/static/rest_mode/svg/not_visible.svg +5 -0
- swarm/static/rest_mode/svg/plus.svg +7 -0
- swarm/static/rest_mode/svg/run_code.svg +6 -0
- swarm/static/rest_mode/svg/save.svg +4 -0
- swarm/static/rest_mode/svg/search.svg +6 -0
- swarm/static/rest_mode/svg/settings.svg +4 -0
- swarm/static/rest_mode/svg/speaker.svg +5 -0
- swarm/static/rest_mode/svg/stop.svg +6 -0
- swarm/static/rest_mode/svg/thumbs_down.svg +3 -0
- swarm/static/rest_mode/svg/thumbs_up.svg +3 -0
- swarm/static/rest_mode/svg/toggle_off.svg +6 -0
- swarm/static/rest_mode/svg/toggle_on.svg +6 -0
- swarm/static/rest_mode/svg/trash.svg +10 -0
- swarm/static/rest_mode/svg/undo.svg +3 -0
- swarm/static/rest_mode/svg/visible.svg +8 -0
- swarm/static/rest_mode/svg/voice.svg +10 -0
- swarm/templates/account/login.html +22 -0
- swarm/templates/account/signup.html +32 -0
- swarm/templates/base.html +30 -0
- swarm/templates/chat.html +43 -0
- swarm/templates/index.html +35 -0
- swarm/templates/rest_mode/components/chat_sidebar.html +55 -0
- swarm/templates/rest_mode/components/header.html +45 -0
- swarm/templates/rest_mode/components/main_chat_pane.html +41 -0
- swarm/templates/rest_mode/components/settings_dialog.html +97 -0
- swarm/templates/rest_mode/components/splash_screen.html +7 -0
- swarm/templates/rest_mode/components/top_bar.html +28 -0
- swarm/templates/rest_mode/message_ui.html +50 -0
- swarm/templates/rest_mode/slackbot.html +30 -0
- swarm/templates/simple_blueprint_page.html +24 -0
- swarm/templates/websocket_partials/final_system_message.html +3 -0
- swarm/templates/websocket_partials/system_message.html +4 -0
- swarm/templates/websocket_partials/user_message.html +5 -0
- swarm/urls.py +57 -74
- swarm/utils/log_utils.py +63 -0
- swarm/views/api_views.py +48 -39
- swarm/views/chat_views.py +156 -70
- swarm/views/core_views.py +85 -90
- swarm/views/model_views.py +64 -121
- swarm/views/utils.py +65 -441
- open_swarm-0.1.1743070217.dist-info/METADATA +0 -258
- open_swarm-0.1.1743070217.dist-info/RECORD +0 -89
- open_swarm-0.1.1743070217.dist-info/entry_points.txt +0 -3
- open_swarm-0.1.1743070217.dist-info/top_level.txt +0 -1
- swarm/agent/agent.py +0 -49
- swarm/core.py +0 -326
- swarm/extensions/mcp/__init__.py +0 -1
- swarm/extensions/mcp/cache_utils.py +0 -36
- swarm/extensions/mcp/mcp_client.py +0 -341
- swarm/extensions/mcp/mcp_constants.py +0 -7
- swarm/extensions/mcp/mcp_tool_provider.py +0 -110
- swarm/types.py +0 -126
- {open_swarm-0.1.1743070217.dist-info → open_swarm-0.1.1743364176.dist-info}/licenses/LICENSE +0 -0
swarm/views/model_views.py
CHANGED
@@ -1,135 +1,78 @@
|
|
1
1
|
"""
|
2
|
-
|
3
|
-
Dynamically discovers blueprints and lists them alongside configured LLMs.
|
2
|
+
Views related to listing and describing available models (Blueprints).
|
4
3
|
"""
|
5
|
-
import
|
6
|
-
from django.
|
7
|
-
from
|
8
|
-
from
|
9
|
-
from
|
4
|
+
import logging
|
5
|
+
from django.conf import settings
|
6
|
+
from django.http import JsonResponse # Not used directly, Response is preferred
|
7
|
+
from django.utils.decorators import method_decorator
|
8
|
+
from django.views.decorators.csrf import csrf_exempt
|
10
9
|
|
11
|
-
from
|
12
|
-
|
13
|
-
from
|
14
|
-
|
15
|
-
from swarm.extensions.blueprint.blueprint_utils import filter_blueprints
|
16
|
-
# Import config loader or access config globally if set up
|
17
|
-
# Using utils seems less direct, let's assume config needs loading or is globally available
|
18
|
-
# from swarm.views.utils import config # This import might be problematic, load directly if needed
|
19
|
-
from swarm.extensions.config.config_loader import load_server_config
|
20
|
-
from swarm.settings import BLUEPRINTS_DIR # Import the directory setting
|
10
|
+
from rest_framework.views import APIView
|
11
|
+
from rest_framework.response import Response
|
12
|
+
from rest_framework.permissions import AllowAny, IsAuthenticated
|
13
|
+
from rest_framework import status
|
21
14
|
|
22
|
-
|
15
|
+
from drf_spectacular.utils import extend_schema
|
23
16
|
|
24
|
-
|
25
|
-
|
26
|
-
200: {
|
27
|
-
"type": "object",
|
28
|
-
"properties": {
|
29
|
-
"object": {"type": "string"},
|
30
|
-
"data": {
|
31
|
-
"type": "array",
|
32
|
-
"items": {
|
33
|
-
"type": "object",
|
34
|
-
"properties": {
|
35
|
-
"id": {"type": "string"},
|
36
|
-
"object": {"type": "string"},
|
37
|
-
"title": {"type": "string"},
|
38
|
-
"description": {"type": "string"}
|
39
|
-
}
|
40
|
-
}
|
41
|
-
}
|
42
|
-
}
|
43
|
-
}
|
44
|
-
},
|
45
|
-
summary="Lists LLMs, config-defined blueprints, and discovered blueprints as models."
|
46
|
-
)
|
47
|
-
@api_view(["GET"])
|
48
|
-
@permission_classes([AllowAny]) # Use AllowAny directly
|
49
|
-
@authentication_classes([]) # No authentication required for listing models
|
50
|
-
def list_models(request):
|
51
|
-
"""List available LLMs, config-defined blueprints, and discovered blueprints."""
|
52
|
-
if request.method != "GET":
|
53
|
-
return JsonResponse({"error": "Method not allowed. Use GET."}, status=405)
|
17
|
+
# *** Import async_to_sync ***
|
18
|
+
from asgiref.sync import async_to_sync
|
54
19
|
|
55
|
-
|
56
|
-
|
57
|
-
|
20
|
+
# Import the utility function
|
21
|
+
from .utils import get_available_blueprints
|
22
|
+
from ..permissions import HasValidTokenOrSession
|
58
23
|
|
59
|
-
|
60
|
-
llm_config = config.get("llm", {})
|
61
|
-
llm_data = [
|
62
|
-
{
|
63
|
-
"id": key,
|
64
|
-
"object": "llm", # Mark as llm type
|
65
|
-
"title": conf.get("model", key), # Use model name or key as title
|
66
|
-
"description": f"Provider: {conf.get('provider', 'N/A')}, Model: {conf.get('model', 'N/A')}"
|
67
|
-
}
|
68
|
-
for key, conf in llm_config.items() if conf.get("passthrough")
|
69
|
-
]
|
24
|
+
logger = logging.getLogger(__name__)
|
70
25
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
{
|
75
|
-
"id": key,
|
76
|
-
"object": "blueprint", # Mark as blueprint type
|
77
|
-
"title": bp.get("title", key),
|
78
|
-
"description": bp.get("description", f"Blueprint '{key}' from configuration file.")
|
79
|
-
}
|
80
|
-
for key, bp in config_blueprints.items()
|
81
|
-
]
|
26
|
+
# ==============================================================================
|
27
|
+
# API Views (DRF based) for Models
|
28
|
+
# ==============================================================================
|
82
29
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
logger.warning(f"Blueprints directory '{BLUEPRINTS_DIR}' not found. No blueprints discovered dynamically.")
|
90
|
-
discovered_blueprints_metadata = {}
|
91
|
-
except Exception as discover_err:
|
92
|
-
logger.error(f"Error discovering blueprints: {discover_err}", exc_info=True)
|
93
|
-
discovered_blueprints_metadata = {}
|
30
|
+
class ListModelsView(APIView):
|
31
|
+
"""
|
32
|
+
API view to list available models (Blueprints).
|
33
|
+
Compliant with OpenAI API's /v1/models endpoint structure.
|
34
|
+
"""
|
35
|
+
permission_classes = [HasValidTokenOrSession]
|
94
36
|
|
37
|
+
@extend_schema(
|
38
|
+
responses={ # Simplified schema for brevity
|
39
|
+
200: {"description": "A list of available models."}
|
40
|
+
}
|
41
|
+
)
|
42
|
+
# *** Make the handler synchronous ***
|
43
|
+
def get(self, request, *args, **kwargs):
|
44
|
+
"""
|
45
|
+
Handles GET requests to list available models.
|
46
|
+
"""
|
47
|
+
try:
|
48
|
+
# *** Call the async utility function using async_to_sync ***
|
49
|
+
# Ensure get_available_blueprints is awaitable (async def or wrapped)
|
50
|
+
available_blueprints_dict = async_to_sync(get_available_blueprints)()
|
95
51
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
52
|
+
models_data = [
|
53
|
+
{
|
54
|
+
"id": model_id,
|
55
|
+
"object": "model",
|
56
|
+
"created": 0, # Placeholder
|
57
|
+
"owned_by": "open-swarm",
|
58
|
+
# Access metadata safely
|
59
|
+
"profile_name": metadata.get('profile_name', 'unknown') if isinstance(metadata, dict) else 'unknown'
|
60
|
+
}
|
61
|
+
# Ensure iteration works correctly
|
62
|
+
for model_id, metadata in (available_blueprints_dict.items() if isinstance(available_blueprints_dict, dict) else [])
|
63
|
+
]
|
104
64
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
"id": key,
|
109
|
-
"object": "blueprint", # Mark as blueprint type
|
110
|
-
"title": meta.get("title", key),
|
111
|
-
"description": meta.get("description", f"Discovered blueprint '{key}'.")
|
65
|
+
response_data = {
|
66
|
+
"object": "list",
|
67
|
+
"data": models_data,
|
112
68
|
}
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
# 4. Merge all data sources
|
117
|
-
# Start with LLMs and config blueprints
|
118
|
-
merged_data = llm_data + config_bp_data
|
119
|
-
# Keep track of IDs already added
|
120
|
-
seen_ids = {item["id"] for item in merged_data}
|
121
|
-
# Add discovered blueprints only if their ID hasn't been used by config/LLMs
|
122
|
-
for bp_item in discovered_bp_data:
|
123
|
-
if bp_item["id"] not in seen_ids:
|
124
|
-
merged_data.append(bp_item)
|
125
|
-
seen_ids.add(bp_item["id"]) # Mark ID as seen
|
126
|
-
|
127
|
-
logger.debug(f"Returning {len(merged_data)} models (LLMs + Blueprints).")
|
128
|
-
# Return the merged list in the expected OpenAI-like format
|
129
|
-
return JsonResponse({"object": "list", "data": merged_data}, status=200)
|
130
|
-
|
131
|
-
except Exception as e:
|
132
|
-
# Catch-all for unexpected errors during the process
|
133
|
-
logger.error(f"Error listing models: {e}", exc_info=True)
|
134
|
-
return JsonResponse({"error": "Internal Server Error while listing models."}, status=500)
|
69
|
+
# Return the standard sync Response
|
70
|
+
return Response(response_data, status=status.HTTP_200_OK)
|
135
71
|
|
72
|
+
except Exception as e:
|
73
|
+
logger.error(f"Error retrieving available blueprints: {e}", exc_info=True)
|
74
|
+
# Return the standard sync Response
|
75
|
+
return Response(
|
76
|
+
{"error": "Internal server error retrieving models."},
|
77
|
+
status=status.HTTP_500_INTERNAL_SERVER_ERROR
|
78
|
+
)
|