open-swarm 0.1.1743070217__py3-none-any.whl → 0.1.1743362777__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.
Files changed (217) hide show
  1. open_swarm-0.1.1743362777.dist-info/METADATA +217 -0
  2. open_swarm-0.1.1743362777.dist-info/RECORD +260 -0
  3. {open_swarm-0.1.1743070217.dist-info → open_swarm-0.1.1743362777.dist-info}/WHEEL +1 -2
  4. open_swarm-0.1.1743362777.dist-info/entry_points.txt +2 -0
  5. swarm/__init__.py +0 -2
  6. swarm/auth.py +53 -49
  7. swarm/blueprints/README.md +67 -0
  8. swarm/blueprints/burnt_noodles/blueprint_burnt_noodles.py +412 -0
  9. swarm/blueprints/chatbot/blueprint_chatbot.py +98 -0
  10. swarm/blueprints/chatbot/templates/chatbot/chatbot.html +33 -0
  11. swarm/blueprints/digitalbutlers/blueprint_digitalbutlers.py +183 -0
  12. swarm/blueprints/dilbot_universe/blueprint_dilbot_universe.py +285 -0
  13. swarm/blueprints/divine_code/__init__.py +0 -0
  14. swarm/blueprints/divine_code/apps.py +11 -0
  15. swarm/blueprints/divine_code/blueprint_divine_code.py +219 -0
  16. swarm/blueprints/django_chat/apps.py +6 -0
  17. swarm/blueprints/django_chat/blueprint_django_chat.py +84 -0
  18. swarm/blueprints/django_chat/templates/django_chat/django_chat_webpage.html +37 -0
  19. swarm/blueprints/django_chat/urls.py +8 -0
  20. swarm/blueprints/django_chat/views.py +32 -0
  21. swarm/blueprints/echocraft/blueprint_echocraft.py +44 -0
  22. swarm/blueprints/family_ties/apps.py +11 -0
  23. swarm/blueprints/family_ties/blueprint_family_ties.py +152 -0
  24. swarm/blueprints/family_ties/models.py +19 -0
  25. swarm/blueprints/family_ties/serializers.py +7 -0
  26. swarm/blueprints/family_ties/settings.py +16 -0
  27. swarm/blueprints/family_ties/urls.py +10 -0
  28. swarm/blueprints/family_ties/views.py +26 -0
  29. swarm/blueprints/flock/__init__.py +0 -0
  30. swarm/blueprints/gaggle/blueprint_gaggle.py +184 -0
  31. swarm/blueprints/gotchaman/blueprint_gotchaman.py +232 -0
  32. swarm/blueprints/mcp_demo/blueprint_mcp_demo.py +133 -0
  33. swarm/blueprints/messenger/templates/messenger/messenger.html +46 -0
  34. swarm/blueprints/mission_improbable/blueprint_mission_improbable.py +234 -0
  35. swarm/blueprints/monkai_magic/blueprint_monkai_magic.py +248 -0
  36. swarm/blueprints/nebula_shellz/blueprint_nebula_shellz.py +156 -0
  37. swarm/blueprints/omniplex/blueprint_omniplex.py +221 -0
  38. swarm/blueprints/rue_code/__init__.py +0 -0
  39. swarm/blueprints/rue_code/blueprint_rue_code.py +291 -0
  40. swarm/blueprints/suggestion/blueprint_suggestion.py +110 -0
  41. swarm/blueprints/unapologetic_press/blueprint_unapologetic_press.py +298 -0
  42. swarm/blueprints/whiskeytango_foxtrot/__init__.py +0 -0
  43. swarm/blueprints/whiskeytango_foxtrot/apps.py +11 -0
  44. swarm/blueprints/whiskeytango_foxtrot/blueprint_whiskeytango_foxtrot.py +256 -0
  45. swarm/extensions/blueprint/__init__.py +30 -15
  46. swarm/extensions/blueprint/agent_utils.py +16 -40
  47. swarm/extensions/blueprint/blueprint_base.py +141 -543
  48. swarm/extensions/blueprint/blueprint_discovery.py +112 -98
  49. swarm/extensions/blueprint/cli_handler.py +185 -0
  50. swarm/extensions/blueprint/config_loader.py +122 -0
  51. swarm/extensions/blueprint/django_utils.py +181 -79
  52. swarm/extensions/blueprint/interactive_mode.py +1 -1
  53. swarm/extensions/config/config_loader.py +83 -200
  54. swarm/extensions/launchers/build_swarm_wrapper.py +0 -0
  55. swarm/extensions/launchers/swarm_cli.py +199 -287
  56. swarm/llm/chat_completion.py +26 -55
  57. swarm/management/__init__.py +0 -0
  58. swarm/management/commands/__init__.py +0 -0
  59. swarm/management/commands/runserver.py +58 -0
  60. swarm/permissions.py +38 -0
  61. swarm/serializers.py +96 -5
  62. swarm/settings.py +95 -110
  63. swarm/static/contrib/fonts/fontawesome-webfont.ttf +7 -0
  64. swarm/static/contrib/fonts/fontawesome-webfont.woff +7 -0
  65. swarm/static/contrib/fonts/fontawesome-webfont.woff2 +7 -0
  66. swarm/static/contrib/markedjs/marked.min.js +6 -0
  67. swarm/static/contrib/tabler-icons/adjustments-horizontal.svg +27 -0
  68. swarm/static/contrib/tabler-icons/alert-triangle.svg +21 -0
  69. swarm/static/contrib/tabler-icons/archive.svg +21 -0
  70. swarm/static/contrib/tabler-icons/artboard.svg +27 -0
  71. swarm/static/contrib/tabler-icons/automatic-gearbox.svg +23 -0
  72. swarm/static/contrib/tabler-icons/box-multiple.svg +19 -0
  73. swarm/static/contrib/tabler-icons/carambola.svg +19 -0
  74. swarm/static/contrib/tabler-icons/copy.svg +20 -0
  75. swarm/static/contrib/tabler-icons/download.svg +21 -0
  76. swarm/static/contrib/tabler-icons/edit.svg +21 -0
  77. swarm/static/contrib/tabler-icons/filled/carambola.svg +13 -0
  78. swarm/static/contrib/tabler-icons/filled/paint.svg +13 -0
  79. swarm/static/contrib/tabler-icons/headset.svg +22 -0
  80. swarm/static/contrib/tabler-icons/layout-sidebar-left-collapse.svg +21 -0
  81. swarm/static/contrib/tabler-icons/layout-sidebar-left-expand.svg +21 -0
  82. swarm/static/contrib/tabler-icons/layout-sidebar-right-collapse.svg +21 -0
  83. swarm/static/contrib/tabler-icons/layout-sidebar-right-expand.svg +21 -0
  84. swarm/static/contrib/tabler-icons/message-chatbot.svg +22 -0
  85. swarm/static/contrib/tabler-icons/message-star.svg +22 -0
  86. swarm/static/contrib/tabler-icons/message-x.svg +23 -0
  87. swarm/static/contrib/tabler-icons/message.svg +21 -0
  88. swarm/static/contrib/tabler-icons/paperclip.svg +18 -0
  89. swarm/static/contrib/tabler-icons/playlist-add.svg +22 -0
  90. swarm/static/contrib/tabler-icons/robot.svg +26 -0
  91. swarm/static/contrib/tabler-icons/search.svg +19 -0
  92. swarm/static/contrib/tabler-icons/settings.svg +20 -0
  93. swarm/static/contrib/tabler-icons/thumb-down.svg +19 -0
  94. swarm/static/contrib/tabler-icons/thumb-up.svg +19 -0
  95. swarm/static/css/dropdown.css +22 -0
  96. swarm/static/htmx/htmx.min.js +0 -0
  97. swarm/static/js/dropdown.js +23 -0
  98. swarm/static/rest_mode/css/base.css +470 -0
  99. swarm/static/rest_mode/css/chat-history.css +286 -0
  100. swarm/static/rest_mode/css/chat.css +251 -0
  101. swarm/static/rest_mode/css/chatbot.css +74 -0
  102. swarm/static/rest_mode/css/chatgpt.css +62 -0
  103. swarm/static/rest_mode/css/colors/corporate.css +74 -0
  104. swarm/static/rest_mode/css/colors/pastel.css +81 -0
  105. swarm/static/rest_mode/css/colors/tropical.css +82 -0
  106. swarm/static/rest_mode/css/general.css +142 -0
  107. swarm/static/rest_mode/css/layout.css +167 -0
  108. swarm/static/rest_mode/css/layouts/messenger-layout.css +17 -0
  109. swarm/static/rest_mode/css/layouts/minimalist-layout.css +57 -0
  110. swarm/static/rest_mode/css/layouts/mobile-layout.css +8 -0
  111. swarm/static/rest_mode/css/messages.css +84 -0
  112. swarm/static/rest_mode/css/messenger.css +135 -0
  113. swarm/static/rest_mode/css/settings.css +91 -0
  114. swarm/static/rest_mode/css/simple.css +44 -0
  115. swarm/static/rest_mode/css/slack.css +58 -0
  116. swarm/static/rest_mode/css/style.css +156 -0
  117. swarm/static/rest_mode/css/theme.css +30 -0
  118. swarm/static/rest_mode/css/toast.css +40 -0
  119. swarm/static/rest_mode/js/auth.js +9 -0
  120. swarm/static/rest_mode/js/blueprint.js +41 -0
  121. swarm/static/rest_mode/js/blueprintUtils.js +12 -0
  122. swarm/static/rest_mode/js/chatLogic.js +79 -0
  123. swarm/static/rest_mode/js/debug.js +63 -0
  124. swarm/static/rest_mode/js/events.js +98 -0
  125. swarm/static/rest_mode/js/main.js +19 -0
  126. swarm/static/rest_mode/js/messages.js +264 -0
  127. swarm/static/rest_mode/js/messengerLogic.js +355 -0
  128. swarm/static/rest_mode/js/modules/apiService.js +84 -0
  129. swarm/static/rest_mode/js/modules/blueprintManager.js +162 -0
  130. swarm/static/rest_mode/js/modules/chatHistory.js +110 -0
  131. swarm/static/rest_mode/js/modules/debugLogger.js +14 -0
  132. swarm/static/rest_mode/js/modules/eventHandlers.js +107 -0
  133. swarm/static/rest_mode/js/modules/messageProcessor.js +120 -0
  134. swarm/static/rest_mode/js/modules/state.js +7 -0
  135. swarm/static/rest_mode/js/modules/userInteractions.js +29 -0
  136. swarm/static/rest_mode/js/modules/validation.js +23 -0
  137. swarm/static/rest_mode/js/rendering.js +119 -0
  138. swarm/static/rest_mode/js/settings.js +130 -0
  139. swarm/static/rest_mode/js/sidebar.js +94 -0
  140. swarm/static/rest_mode/js/simpleLogic.js +37 -0
  141. swarm/static/rest_mode/js/slackLogic.js +66 -0
  142. swarm/static/rest_mode/js/splash.js +76 -0
  143. swarm/static/rest_mode/js/theme.js +111 -0
  144. swarm/static/rest_mode/js/toast.js +36 -0
  145. swarm/static/rest_mode/js/ui.js +265 -0
  146. swarm/static/rest_mode/js/validation.js +57 -0
  147. swarm/static/rest_mode/svg/animated_spinner.svg +12 -0
  148. swarm/static/rest_mode/svg/arrow_down.svg +5 -0
  149. swarm/static/rest_mode/svg/arrow_left.svg +5 -0
  150. swarm/static/rest_mode/svg/arrow_right.svg +5 -0
  151. swarm/static/rest_mode/svg/arrow_up.svg +5 -0
  152. swarm/static/rest_mode/svg/attach.svg +8 -0
  153. swarm/static/rest_mode/svg/avatar.svg +7 -0
  154. swarm/static/rest_mode/svg/canvas.svg +6 -0
  155. swarm/static/rest_mode/svg/chat_history.svg +4 -0
  156. swarm/static/rest_mode/svg/close.svg +5 -0
  157. swarm/static/rest_mode/svg/copy.svg +4 -0
  158. swarm/static/rest_mode/svg/dark_mode.svg +3 -0
  159. swarm/static/rest_mode/svg/edit.svg +5 -0
  160. swarm/static/rest_mode/svg/layout.svg +9 -0
  161. swarm/static/rest_mode/svg/logo.svg +29 -0
  162. swarm/static/rest_mode/svg/logout.svg +5 -0
  163. swarm/static/rest_mode/svg/mobile.svg +5 -0
  164. swarm/static/rest_mode/svg/new_chat.svg +4 -0
  165. swarm/static/rest_mode/svg/not_visible.svg +5 -0
  166. swarm/static/rest_mode/svg/plus.svg +7 -0
  167. swarm/static/rest_mode/svg/run_code.svg +6 -0
  168. swarm/static/rest_mode/svg/save.svg +4 -0
  169. swarm/static/rest_mode/svg/search.svg +6 -0
  170. swarm/static/rest_mode/svg/settings.svg +4 -0
  171. swarm/static/rest_mode/svg/speaker.svg +5 -0
  172. swarm/static/rest_mode/svg/stop.svg +6 -0
  173. swarm/static/rest_mode/svg/thumbs_down.svg +3 -0
  174. swarm/static/rest_mode/svg/thumbs_up.svg +3 -0
  175. swarm/static/rest_mode/svg/toggle_off.svg +6 -0
  176. swarm/static/rest_mode/svg/toggle_on.svg +6 -0
  177. swarm/static/rest_mode/svg/trash.svg +10 -0
  178. swarm/static/rest_mode/svg/undo.svg +3 -0
  179. swarm/static/rest_mode/svg/visible.svg +8 -0
  180. swarm/static/rest_mode/svg/voice.svg +10 -0
  181. swarm/templates/account/login.html +22 -0
  182. swarm/templates/account/signup.html +32 -0
  183. swarm/templates/base.html +30 -0
  184. swarm/templates/chat.html +43 -0
  185. swarm/templates/index.html +35 -0
  186. swarm/templates/rest_mode/components/chat_sidebar.html +55 -0
  187. swarm/templates/rest_mode/components/header.html +45 -0
  188. swarm/templates/rest_mode/components/main_chat_pane.html +41 -0
  189. swarm/templates/rest_mode/components/settings_dialog.html +97 -0
  190. swarm/templates/rest_mode/components/splash_screen.html +7 -0
  191. swarm/templates/rest_mode/components/top_bar.html +28 -0
  192. swarm/templates/rest_mode/message_ui.html +50 -0
  193. swarm/templates/rest_mode/slackbot.html +30 -0
  194. swarm/templates/simple_blueprint_page.html +24 -0
  195. swarm/templates/websocket_partials/final_system_message.html +3 -0
  196. swarm/templates/websocket_partials/system_message.html +4 -0
  197. swarm/templates/websocket_partials/user_message.html +5 -0
  198. swarm/urls.py +57 -74
  199. swarm/utils/log_utils.py +63 -0
  200. swarm/views/api_views.py +48 -39
  201. swarm/views/chat_views.py +156 -70
  202. swarm/views/core_views.py +85 -90
  203. swarm/views/model_views.py +64 -121
  204. swarm/views/utils.py +65 -441
  205. open_swarm-0.1.1743070217.dist-info/METADATA +0 -258
  206. open_swarm-0.1.1743070217.dist-info/RECORD +0 -89
  207. open_swarm-0.1.1743070217.dist-info/entry_points.txt +0 -3
  208. open_swarm-0.1.1743070217.dist-info/top_level.txt +0 -1
  209. swarm/agent/agent.py +0 -49
  210. swarm/core.py +0 -326
  211. swarm/extensions/mcp/__init__.py +0 -1
  212. swarm/extensions/mcp/cache_utils.py +0 -36
  213. swarm/extensions/mcp/mcp_client.py +0 -341
  214. swarm/extensions/mcp/mcp_constants.py +0 -7
  215. swarm/extensions/mcp/mcp_tool_provider.py +0 -110
  216. swarm/types.py +0 -126
  217. {open_swarm-0.1.1743070217.dist-info → open_swarm-0.1.1743362777.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,45 @@
1
+ {% load static %}
2
+ <!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="UTF-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Open-Swarm Chat</title>
8
+
9
+ <!-- CSRF Token -->
10
+ <meta name="csrf-token" content="{{ csrf_token }}">
11
+
12
+ <!-- Base CSS -->
13
+ <link rel="stylesheet" href="{% static 'rest_mode/css/base.css' %}">
14
+ <link id="colorThemeLink" rel="stylesheet" href="{% static 'rest_mode/css/colors/corporate.css' %}">
15
+ <link id="layoutThemeLink" rel="stylesheet" href="{% static 'rest_mode/css/layouts/messenger-layout.css' %}">
16
+ <link rel="stylesheet" href="{% static 'rest_mode/css/style.css' %}">
17
+ <link rel="stylesheet" href="{% static 'rest_mode/css/chat-history.css' %}">
18
+ <link rel="stylesheet" href="{% static 'rest_mode/css/chat.css' %}">
19
+ <link rel="stylesheet" href="{% static 'rest_mode/css/general.css' %}">
20
+ <link rel="stylesheet" href="{% static 'rest_mode/css/messages.css' %}">
21
+ <link rel="stylesheet" href="{% static 'rest_mode/css/settings.css' %}">
22
+
23
+ <!-- Inline Script to Apply Settings from localStorage -->
24
+ <script>
25
+ (function () {
26
+ // Default values
27
+ const defaultSettings = {
28
+ colorTheme: 'corporate',
29
+ layoutTheme: 'messenger-layout',
30
+ darkMode: true,
31
+ mobileLayout: false
32
+ };
33
+
34
+ // Load settings from localStorage or use defaults
35
+ const colorTheme = localStorage.getItem('selectedColor') || defaultSettings.colorTheme;
36
+ const layoutTheme = localStorage.getItem('selectedLayout') || defaultSettings.layoutTheme;
37
+ const darkMode = localStorage.getItem('darkMode') === 'true' || defaultSettings.darkMode;
38
+
39
+ // Apply settings
40
+ document.documentElement.setAttribute('data-theme-color', colorTheme);
41
+ document.documentElement.setAttribute('data-theme-layout', layoutTheme);
42
+ document.documentElement.setAttribute('data-theme-dark', darkMode);
43
+ })();
44
+ </script>
45
+ </head>
@@ -0,0 +1,41 @@
1
+ {% load static %}
2
+ <div class="main-pane">
3
+ <div class="button-row">
4
+ <button class="input-button-subtle" aria-label="Toggle Chat History" id="chatHistoryToggleButtonVisible" style="display: none;">
5
+ <img src="{% static 'contrib/tabler-icons/layout-sidebar-left-expand.svg' %}" alt="Chat History">
6
+ </button>
7
+ <button class="input-button-subtle" aria-label="Settings" id="settingsButton-main" style="display: none;">
8
+ <img src="{% static 'contrib/tabler-icons/settings.svg' %}" alt="Settings">
9
+ </button>
10
+ <button class="input-button-subtle" aria-label="Search" id="searchButton-main" style="display: none;">
11
+ <img src="{% static 'contrib/tabler-icons/search.svg' %}" alt="Search">
12
+ </button>
13
+ <button class="input-button-subtle" aria-label="New Chat" id="newChatButton-main" style="display: none;">
14
+ <img src="{% static 'contrib/tabler-icons/message-chatbot.svg' %}" alt="New Chat"> New Chat
15
+ </button>
16
+ </div>
17
+ <div id="quickPromptsContainer" class="quick-prompts-container"></div>
18
+ <div id="messageHistory" class="message-container"></div>
19
+ <div id="loadingIndicator" class="loading-indicator"></div>
20
+ <div class="form-container">
21
+ <div class="dropdown-buttons-container">
22
+ <select class="blueprint-dropdown" id="blueprintDropdown" aria-label="Select Blueprint"></select>
23
+ <button class="input-button upload-button" id="uploadButton" aria-label="Upload">
24
+ <img src="{% static 'contrib/tabler-icons/paperclip.svg' %}" alt="Upload">
25
+ </button>
26
+ <button class="input-button upload-button" id="canvasToggleButton" aria-label="Toggle Canvas">
27
+ <img src="{% static 'contrib/tabler-icons/artboard.svg' %}" alt="Canvas">
28
+ </button>
29
+ <button class="input-button" id="voiceRecordButton" aria-label="Record Voice">
30
+ <img src="{% static 'contrib/tabler-icons/headset.svg' %}" alt="Record Voice">
31
+ </button>
32
+ <button class="input-button upload-button" id="avatarToggleButton" aria-label="Toggle Avatar">
33
+ <img src="{% static 'contrib/tabler-icons/robot.svg' %}" alt="Avatar">
34
+ </button>
35
+ </div>
36
+ <div class="send-container">
37
+ <input type="text" id="userInput" class="rounded-input" placeholder="Type your message here...">
38
+ <button class="half-cut-button">Send</button>
39
+ </div>
40
+ </div>
41
+ </div>
@@ -0,0 +1,97 @@
1
+ {% load static %}
2
+ <div class="settings-dialog" id="settingsDialog">
3
+ <button class="dialog-close-btn" id="closeSettingsDialog">
4
+ <img src="{% static 'rest_mode/svg/close.svg' %}" alt="Close Settings Dialog">
5
+ </button>
6
+ <div class="settings-container scrollable-container">
7
+ <h2>⚙️ Settings</h2>
8
+
9
+ <!-- User Interface Section -->
10
+ <div class="settings-container-section">
11
+ <h3 id="uiConfigToggle" class="collapsible-toggle">🖌️ User Interface <span>▼</span></h3>
12
+ <div id="uiConfiguration" class="collapsible-content hidden">
13
+ <!-- Dark Mode -->
14
+ <div class="toggle-title">
15
+ <label for="darkModeToggle">🌙 Dark Mode:</label>
16
+ <div id="darkModeToggle" class="svg-toggle" data-state="off">
17
+ <img src="{% static 'rest_mode/svg/toggle_off.svg' %}" alt="Toggle Off">
18
+ </div>
19
+ </div>
20
+
21
+ <!-- Colour -->
22
+ <div class="theme-dropdown">
23
+ <label for="colorSelect">🎨&nbsp;Colour:</label><select id="colorSelect">
24
+ <option value="corporate">Corporate</option>
25
+ <option value="pastel">Pastel</option>
26
+ <option value="tropical">Tropical</option>
27
+ </select>
28
+ </div>
29
+
30
+ <!-- Layout -->
31
+ <div class="theme-dropdown">
32
+ <label for="layoutSelect">🖥️&nbsp;Layout:</label>
33
+ <select id="layoutSelect">
34
+ <option value="messenger-layout">Messenger</option>
35
+ <option value="mobile-layout">Mobile</option>
36
+ <option value="minimalist-layout">Minimalist</option>
37
+ </select>
38
+ </div>
39
+
40
+ <!-- Mobile UI Master Toggle -->
41
+ <div class="settings-container-section">
42
+ <h4 id="mobileUIToggleTitle" class="collapsible-toggle">📱 Mobile UI <span>▼</span></h4>
43
+ <div id="mobileUIConfiguration" class="collapsible-content hidden">
44
+ <!-- Master Toggle -->
45
+ <div class="toggle-title">
46
+ <label for="mobileUIToggle">Enable Mobile UI:</label>
47
+ <div id="mobileUIToggle" class="svg-toggle" data-state="off">
48
+ <img src="{% static 'rest_mode/svg/toggle_off.svg' %}" alt="Toggle Off">
49
+ </div>
50
+ </div>
51
+ <!-- Nested Toggles -->
52
+ <div id="mobileUIOptions" class="nested-container">
53
+ <div class="nested-toggle">
54
+ <label for="alwaysVisibleButtonsToggle">Always Visible Buttons:</label>
55
+ <div id="alwaysVisibleButtonsToggle" class="svg-toggle" data-state="off">
56
+ <img src="{% static 'rest_mode/svg/toggle_off.svg' %}" alt="Toggle Off">
57
+ </div>
58
+ </div>
59
+ <div class="nested-toggle">
60
+ <label for="revealTopBarToggle">Reveal Top Bar When Up Scroll:</label>
61
+ <div id="revealTopBarToggle" class="svg-toggle" data-state="off">
62
+ <img src="{% static 'rest_mode/svg/toggle_off.svg' %}" alt="Toggle Off">
63
+ </div>
64
+ </div>
65
+ <div class="nested-toggle">
66
+ <label for="swipeLeftSettingsToggle">Swipe Left for Settings:</label>
67
+ <div id="swipeLeftSettingsToggle" class="svg-toggle" data-state="off">
68
+ <img src="{% static 'rest_mode/svg/toggle_off.svg' %}" alt="Toggle Off">
69
+ </div>
70
+ </div>
71
+ <div class="nested-toggle">
72
+ <label for="swipeRightChatHistoryToggle">Swipe Right for Chat History:</label>
73
+ <div id="swipeRightChatHistoryToggle" class="svg-toggle" data-state="off">
74
+ <img src="{% static 'rest_mode/svg/toggle_off.svg' %}" alt="Toggle Off">
75
+ </div>
76
+ </div>
77
+ <div class="nested-toggle">
78
+ <label for="swipeDownControlsToggle">Swipe Down for Controls:</label>
79
+ <div id="swipeDownControlsToggle" class="svg-toggle" data-state="off">
80
+ <img src="{% static 'rest_mode/svg/toggle_off.svg' %}" alt="Toggle Off">
81
+ </div>
82
+ </div>
83
+ </div>
84
+ </div>
85
+ </div>
86
+ </div>
87
+ </div>
88
+
89
+ <!-- LLM Configuration -->
90
+ <div class="settings-container-section">
91
+ <h3 id="llmConfigToggle" class="collapsible-toggle">🧠 LLM Configuration <span>▼</span></h3>
92
+ <div id="llmConfiguration" class="collapsible-content hidden">
93
+ <p>Loading LLM configurations...</p>
94
+ </div>
95
+ </div>
96
+ </div>
97
+ </div>
@@ -0,0 +1,7 @@
1
+ {% load static %}
2
+ <div id="splashScreen" class="splash-screen">
3
+ <div class="splash-content">
4
+ <h1 id="splashText">Connecting to the AI...</h1>
5
+ <small>... trouble connecting? Check the <a href="https://github.com/matthewhand/open-swarm/TROUBLESHOOTING.md">Troubleshooting Guide</a></small>
6
+ </div>
7
+ </div>
@@ -0,0 +1,28 @@
1
+ {% load static %}
2
+ <div class="top-bar">
3
+
4
+
5
+ <!-- Persistent Message Area -->
6
+ <div id="firstUserMessage" class="first-user-message"></div>
7
+
8
+ <!-- Settings (Right) -->
9
+ <div class="top-bar-right">
10
+
11
+ <!-- Blueprint Name and Dropdown -->
12
+ <div class="blueprint-container">
13
+ <h2 id="blueprintTitle" class="blueprint-title"></h2>
14
+
15
+ <!-- Hidden Blueprint Metadata -->
16
+ <div id="blueprintMetadata" class="hidden">
17
+ <h2>Metadata</h2>
18
+ <p>Metadata content will be dynamically updated...</p>
19
+ </div>
20
+
21
+ <!-- Blueprint Dialog -->
22
+ <div id="blueprintDialog" class="blueprint-dialog hidden">
23
+ <!-- Blueprint options will be injected dynamically -->
24
+ </div>
25
+ </div>
26
+
27
+ </div>
28
+ </div>
@@ -0,0 +1,50 @@
1
+ <div class="message-container">
2
+ <!-- Persistent Message Area -->
3
+ <div id="persistentMessage" class="persistent-message">
4
+ <div class="message assistant">
5
+ <span>Welcome to Open-Swarm Chat!</span>
6
+ </div>
7
+ <div id="firstUserMessage">
8
+ <!-- Placeholder for dynamically updated persistent message -->
9
+ </div>
10
+ <div class="message-toolbar">
11
+ <button class="toolbar-btn" aria-label="Edit Persistent Message" title="Edit">
12
+ <img src="{% static 'rest_mode/svg/edit.svg' %}" alt="Edit Icon" class="icon-svg" />
13
+ </button>
14
+ <button class="toolbar-btn" aria-label="Copy Persistent Message" title="Copy">
15
+ <img src="{% static 'rest_mode/svg/copy.svg' %}" alt="Copy Icon" class="icon-svg" />
16
+ </button>
17
+ <button class="toolbar-btn" aria-label="Delete Persistent Message" title="Delete">
18
+ <img src="{% static 'rest_mode/svg/trash.svg' %}" alt="Trash Icon" class="icon-svg" />
19
+ </button>
20
+ </div>
21
+ </div>
22
+
23
+ <!-- Messages -->
24
+ <div id="messageHistory" class="message-history">
25
+ <!-- Example of a user message -->
26
+ <div class="message user">
27
+ <span>Hello, how are you?</span>
28
+ <div class="message-toolbar">
29
+ <button class="toolbar-btn" aria-label="Append to Persistent Message" title="Append">
30
+ <img src="{% static 'rest_mode/svg/plus.svg' %}" alt="Plus Icon" class="icon-svg" />
31
+ </button>
32
+ <button class="toolbar-btn" aria-label="Edit Message" title="Edit">
33
+ <img src="{% static 'rest_mode/svg/edit.svg' %}" alt="Edit Icon" class="icon-svg" />
34
+ </button>
35
+ <button class="toolbar-btn" aria-label="Copy Message" title="Copy">
36
+ <img src="{% static 'rest_mode/svg/copy.svg' %}" alt="Copy Icon" class="icon-svg" />
37
+ </button>
38
+ <button class="toolbar-btn" aria-label="Delete Message" title="Delete">
39
+ <img src="{% static 'rest_mode/svg/trash.svg' %}" alt="Trash Icon" class="icon-svg" />
40
+ </button>
41
+ <button class="toolbar-btn" aria-label="Thumbs Up" title="Thumbs Up">
42
+ <img src="{% static 'rest_mode/svg/thumbs_up.svg' %}" alt="Thumbs Up Icon" class="icon-svg" />
43
+ </button>
44
+ <button class="toolbar-btn" aria-label="Thumbs Down" title="Thumbs Down">
45
+ <img src="{% static 'rest_mode/svg/thumbs_down.svg' %}" alt="Thumbs Down Icon" class="icon-svg" />
46
+ </button>
47
+ </div>
48
+ </div>
49
+ </div>
50
+ </div>
@@ -0,0 +1,30 @@
1
+ {% load static %}
2
+ <!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ {% include 'rest_mode/components/header.html' %}
6
+ <link rel="stylesheet" href="{% static 'rest_mode/css/slack.css' %}">
7
+ <script>
8
+ window.STATIC_URLS = {
9
+ layoutSidebarLeftExpand: "{% static 'contrib/tabler-icons/layout-sidebar-left-expand.svg' %}",
10
+ layoutSidebarLeftCollapse: "{% static 'contrib/tabler-icons/layout-sidebar-left-collapse.svg' %}"
11
+ };
12
+ </script>
13
+ </head>
14
+ <body>
15
+ {% include 'rest_mode/components/top_bar.html' %}
16
+ <div class="container" data-theme-color="corporate" data-theme-dark="false" data-theme-layout="slack-layout">
17
+ <div class="side-panes channel-pane" id="channelPane">
18
+ <h2>Channels</h2>
19
+ <ul id="channelList" class="channel-list"></ul>
20
+ </div>
21
+ <div class="vertical-divider" id="divider-left"></div>
22
+ <div class="main-pane">
23
+ {% include 'rest_mode/components/main_chat_pane.html' %}
24
+ </div>
25
+ <div id="toastContainer"></div>
26
+ </div>
27
+ <script type="module" src="{% static 'contrib/markedjs/marked.min.js' %}"></script>
28
+ <script type="module" src="{% static 'rest_mode/js/slackLogic.js' %}" defer></script>
29
+ </body>
30
+ </html>
@@ -0,0 +1,24 @@
1
+ {% load static %}
2
+ <!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ {% include 'rest_mode/components/header.html' %}
6
+ <title>{{ blueprint_name }} Chat</title>
7
+ <meta name="csrf-token" content="{{ csrf_token }}">
8
+ <link rel="stylesheet" href="{% static 'rest_mode/css/style.css' %}">
9
+ </head>
10
+ <body>
11
+ <div class="container" data-theme-color="corporate" data-theme-dark="false" data-theme-layout="minimal-layout">
12
+ <div class="main-pane">
13
+ <h2 id="blueprintTitle">{{ blueprint_name }}</h2>
14
+ <div id="messageHistory" class="message-container"></div>
15
+ <div class="send-container">
16
+ <input type="text" id="userInput" class="rounded-input" placeholder="Type your message here...">
17
+ <button class="half-cut-button" id="sendButton">Send</button>
18
+ </div>
19
+ </div>
20
+ </div>
21
+ <script type="module" src="{% static 'contrib/markedjs/marked.min.js' %}"></script>
22
+ <script type="module" src="{% static 'rest_mode/js/simpleLogic.js' %}" defer></script>
23
+ </body>
24
+ </html>
@@ -0,0 +1,3 @@
1
+ <div id="{{ contents_div_id }}" class="assistant-message chatbot-text-system mb-2" hx-swap-oob="true">
2
+ {{ message }}
3
+ </div>
@@ -0,0 +1,4 @@
1
+ <div id="message-list" hx-swap-oob="beforeend">
2
+ <div id="{{ contents_div_id }}" class="assistant-message chatbot-text-system add-loading-dots mb-2">
3
+ </div>
4
+ </div>
@@ -0,0 +1,5 @@
1
+ <div id="message-list" hx-swap-oob="beforeend">
2
+ <div class="user-message chatbot-text-system mb-2">
3
+ {{ message_text }}
4
+ </div>
5
+ </div>
swarm/urls.py CHANGED
@@ -1,89 +1,72 @@
1
+ """
2
+ Swarm URL Configuration
3
+ """
4
+ import logging
1
5
  from django.contrib import admin
2
- from django.urls import path, re_path, include
3
- from django.http import HttpResponse
6
+ from django.urls import path, include, reverse_lazy
4
7
  from django.conf import settings
5
- from django.conf.urls.static import static
6
- import os
7
- import logging
8
+ from django.views.generic import RedirectView
9
+ from django.contrib.auth import views as auth_views
8
10
 
9
- # Import specific views from their modules
10
- from swarm.views.core_views import index as core_index_view, serve_swarm_config, custom_login
11
- from swarm.views.chat_views import chat_completions
12
- from swarm.views.model_views import list_models
13
- from swarm.views.message_views import ChatMessageViewSet
14
- from drf_spectacular.views import SpectacularSwaggerView, SpectacularAPIView as HiddenSpectacularAPIView
15
- from rest_framework.routers import DefaultRouter
11
+ from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView
12
+
13
+ from swarm.views.chat_views import ChatCompletionsView, HealthCheckView
14
+ # *** Uncomment and correct the import path ***
15
+ from swarm.views.api_views import ModelsListView
16
+ # from swarm.views.webui_views import index as webui_index # Rename to avoid conflict
16
17
 
17
18
  logger = logging.getLogger(__name__)
18
19
 
19
- def favicon(request):
20
- favicon_path = settings.BASE_DIR / 'assets' / 'images' / 'favicon.ico'
21
- try:
22
- with open(favicon_path, 'rb') as f:
23
- favicon_data = f.read()
24
- return HttpResponse(favicon_data, content_type="image/x-icon")
25
- except FileNotFoundError:
26
- logger.warning("Favicon not found.")
27
- return HttpResponse(status=404)
20
+ # ==============================================================================
21
+ # API URL Patterns (v1)
22
+ # ==============================================================================
23
+ api_urlpatterns = [
24
+ path('chat/completions', ChatCompletionsView.as_view(), name='chat_completions'),
25
+ # *** Uncomment this URL pattern ***
26
+ path('models', ModelsListView.as_view(), name='list_models'),
27
+ path('health', HealthCheckView.as_view(), name='health_check'),
28
+ # Add other v1 API endpoints here
29
+ ]
30
+
31
+ # ==============================================================================
32
+ # Schema URL Patterns
33
+ # ==============================================================================
34
+ schema_urlpatterns = [
35
+ path('schema/', SpectacularAPIView.as_view(), name='schema'),
36
+ path('schema/swagger-ui/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
37
+ path('schema/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='redoc'),
38
+ ]
28
39
 
29
- ENABLE_ADMIN = os.getenv("ENABLE_ADMIN", "false").lower() in ("true", "1", "t")
30
- ENABLE_WEBUI = os.getenv("ENABLE_WEBUI", "true").lower() in ("true", "1", "t")
40
+ # ==============================================================================
41
+ # Main URL Patterns
42
+ # ==============================================================================
43
+ urlpatterns = [
44
+ # Redirect root based on DEBUG setting
45
+ path('', RedirectView.as_view(pattern_name='swagger-ui', permanent=False) if settings.DEBUG else RedirectView.as_view(pattern_name='login', permanent=False)),
31
46
 
32
- logger.debug(f"ENABLE_WEBUI={'true' if ENABLE_WEBUI else 'false'}")
33
- logger.debug(f"ENABLE_ADMIN={'true' if ENABLE_ADMIN else 'false'}")
47
+ # API v1 endpoints
48
+ path('v1/', include(api_urlpatterns)),
34
49
 
35
- router = DefaultRouter()
36
- # Ensure ChatMessageViewSet is available before registering
37
- if ChatMessageViewSet:
38
- router.register(r'v1/chat/messages', ChatMessageViewSet, basename='chatmessage')
39
- else:
40
- logger.warning("ChatMessageViewSet not imported correctly, skipping API registration.")
50
+ # Schema endpoints
51
+ path('api/', include(schema_urlpatterns)),
41
52
 
42
- # Base URL patterns required by Swarm core
43
- # Use the imported view functions directly
44
- base_urlpatterns = [
45
- re_path(r'^health/?$', lambda request: HttpResponse("OK"), name='health_check'),
46
- re_path(r'^v1/chat/completions/?$', chat_completions, name='chat_completions'),
47
- re_path(r'^v1/models/?$', list_models, name='list_models'),
48
- re_path(r'^schema/?$', HiddenSpectacularAPIView.as_view(), name='schema'),
49
- re_path(r'^swagger-ui/?$', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
50
- ]
53
+ # Django Admin (Optional)
54
+ path('admin/', admin.site.urls) if getattr(settings, 'ENABLE_ADMIN', False) else path('admin/', RedirectView.as_view(url=reverse_lazy('login'))),
51
55
 
52
- # Optional Admin URLs
53
- admin_urlpatterns = [path('admin/', admin.site.urls)] if ENABLE_ADMIN else []
56
+ # Authentication Views (Django Built-in)
57
+ path('login/', auth_views.LoginView.as_view(template_name='swarm/login.html'), name='login'),
58
+ path('logout/', auth_views.LogoutView.as_view(next_page=reverse_lazy('login')), name='logout'),
54
59
 
55
- # Optional Web UI URLs
56
- webui_urlpatterns = []
57
- if ENABLE_WEBUI:
58
- webui_urlpatterns = [
59
- path('', core_index_view, name='index'),
60
- path('favicon.ico', favicon, name='favicon'),
61
- path('config/swarm_config.json', serve_swarm_config, name='serve_swarm_config'),
62
- path('accounts/login/', custom_login, name='custom_login'),
63
- ]
64
- if settings.DEBUG:
65
- if settings.STATIC_URL and settings.STATIC_ROOT:
66
- webui_urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
67
- else:
68
- logger.warning("STATIC_URL or STATIC_ROOT not configured, static files may not serve correctly in DEBUG mode.")
60
+ # Web UI (Optional) - Conditionally include based on settings
61
+ # *** Ensure this line remains commented out or removed if webui_index is not defined ***
62
+ # path('webui/', webui_index, name='webui_index') if getattr(settings, 'ENABLE_WEBUI', False) else path('webui/', RedirectView.as_view(url=reverse_lazy('login'))),
63
+ ]
69
64
 
70
- # --- Blueprint URLs are now added dynamically via blueprint_base.py -> django_utils.py ---
71
- blueprint_urlpatterns = [] # Start with empty list, populated by utils
65
+ # Debug logging (optional)
66
+ logger.debug(f"ENABLE_ADMIN={getattr(settings, 'ENABLE_ADMIN', False)}")
67
+ logger.debug(f"ENABLE_WEBUI={getattr(settings, 'ENABLE_WEBUI', False)}")
72
68
 
73
- # Combine all URL patterns
74
- urlpatterns = webui_urlpatterns + admin_urlpatterns + base_urlpatterns + blueprint_urlpatterns + router.urls
69
+ # Example of how to conditionally add URLs based on settings
70
+ # if getattr(settings, 'ENABLE_SOMETHING', False):
71
+ # urlpatterns.append(path('something/', include('something.urls')))
75
72
 
76
- # Log final URL patterns (consider moving this to where patterns are finalized if issues persist)
77
- if settings.DEBUG:
78
- try:
79
- from django.urls import get_resolver
80
- # Note: get_resolver(None) might not reflect dynamically added URLs perfectly here.
81
- # Logging within django_utils might be more accurate for dynamic additions.
82
- final_patterns = get_resolver(None).url_patterns
83
- logger.debug(f"Initial resolved URL patterns ({len(final_patterns)} total):")
84
- # for pattern in final_patterns:
85
- # try: pattern_repr = str(pattern)
86
- # except: pattern_repr = f"[Pattern for {getattr(pattern, 'name', 'unnamed')}]"
87
- # logger.debug(f" {pattern_repr}")
88
- except Exception as e:
89
- logger.error(f"Could not log initial URL patterns: {e}")
@@ -0,0 +1,63 @@
1
+ import logging
2
+ import sys
3
+ from swarm.settings import Settings, LogFormat
4
+
5
+ # Cache for initialized loggers to avoid adding handlers multiple times
6
+ _initialized_loggers = set()
7
+
8
+ def setup_logging(logger_name: str | None = None, level: str | int = Settings().log_level, force_reconfigure: bool = False) -> logging.Logger:
9
+ """
10
+ Configures and returns a logger instance. Ensures handlers are not duplicated
11
+ and prevents propagation to avoid duplicate messages from parent loggers.
12
+
13
+ Args:
14
+ logger_name: Name of the logger. If None, configures the root logger.
15
+ level: Logging level (e.g., 'DEBUG', 'INFO', logging.DEBUG).
16
+ force_reconfigure: If True, remove existing handlers before adding new ones.
17
+
18
+ Returns:
19
+ Configured logger instance.
20
+ """
21
+ log_level = logging.getLevelName(level.upper()) if isinstance(level, str) else level
22
+
23
+ logger = logging.getLogger(logger_name)
24
+ logger_id = logger_name if logger_name is not None else "root"
25
+
26
+ # Check if logger (by name) is already initialized and reconfiguration is not forced
27
+ if logger_id in _initialized_loggers and not force_reconfigure:
28
+ if logger.level != log_level:
29
+ logger.setLevel(log_level)
30
+ return logger
31
+
32
+ # If forcing reconfigure or first time, remove existing handlers
33
+ if force_reconfigure or logger_id not in _initialized_loggers:
34
+ for handler in logger.handlers[:]:
35
+ logger.removeHandler(handler)
36
+ if logger_name is None:
37
+ root_logger = logging.getLogger()
38
+ for handler in root_logger.handlers[:]:
39
+ root_logger.removeHandler(handler)
40
+
41
+ # Set the desired level on the logger
42
+ logger.setLevel(log_level)
43
+
44
+ # Prevent propagation for non-root loggers
45
+ if logger_name is not None:
46
+ logger.propagate = False
47
+ else:
48
+ logger.propagate = True # Root logger should propagate if needed by other libraries
49
+
50
+ # Add the stream handler if no handlers exist after potential removal
51
+ if not logger.handlers:
52
+ handler = logging.StreamHandler(sys.stdout)
53
+ log_format_enum = Settings().log_format
54
+ formatter = logging.Formatter(log_format_enum.value)
55
+ handler.setFormatter(formatter)
56
+ logger.addHandler(handler)
57
+
58
+ _initialized_loggers.add(logger_id)
59
+
60
+ # --- Lower level for specific noisy loggers ---
61
+ logging.getLogger('swarm.extensions.config.config_loader').setLevel(logging.ERROR) # Make config loader quieter by default
62
+
63
+ return logger