open-swarm 0.1.1745274976__py3-none-any.whl → 0.1.1748636259__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 (295) hide show
  1. open_swarm-0.1.1748636259.dist-info/METADATA +188 -0
  2. open_swarm-0.1.1748636259.dist-info/RECORD +82 -0
  3. {open_swarm-0.1.1745274976.dist-info → open_swarm-0.1.1748636259.dist-info}/WHEEL +2 -1
  4. open_swarm-0.1.1748636259.dist-info/entry_points.txt +3 -0
  5. open_swarm-0.1.1748636259.dist-info/top_level.txt +1 -0
  6. swarm/agent/agent.py +49 -0
  7. swarm/auth.py +48 -113
  8. swarm/consumers.py +0 -19
  9. swarm/extensions/blueprint/__init__.py +16 -30
  10. swarm/{core → extensions/blueprint}/agent_utils.py +1 -1
  11. swarm/extensions/blueprint/blueprint_base.py +458 -0
  12. swarm/extensions/blueprint/blueprint_discovery.py +112 -0
  13. swarm/extensions/blueprint/output_utils.py +95 -0
  14. swarm/{core → extensions/blueprint}/spinner.py +21 -30
  15. swarm/extensions/cli/cli_args.py +0 -6
  16. swarm/extensions/cli/commands/blueprint_management.py +9 -47
  17. swarm/extensions/cli/commands/config_management.py +6 -5
  18. swarm/extensions/cli/commands/edit_config.py +7 -16
  19. swarm/extensions/cli/commands/list_blueprints.py +1 -1
  20. swarm/extensions/cli/commands/validate_env.py +4 -11
  21. swarm/extensions/cli/commands/validate_envvars.py +6 -6
  22. swarm/extensions/cli/interactive_shell.py +2 -16
  23. swarm/extensions/config/config_loader.py +201 -107
  24. swarm/{core → extensions/config}/config_manager.py +38 -50
  25. swarm/{core → extensions/config}/server_config.py +0 -32
  26. swarm/extensions/launchers/build_launchers.py +14 -0
  27. swarm/{core → extensions/launchers}/build_swarm_wrapper.py +0 -0
  28. swarm/extensions/launchers/swarm_api.py +64 -8
  29. swarm/extensions/launchers/swarm_cli.py +300 -8
  30. swarm/llm/chat_completion.py +195 -0
  31. swarm/serializers.py +5 -96
  32. swarm/settings.py +111 -99
  33. swarm/urls.py +74 -57
  34. swarm/utils/context_utils.py +4 -10
  35. swarm/utils/general_utils.py +0 -21
  36. swarm/utils/redact.py +36 -23
  37. swarm/views/api_views.py +39 -48
  38. swarm/views/chat_views.py +70 -237
  39. swarm/views/core_views.py +87 -80
  40. swarm/views/model_views.py +121 -64
  41. swarm/views/utils.py +441 -65
  42. swarm/views/web_views.py +2 -2
  43. open_swarm-0.1.1745274976.dist-info/METADATA +0 -874
  44. open_swarm-0.1.1745274976.dist-info/RECORD +0 -318
  45. open_swarm-0.1.1745274976.dist-info/entry_points.txt +0 -4
  46. swarm/blueprints/README.md +0 -68
  47. swarm/blueprints/blueprint_audit_status.json +0 -27
  48. swarm/blueprints/chatbot/README.md +0 -40
  49. swarm/blueprints/chatbot/blueprint_chatbot.py +0 -471
  50. swarm/blueprints/chatbot/metadata.json +0 -23
  51. swarm/blueprints/chatbot/templates/chatbot/chatbot.html +0 -33
  52. swarm/blueprints/chucks_angels/README.md +0 -11
  53. swarm/blueprints/chucks_angels/blueprint_chucks_angels.py +0 -7
  54. swarm/blueprints/chucks_angels/test_basic.py +0 -3
  55. swarm/blueprints/codey/CODEY.md +0 -15
  56. swarm/blueprints/codey/README.md +0 -115
  57. swarm/blueprints/codey/blueprint_codey.py +0 -1072
  58. swarm/blueprints/codey/codey_cli.py +0 -373
  59. swarm/blueprints/codey/instructions.md +0 -17
  60. swarm/blueprints/codey/metadata.json +0 -23
  61. swarm/blueprints/common/operation_box_utils.py +0 -83
  62. swarm/blueprints/digitalbutlers/README.md +0 -11
  63. swarm/blueprints/digitalbutlers/__init__.py +0 -1
  64. swarm/blueprints/digitalbutlers/blueprint_digitalbutlers.py +0 -7
  65. swarm/blueprints/digitalbutlers/test_basic.py +0 -3
  66. swarm/blueprints/divine_code/README.md +0 -3
  67. swarm/blueprints/divine_code/__init__.py +0 -10
  68. swarm/blueprints/divine_code/apps.py +0 -11
  69. swarm/blueprints/divine_code/blueprint_divine_code.py +0 -270
  70. swarm/blueprints/django_chat/apps.py +0 -6
  71. swarm/blueprints/django_chat/blueprint_django_chat.py +0 -268
  72. swarm/blueprints/django_chat/templates/django_chat/django_chat_webpage.html +0 -37
  73. swarm/blueprints/django_chat/urls.py +0 -8
  74. swarm/blueprints/django_chat/views.py +0 -32
  75. swarm/blueprints/echocraft/blueprint_echocraft.py +0 -384
  76. swarm/blueprints/flock/README.md +0 -11
  77. swarm/blueprints/flock/__init__.py +0 -8
  78. swarm/blueprints/flock/blueprint_flock.py +0 -7
  79. swarm/blueprints/flock/test_basic.py +0 -3
  80. swarm/blueprints/geese/README.md +0 -97
  81. swarm/blueprints/geese/blueprint_geese.py +0 -803
  82. swarm/blueprints/geese/geese_cli.py +0 -102
  83. swarm/blueprints/jeeves/README.md +0 -41
  84. swarm/blueprints/jeeves/blueprint_jeeves.py +0 -722
  85. swarm/blueprints/jeeves/jeeves_cli.py +0 -55
  86. swarm/blueprints/jeeves/metadata.json +0 -24
  87. swarm/blueprints/mcp_demo/blueprint_mcp_demo.py +0 -473
  88. swarm/blueprints/messenger/templates/messenger/messenger.html +0 -46
  89. swarm/blueprints/mission_improbable/blueprint_mission_improbable.py +0 -423
  90. swarm/blueprints/monkai_magic/blueprint_monkai_magic.py +0 -340
  91. swarm/blueprints/nebula_shellz/blueprint_nebula_shellz.py +0 -265
  92. swarm/blueprints/omniplex/blueprint_omniplex.py +0 -298
  93. swarm/blueprints/poets/blueprint_poets.py +0 -546
  94. swarm/blueprints/poets/poets_cli.py +0 -23
  95. swarm/blueprints/rue_code/README.md +0 -8
  96. swarm/blueprints/rue_code/blueprint_rue_code.py +0 -448
  97. swarm/blueprints/rue_code/rue_code_cli.py +0 -43
  98. swarm/blueprints/stewie/apps.py +0 -12
  99. swarm/blueprints/stewie/blueprint_family_ties.py +0 -349
  100. swarm/blueprints/stewie/models.py +0 -19
  101. swarm/blueprints/stewie/serializers.py +0 -10
  102. swarm/blueprints/stewie/settings.py +0 -17
  103. swarm/blueprints/stewie/urls.py +0 -11
  104. swarm/blueprints/stewie/views.py +0 -26
  105. swarm/blueprints/suggestion/blueprint_suggestion.py +0 -222
  106. swarm/blueprints/whinge_surf/README.md +0 -22
  107. swarm/blueprints/whinge_surf/__init__.py +0 -1
  108. swarm/blueprints/whinge_surf/blueprint_whinge_surf.py +0 -565
  109. swarm/blueprints/whinge_surf/whinge_surf_cli.py +0 -99
  110. swarm/blueprints/whiskeytango_foxtrot/__init__.py +0 -0
  111. swarm/blueprints/whiskeytango_foxtrot/apps.py +0 -11
  112. swarm/blueprints/whiskeytango_foxtrot/blueprint_whiskeytango_foxtrot.py +0 -339
  113. swarm/blueprints/zeus/__init__.py +0 -2
  114. swarm/blueprints/zeus/apps.py +0 -4
  115. swarm/blueprints/zeus/blueprint_zeus.py +0 -270
  116. swarm/blueprints/zeus/zeus_cli.py +0 -13
  117. swarm/cli/async_input.py +0 -65
  118. swarm/cli/async_input_demo.py +0 -32
  119. swarm/core/blueprint_base.py +0 -769
  120. swarm/core/blueprint_discovery.py +0 -125
  121. swarm/core/blueprint_runner.py +0 -59
  122. swarm/core/blueprint_ux.py +0 -109
  123. swarm/core/build_launchers.py +0 -15
  124. swarm/core/cli/__init__.py +0 -1
  125. swarm/core/cli/commands/__init__.py +0 -1
  126. swarm/core/cli/commands/blueprint_management.py +0 -7
  127. swarm/core/cli/interactive_shell.py +0 -14
  128. swarm/core/cli/main.py +0 -50
  129. swarm/core/cli/utils/__init__.py +0 -1
  130. swarm/core/cli/utils/discover_commands.py +0 -18
  131. swarm/core/config_loader.py +0 -122
  132. swarm/core/output_utils.py +0 -193
  133. swarm/core/session_logger.py +0 -42
  134. swarm/core/slash_commands.py +0 -89
  135. swarm/core/swarm_api.py +0 -68
  136. swarm/core/swarm_cli.py +0 -216
  137. swarm/core/utils/__init__.py +0 -0
  138. swarm/extensions/blueprint/cli_handler.py +0 -197
  139. swarm/extensions/blueprint/runnable_blueprint.py +0 -42
  140. swarm/extensions/cli/utils/__init__.py +0 -1
  141. swarm/extensions/cli/utils/async_input.py +0 -46
  142. swarm/extensions/cli/utils/prompt_user.py +0 -3
  143. swarm/management/__init__.py +0 -0
  144. swarm/management/commands/__init__.py +0 -0
  145. swarm/management/commands/runserver.py +0 -58
  146. swarm/middleware.py +0 -65
  147. swarm/permissions.py +0 -38
  148. swarm/static/contrib/fonts/fontawesome-webfont.ttf +0 -7
  149. swarm/static/contrib/fonts/fontawesome-webfont.woff +0 -7
  150. swarm/static/contrib/fonts/fontawesome-webfont.woff2 +0 -7
  151. swarm/static/contrib/markedjs/marked.min.js +0 -6
  152. swarm/static/contrib/tabler-icons/adjustments-horizontal.svg +0 -27
  153. swarm/static/contrib/tabler-icons/alert-triangle.svg +0 -21
  154. swarm/static/contrib/tabler-icons/archive.svg +0 -21
  155. swarm/static/contrib/tabler-icons/artboard.svg +0 -27
  156. swarm/static/contrib/tabler-icons/automatic-gearbox.svg +0 -23
  157. swarm/static/contrib/tabler-icons/box-multiple.svg +0 -19
  158. swarm/static/contrib/tabler-icons/carambola.svg +0 -19
  159. swarm/static/contrib/tabler-icons/copy.svg +0 -20
  160. swarm/static/contrib/tabler-icons/download.svg +0 -21
  161. swarm/static/contrib/tabler-icons/edit.svg +0 -21
  162. swarm/static/contrib/tabler-icons/filled/carambola.svg +0 -13
  163. swarm/static/contrib/tabler-icons/filled/paint.svg +0 -13
  164. swarm/static/contrib/tabler-icons/headset.svg +0 -22
  165. swarm/static/contrib/tabler-icons/layout-sidebar-left-collapse.svg +0 -21
  166. swarm/static/contrib/tabler-icons/layout-sidebar-left-expand.svg +0 -21
  167. swarm/static/contrib/tabler-icons/layout-sidebar-right-collapse.svg +0 -21
  168. swarm/static/contrib/tabler-icons/layout-sidebar-right-expand.svg +0 -21
  169. swarm/static/contrib/tabler-icons/message-chatbot.svg +0 -22
  170. swarm/static/contrib/tabler-icons/message-star.svg +0 -22
  171. swarm/static/contrib/tabler-icons/message-x.svg +0 -23
  172. swarm/static/contrib/tabler-icons/message.svg +0 -21
  173. swarm/static/contrib/tabler-icons/paperclip.svg +0 -18
  174. swarm/static/contrib/tabler-icons/playlist-add.svg +0 -22
  175. swarm/static/contrib/tabler-icons/robot.svg +0 -26
  176. swarm/static/contrib/tabler-icons/search.svg +0 -19
  177. swarm/static/contrib/tabler-icons/settings.svg +0 -20
  178. swarm/static/contrib/tabler-icons/thumb-down.svg +0 -19
  179. swarm/static/contrib/tabler-icons/thumb-up.svg +0 -19
  180. swarm/static/css/dropdown.css +0 -22
  181. swarm/static/htmx/htmx.min.js +0 -0
  182. swarm/static/js/dropdown.js +0 -23
  183. swarm/static/rest_mode/css/base.css +0 -470
  184. swarm/static/rest_mode/css/chat-history.css +0 -286
  185. swarm/static/rest_mode/css/chat.css +0 -251
  186. swarm/static/rest_mode/css/chatbot.css +0 -74
  187. swarm/static/rest_mode/css/chatgpt.css +0 -62
  188. swarm/static/rest_mode/css/colors/corporate.css +0 -74
  189. swarm/static/rest_mode/css/colors/pastel.css +0 -81
  190. swarm/static/rest_mode/css/colors/tropical.css +0 -82
  191. swarm/static/rest_mode/css/general.css +0 -142
  192. swarm/static/rest_mode/css/layout.css +0 -167
  193. swarm/static/rest_mode/css/layouts/messenger-layout.css +0 -17
  194. swarm/static/rest_mode/css/layouts/minimalist-layout.css +0 -57
  195. swarm/static/rest_mode/css/layouts/mobile-layout.css +0 -8
  196. swarm/static/rest_mode/css/messages.css +0 -84
  197. swarm/static/rest_mode/css/messenger.css +0 -135
  198. swarm/static/rest_mode/css/settings.css +0 -91
  199. swarm/static/rest_mode/css/simple.css +0 -44
  200. swarm/static/rest_mode/css/slack.css +0 -58
  201. swarm/static/rest_mode/css/style.css +0 -156
  202. swarm/static/rest_mode/css/theme.css +0 -30
  203. swarm/static/rest_mode/css/toast.css +0 -40
  204. swarm/static/rest_mode/js/auth.js +0 -9
  205. swarm/static/rest_mode/js/blueprint.js +0 -41
  206. swarm/static/rest_mode/js/blueprintUtils.js +0 -12
  207. swarm/static/rest_mode/js/chatLogic.js +0 -79
  208. swarm/static/rest_mode/js/debug.js +0 -63
  209. swarm/static/rest_mode/js/events.js +0 -98
  210. swarm/static/rest_mode/js/main.js +0 -19
  211. swarm/static/rest_mode/js/messages.js +0 -264
  212. swarm/static/rest_mode/js/messengerLogic.js +0 -355
  213. swarm/static/rest_mode/js/modules/apiService.js +0 -84
  214. swarm/static/rest_mode/js/modules/blueprintManager.js +0 -162
  215. swarm/static/rest_mode/js/modules/chatHistory.js +0 -110
  216. swarm/static/rest_mode/js/modules/debugLogger.js +0 -14
  217. swarm/static/rest_mode/js/modules/eventHandlers.js +0 -107
  218. swarm/static/rest_mode/js/modules/messageProcessor.js +0 -120
  219. swarm/static/rest_mode/js/modules/state.js +0 -7
  220. swarm/static/rest_mode/js/modules/userInteractions.js +0 -29
  221. swarm/static/rest_mode/js/modules/validation.js +0 -23
  222. swarm/static/rest_mode/js/rendering.js +0 -119
  223. swarm/static/rest_mode/js/settings.js +0 -130
  224. swarm/static/rest_mode/js/sidebar.js +0 -94
  225. swarm/static/rest_mode/js/simpleLogic.js +0 -37
  226. swarm/static/rest_mode/js/slackLogic.js +0 -66
  227. swarm/static/rest_mode/js/splash.js +0 -76
  228. swarm/static/rest_mode/js/theme.js +0 -111
  229. swarm/static/rest_mode/js/toast.js +0 -36
  230. swarm/static/rest_mode/js/ui.js +0 -265
  231. swarm/static/rest_mode/js/validation.js +0 -57
  232. swarm/static/rest_mode/svg/animated_spinner.svg +0 -12
  233. swarm/static/rest_mode/svg/arrow_down.svg +0 -5
  234. swarm/static/rest_mode/svg/arrow_left.svg +0 -5
  235. swarm/static/rest_mode/svg/arrow_right.svg +0 -5
  236. swarm/static/rest_mode/svg/arrow_up.svg +0 -5
  237. swarm/static/rest_mode/svg/attach.svg +0 -8
  238. swarm/static/rest_mode/svg/avatar.svg +0 -7
  239. swarm/static/rest_mode/svg/canvas.svg +0 -6
  240. swarm/static/rest_mode/svg/chat_history.svg +0 -4
  241. swarm/static/rest_mode/svg/close.svg +0 -5
  242. swarm/static/rest_mode/svg/copy.svg +0 -4
  243. swarm/static/rest_mode/svg/dark_mode.svg +0 -3
  244. swarm/static/rest_mode/svg/edit.svg +0 -5
  245. swarm/static/rest_mode/svg/layout.svg +0 -9
  246. swarm/static/rest_mode/svg/logo.svg +0 -29
  247. swarm/static/rest_mode/svg/logout.svg +0 -5
  248. swarm/static/rest_mode/svg/mobile.svg +0 -5
  249. swarm/static/rest_mode/svg/new_chat.svg +0 -4
  250. swarm/static/rest_mode/svg/not_visible.svg +0 -5
  251. swarm/static/rest_mode/svg/plus.svg +0 -7
  252. swarm/static/rest_mode/svg/run_code.svg +0 -6
  253. swarm/static/rest_mode/svg/save.svg +0 -4
  254. swarm/static/rest_mode/svg/search.svg +0 -6
  255. swarm/static/rest_mode/svg/settings.svg +0 -4
  256. swarm/static/rest_mode/svg/speaker.svg +0 -5
  257. swarm/static/rest_mode/svg/stop.svg +0 -6
  258. swarm/static/rest_mode/svg/thumbs_down.svg +0 -3
  259. swarm/static/rest_mode/svg/thumbs_up.svg +0 -3
  260. swarm/static/rest_mode/svg/toggle_off.svg +0 -6
  261. swarm/static/rest_mode/svg/toggle_on.svg +0 -6
  262. swarm/static/rest_mode/svg/trash.svg +0 -10
  263. swarm/static/rest_mode/svg/undo.svg +0 -3
  264. swarm/static/rest_mode/svg/visible.svg +0 -8
  265. swarm/static/rest_mode/svg/voice.svg +0 -10
  266. swarm/templates/account/login.html +0 -22
  267. swarm/templates/account/signup.html +0 -32
  268. swarm/templates/base.html +0 -30
  269. swarm/templates/chat.html +0 -43
  270. swarm/templates/index.html +0 -35
  271. swarm/templates/rest_mode/components/chat_sidebar.html +0 -55
  272. swarm/templates/rest_mode/components/header.html +0 -45
  273. swarm/templates/rest_mode/components/main_chat_pane.html +0 -41
  274. swarm/templates/rest_mode/components/settings_dialog.html +0 -97
  275. swarm/templates/rest_mode/components/splash_screen.html +0 -7
  276. swarm/templates/rest_mode/components/top_bar.html +0 -28
  277. swarm/templates/rest_mode/message_ui.html +0 -50
  278. swarm/templates/rest_mode/slackbot.html +0 -30
  279. swarm/templates/simple_blueprint_page.html +0 -24
  280. swarm/templates/websocket_partials/final_system_message.html +0 -3
  281. swarm/templates/websocket_partials/system_message.html +0 -4
  282. swarm/templates/websocket_partials/user_message.html +0 -5
  283. swarm/utils/ansi_box.py +0 -34
  284. swarm/utils/disable_tracing.py +0 -38
  285. swarm/utils/log_utils.py +0 -63
  286. swarm/utils/openai_patch.py +0 -33
  287. swarm/ux/ansi_box.py +0 -43
  288. swarm/ux/spinner.py +0 -53
  289. {open_swarm-0.1.1745274976.dist-info → open_swarm-0.1.1748636259.dist-info}/licenses/LICENSE +0 -0
  290. /swarm/{core → extensions/blueprint}/blueprint_utils.py +0 -0
  291. /swarm/{core → extensions/blueprint}/common_utils.py +0 -0
  292. /swarm/{core → extensions/config}/setup_wizard.py +0 -0
  293. /swarm/{blueprints/rue_code → extensions/config/utils}/__init__.py +0 -0
  294. /swarm/{core → extensions/config}/utils/logger.py +0 -0
  295. /swarm/{core → extensions/launchers}/swarm_wrapper.py +0 -0
@@ -1,355 +0,0 @@
1
- async function fetchBlueprints() {
2
- console.log('Fetching blueprints from /v1/models/ at:', new Date().toISOString());
3
- try {
4
- const response = await fetch('/v1/models/');
5
- if (!response.ok) throw new Error(`HTTP error! Status: ${response.status}`);
6
- const data = await response.json();
7
- console.log('Raw response from /v1/models/:', data); // Print the raw response
8
- const blueprints = data.data.filter(model => model.object === 'model');
9
- console.log('Filtered blueprints:', blueprints);
10
- return blueprints;
11
- } catch (error) {
12
- console.error('Error fetching blueprints:', error);
13
- return [];
14
- }
15
- }
16
-
17
- function populateChannelList(blueprints) {
18
- console.log('Populating channel list with blueprints:', blueprints);
19
- const list = document.getElementById('channelList');
20
- if (!list) {
21
- console.error('Channel list element not found!');
22
- return;
23
- }
24
- console.log('Channel list found, initial HTML:', list.innerHTML);
25
- list.innerHTML = ''; // Clear to ensure test data
26
- // Preserve or add pseudo-channel
27
- const existingPseudo = list.querySelector('li[data-blueprint-id="welcome"]');
28
- if (!existingPseudo) {
29
- list.innerHTML += '<li data-blueprint-id="welcome">#Welcome to Open-Swarm</li>';
30
- console.log('Added pseudo-channel');
31
- }
32
- // Force test data
33
- const testData = [
34
- { id: 'test1', title: 'Test Channel 1' },
35
- { id: 'test2', title: 'Test Channel 2' }
36
- ];
37
- testData.forEach(bp => {
38
- if (!list.querySelector(`li[data-blueprint-id="${bp.id}"]`)) {
39
- const li = document.createElement('li');
40
- li.textContent = `# ${bp.title}`;
41
- li.dataset.blueprintId = bp.id;
42
- li.addEventListener('click', () => switchChannel(bp.id));
43
- list.appendChild(li);
44
- console.log('Added test channel:', bp.title);
45
- }
46
- });
47
- blueprints.forEach(bp => {
48
- if (!list.querySelector(`li[data-blueprint-id="${bp.id}"]`)) {
49
- const li = document.createElement('li');
50
- li.textContent = `# ${bp.title}`;
51
- li.dataset.blueprintId = bp.id;
52
- li.addEventListener('click', () => switchChannel(bp.id));
53
- list.appendChild(li);
54
- console.log('Added blueprint:', bp.title);
55
- }
56
- });
57
- console.log('Channel list updated:', list.innerHTML);
58
- }
59
-
60
- let currentBlueprint = null;
61
- function switchChannel(blueprintId) {
62
- currentBlueprint = blueprintId;
63
- document.getElementById('messageHistory').innerHTML = '';
64
- document.getElementById('blueprintTitle').textContent = blueprintId;
65
- console.log(`Switched to channel: ${blueprintId}`);
66
- }
67
-
68
- async function handleSubmit(event) {
69
- event.preventDefault();
70
- const input = document.getElementById('userInput');
71
- const message = input.value.trim();
72
- if (!message || !currentBlueprint) {
73
- console.log('No message or blueprint selected, skipping submission');
74
- return;
75
- }
76
- input.value = '';
77
- const history = document.getElementById('messageHistory');
78
- history.innerHTML += `<div class="user-message">${message}</div>`;
79
- try {
80
- const response = await fetch('/v1/chat/completions/', {
81
- method: 'POST',
82
- headers: {
83
- 'Content-Type': 'application/json',
84
- 'X-CSRFToken': document.querySelector('meta[name="csrf-token"]').content
85
- },
86
- body: JSON.stringify({
87
- model: currentBlueprint,
88
- messages: [{ role: 'user', content: message }]
89
- })
90
- });
91
- const data = await response.json();
92
- history.innerHTML += `<div class="assistant-message">${data.choices[0].message.content}</div>`;
93
- history.scrollTop = history.scrollHeight;
94
- } catch (error) {
95
- console.error('Error submitting message:', error);
96
- history.innerHTML += `<div class="error-message">Error: ${error.message}</div>`;
97
- }
98
- }
99
-
100
- document.addEventListener('DOMContentLoaded', () => {
101
- console.log('DOM fully loaded, initializing Messenger at:', new Date().toISOString());
102
- const blueprints = []; // Disable fetch to test DOM with test data
103
- populateChannelList(blueprints);
104
- if (blueprints.length > 0) {
105
- switchChannel(blueprints[0].id);
106
- } else {
107
- console.log('No blueprints available, using test data at:', new Date().toISOString());
108
- }
109
- document.getElementById('sendButton').addEventListener('click', handleSubmit);
110
- document.getElementById('userInput').addEventListener('keypress', (e) => {
111
- if (e.key === 'Enter') handleSubmit(e);
112
- });
113
- });
114
- // Append debugging and test data
115
- console.log('Appending debug at:', new Date().toISOString());
116
- const originalPopulate = populateChannelList;
117
- populateChannelList = function(blueprints) {
118
- console.log('Original populate called with:', blueprints);
119
- originalPopulate(blueprints); // Call your original function
120
- // Force test data
121
- const testData = [
122
- { id: 'test1', title: 'Test Channel 1' },
123
- { id: 'test2', title: 'Test Channel 2' }
124
- ];
125
- const list = document.getElementById('channelList');
126
- if (list) {
127
- testData.forEach(bp => {
128
- if (!list.querySelector(`li[data-blueprint-id="${bp.id}"]`)) {
129
- const li = document.createElement('li');
130
- li.textContent = `# ${bp.title}`;
131
- li.dataset.blueprintId = bp.id;
132
- li.addEventListener('click', () => switchChannel(bp.id));
133
- list.appendChild(li);
134
- console.log('Added test channel:', bp.title, 'at:', new Date().toISOString());
135
- }
136
- });
137
- console.log('Channel list updated with test data:', list.innerHTML);
138
- } else {
139
- console.error('Channel list not found during test data append!');
140
- }
141
- };
142
- // Append debug and test data
143
- console.log('Appending debug at:', new Date().toISOString());
144
- const originalFetch = fetchBlueprints;
145
- fetchBlueprints = async function() {
146
- console.log('Fetching blueprints with debug at:', new Date().toISOString());
147
- const blueprints = await originalFetch();
148
- console.log('Fetch result:', blueprints);
149
- return blueprints;
150
- };
151
- const originalPopulate = populateChannelList;
152
- populateChannelList = function(blueprints) {
153
- console.log('Populating with debug:', blueprints);
154
- originalPopulate(blueprints);
155
- if (blueprints.length === 0) {
156
- const testData = [
157
- { id: 'test1', title: 'Test Channel 1' },
158
- { id: 'test2', title: 'Test Channel 2' }
159
- ];
160
- const list = document.getElementById('channelList');
161
- if (list) {
162
- testData.forEach(bp => {
163
- if (!list.querySelector(`li[data-blueprint-id="${bp.id}"]`)) {
164
- const li = document.createElement('li');
165
- li.textContent = `# ${bp.title}`;
166
- li.dataset.blueprintId = bp.id;
167
- li.addEventListener('click', () => switchChannel(bp.id));
168
- list.appendChild(li);
169
- console.log('Added test channel:', bp.title);
170
- }
171
- });
172
- console.log('Updated with test data:', list.innerHTML);
173
- }
174
- }
175
- };
176
- // Append debug and test data
177
- console.log('Debug append at:', new Date().toISOString());
178
- const originalPopulate = populateChannelList;
179
- populateChannelList = function(blueprints) {
180
- console.log('Populating with:', blueprints);
181
- originalPopulate(blueprints);
182
- const testData = [
183
- { id: 'test1', title: 'Test Channel 1' },
184
- { id: 'test2', title: 'Test Channel 2' }
185
- ];
186
- const list = document.getElementById('channelList');
187
- if (list) {
188
- testData.forEach(bp => {
189
- if (!list.querySelector(`li[data-blueprint-id="${bp.id}"]`)) {
190
- const li = document.createElement('li');
191
- li.textContent = `# ${bp.title}`;
192
- li.dataset.blueprintId = bp.id;
193
- li.addEventListener('click', () => switchChannel(bp.id));
194
- list.appendChild(li);
195
- console.log('Added test:', bp.title);
196
- }
197
- });
198
- console.log('List after test:', list.innerHTML);
199
- } else {
200
- console.error('No channel list found!');
201
- }
202
- };
203
- // Append debug and test data
204
- console.log('MessengerLogic debug append at:', new Date().toISOString());
205
- const originalFetch = fetchBlueprints;
206
- fetchBlueprints = async function() {
207
- console.log('Executing fetchBlueprints at:', new Date().toISOString());
208
- const response = await originalFetch();
209
- console.log('Fetch result from /v1/models/:', response);
210
- return response;
211
- };
212
- const originalPopulate = populateChannelList;
213
- populateChannelList = function(blueprints) {
214
- console.log('Executing populateChannelList with:', blueprints);
215
- originalPopulate(blueprints);
216
- if (blueprints.length === 0 || !blueprints) {
217
- console.log('No blueprints, forcing test data at:', new Date().toISOString());
218
- const testData = [
219
- { id: 'test1', title: 'Test Channel 1' },
220
- { id: 'test2', title: 'Test Channel 2' }
221
- ];
222
- const list = document.getElementById('channelList');
223
- if (list) {
224
- testData.forEach(bp => {
225
- if (!list.querySelector(`li[data-blueprint-id="${bp.id}"]`)) {
226
- const li = document.createElement('li');
227
- li.textContent = `# ${bp.title}`;
228
- li.dataset.blueprintId = bp.id;
229
- li.addEventListener('click', () => switchChannel(bp.id));
230
- list.appendChild(li);
231
- console.log('Populated test channel:', bp.title);
232
- }
233
- });
234
- console.log('Channel list after population:', list.innerHTML);
235
- } else {
236
- console.error('Channel list not found!');
237
- }
238
- }
239
- };
240
- // Append debug and test data
241
- console.log('MessengerLogic debug append at:', new Date().toISOString());
242
- const originalFetch = fetchBlueprints;
243
- fetchBlueprints = async function() {
244
- console.log('Executing fetchBlueprints at:', new Date().toISOString());
245
- const response = await originalFetch();
246
- console.log('Fetch result from /v1/models/:', response);
247
- return response;
248
- };
249
- const originalPopulate = populateChannelList;
250
- populateChannelList = function(blueprints) {
251
- console.log('Executing populateChannelList with:', blueprints);
252
- originalPopulate(blueprints);
253
- if (blueprints.length === 0 || !blueprints) {
254
- console.log('No blueprints, forcing test data at:', new Date().toISOString());
255
- const testData = [
256
- { id: 'test1', title: 'Test Channel 1' },
257
- { id: 'test2', title: 'Test Channel 2' }
258
- ];
259
- const list = document.getElementById('channelList');
260
- if (list) {
261
- testData.forEach(bp => {
262
- if (!list.querySelector(`li[data-blueprint-id="${bp.id}"]`)) {
263
- const li = document.createElement('li');
264
- li.textContent = `# ${bp.title}`;
265
- li.dataset.blueprintId = bp.id;
266
- li.addEventListener('click', () => switchChannel(bp.id));
267
- list.appendChild(li);
268
- console.log('Populated test channel:', bp.title);
269
- }
270
- });
271
- console.log('Channel list after population:', list.innerHTML);
272
- } else {
273
- console.error('Channel list not found!');
274
- }
275
- }
276
- };
277
- // Append load check and test data
278
- console.log('MessengerLogic loaded at:', new Date().toISOString());
279
- const originalPopulate = populateChannelList;
280
- populateChannelList = function(blueprints) {
281
- console.log('Populating with blueprints at:', new Date().toISOString(), blueprints);
282
- originalPopulate(blueprints);
283
- if (!blueprints || blueprints.length === 0) {
284
- console.log('No blueprints, adding test data at:', new Date().toISOString());
285
- const testData = [
286
- { id: 'test1', title: 'Test Channel 1' },
287
- { id: 'test2', title: 'Test Channel 2' }
288
- ];
289
- const list = document.getElementById('channelList');
290
- if (list) {
291
- testData.forEach(bp => {
292
- if (!list.querySelector(`li[data-blueprint-id="${bp.id}"]`)) {
293
- const li = document.createElement('li');
294
- li.textContent = `# ${bp.title}`;
295
- li.dataset.blueprintId = bp.id;
296
- li.addEventListener('click', () => switchChannel(bp.id));
297
- list.appendChild(li);
298
- console.log('Added test channel:', bp.title);
299
- }
300
- });
301
- console.log('Channel list updated:', list.innerHTML);
302
- } else {
303
- console.error('Channel list not found!');
304
- }
305
- }
306
- };
307
- // Append debug and combine ideas
308
- console.log('Debug append at:', new Date().toISOString());
309
- const originalFetch = fetchBlueprints;
310
- fetchBlueprints = async function() {
311
- console.log('Fetching blueprints like dropdown at:', new Date().toISOString());
312
- const blueprints = await originalFetch();
313
- console.log('Fetch result (like Chatbot dropdown):', blueprints);
314
- return blueprints;
315
- };
316
- const originalPopulate = populateChannelList;
317
- populateChannelList = function(blueprints) {
318
- console.log('Populating like pseudo-channel with:', blueprints);
319
- originalPopulate(blueprints); // Your logic
320
- if (!blueprints || blueprints.length === 0) {
321
- console.log('No blueprints, adding test channels at:', new Date().toISOString());
322
- const testData = [
323
- { id: 'test1', title: 'Test Channel 1' },
324
- { id: 'test2', title: 'Test Channel 2' }
325
- ];
326
- const list = document.getElementById('channelList');
327
- if (list) {
328
- testData.forEach(bp => {
329
- if (!list.querySelector(`li[data-blueprint-id="${bp.id}"]`)) {
330
- const li = document.createElement('li');
331
- li.textContent = `# ${bp.title}`;
332
- li.dataset.blueprintId = bp.id;
333
- li.addEventListener('click', () => switchChannel(bp.id));
334
- list.appendChild(li);
335
- console.log('Added test channel (like pseudo):', bp.title);
336
- }
337
- });
338
- console.log('Channel list updated:', list.innerHTML);
339
- }
340
- }
341
- };
342
- // Append fetch debug
343
- console.log('Debug append at:', new Date().toISOString());
344
- const originalFetch = fetchBlueprints;
345
- fetchBlueprints = async function() {
346
- console.log('Fetching blueprints at:', new Date().toISOString());
347
- try {
348
- const response = await originalFetch();
349
- console.log('Fetch result from /v1/models/:', response);
350
- return response;
351
- } catch (error) {
352
- console.error('Fetch error:', error);
353
- return [];
354
- }
355
- };
@@ -1,84 +0,0 @@
1
- // src/swarm/static/rest_mode/js/modules/apiService.js
2
-
3
- import { showToast } from '../toast.js';
4
- import { debugLog } from './debugLogger.js';
5
-
6
- /**
7
- * Handles all API interactions.
8
- */
9
-
10
- /**
11
- * Fetches blueprint metadata from the server.
12
- * @returns {Promise<Array>} - Returns a promise that resolves to the list of blueprints.
13
- */
14
- export async function fetchBlueprintMetadata() {
15
- try {
16
- const response = await fetch('/v1/models/');
17
- if (!response.ok) throw new Error('Failed to fetch metadata.');
18
-
19
- const data = await response.json();
20
- showToast('Retrieved blueprint metadata.', 'info');
21
- return data.data || [];
22
- } catch (error) {
23
- debugLog('Error fetching blueprint metadata:', error);
24
- showToast('❌ Could not retrieve blueprint metadata.', 'error');
25
- return [];
26
- }
27
- }
28
-
29
- /**
30
- * Submits a user message to the server and retrieves the assistant's response.
31
- * @param {string} modelName - The model to use for generating responses.
32
- * @param {Array} messages - The chat history messages.
33
- * @param {Object} contextVariables - Context variables for the chat.
34
- * @returns {Promise<Object>} - Returns a promise that resolves to the server's response.
35
- */
36
- export async function submitMessage(modelName, messages, contextVariables) {
37
- try {
38
- const response = await fetch('/v1/chat/completions', {
39
- method: 'POST',
40
- headers: {
41
- 'Content-Type': 'application/json',
42
- 'X-CSRFToken': document.querySelector('meta[name="csrf-token"]')?.getAttribute('content') || '',
43
- },
44
- body: JSON.stringify({
45
- model: modelName,
46
- messages: messages,
47
- context_variables: contextVariables,
48
- }),
49
- });
50
-
51
- if (!response.ok) throw new Error(`HTTP Error: ${response.status}`);
52
-
53
- const data = await response.json();
54
- return data;
55
- } catch (error) {
56
- debugLog('Error submitting message:', error);
57
- showToast('⚠️ Error submitting message. Please try again.', 'error');
58
- throw error;
59
- }
60
- }
61
-
62
- /**
63
- * Deletes a chat by its ID.
64
- * @param {string} chatId - The ID of the chat to delete.
65
- * @returns {Promise<boolean>} - Returns true if deletion was successful.
66
- */
67
- export async function deleteChat(chatId) {
68
- try {
69
- const response = await fetch(`/v1/chat/delete/${chatId}`, {
70
- method: 'DELETE',
71
- headers: {
72
- 'Content-Type': 'application/json',
73
- 'X-CSRFToken': document.querySelector('meta[name="csrf-token"]')?.getAttribute('content') || '',
74
- },
75
- });
76
-
77
- if (!response.ok) throw new Error(`HTTP Error: ${response.status}`);
78
- return true;
79
- } catch (error) {
80
- debugLog('Error deleting chat:', error);
81
- showToast('❌ Error deleting chat. Please try again.', 'error');
82
- return false;
83
- }
84
- }
@@ -1,162 +0,0 @@
1
- // src/swarm/static/rest_mode/js/modules/blueprintManager.js
2
-
3
- import { fetchBlueprintMetadata as fetchMetadataAPI } from './apiService.js';
4
- import { showToast } from '../toast.js';
5
- import { appendRawMessage } from '../messages.js';
6
- import { debugLog } from './debugLogger.js';
7
- import { createChatHistoryEntry } from './chatHistory.js';
8
-
9
- /**
10
- * Populates the blueprint selection dialog and dropdown.
11
- * @param {Array} blueprints - The list of blueprints fetched from the API.
12
- */
13
- function populateBlueprintDialog(blueprints) {
14
- const blueprintDialogElement = document.getElementById('blueprintDialog');
15
- const blueprintDropdown = document.getElementById('blueprintDropdown');
16
- const currentPath = window.location.pathname; // Get the current URL path
17
-
18
- if (!blueprintDialogElement) {
19
- debugLog('Blueprint dialog not found.');
20
- return;
21
- }
22
-
23
- // Populate dialog
24
- blueprintDialogElement.innerHTML = blueprints
25
- .map(
26
- (bp) => `
27
- <div class="blueprint-option" data-id="${bp.id}">
28
- <p class="blueprint-title">${bp.title}</p>
29
- <p class="blueprint-description">${bp.description}</p>
30
- </div>`
31
- )
32
- .join('');
33
-
34
- if (!blueprintDropdown) {
35
- debugLog('Blueprint dropdown element not found.');
36
- return;
37
- }
38
-
39
- // Populate dropdown
40
- blueprintDropdown.innerHTML = blueprints
41
- .map(
42
- (bp) => `
43
- <option value="${bp.id}">${bp.title}</option>`
44
- )
45
- .join('');
46
-
47
- // Add click event for each dialog option
48
- blueprintDialogElement.querySelectorAll('.blueprint-option').forEach((option) => {
49
- option.addEventListener('click', () => {
50
- const selectedId = option.getAttribute('data-id');
51
- const selectedBlueprint = blueprints.find((bp) => bp.id === selectedId);
52
- if (selectedBlueprint) {
53
- selectBlueprint(selectedBlueprint, true); // User-initiated selection
54
- }
55
- });
56
- });
57
-
58
- // Add change event for dropdown
59
- blueprintDropdown.addEventListener('change', (event) => {
60
- const selectedId = event.target.value;
61
- const selectedBlueprint = blueprints.find((bp) => bp.id === selectedId);
62
- if (selectedBlueprint) {
63
- selectBlueprint(selectedBlueprint, true); // User-initiated selection
64
- }
65
- });
66
- }
67
-
68
- /**
69
- * Updates the UI and metadata when a blueprint is selected.
70
- * @param {Object} blueprint - The selected blueprint.
71
- * @param {boolean} isUserInitiated - Indicates if the selection was made by the user.
72
- */
73
- export function selectBlueprint(blueprint, isUserInitiated = false) {
74
- const blueprintMetadataElement = document.getElementById('blueprintMetadata');
75
- const blueprintTitleElement = document.getElementById('blueprintTitle');
76
- const blueprintDialogElement = document.getElementById('blueprintDialog');
77
- const blueprintDropdown = document.getElementById('blueprintDropdown');
78
-
79
- if (!blueprintMetadataElement || !blueprintTitleElement || !blueprintDropdown) {
80
- debugLog('Required elements for blueprint selection not found.');
81
- return;
82
- }
83
-
84
- const blueprintName = blueprint.title;
85
- const blueprintDescription = blueprint.description;
86
-
87
- // Update UI
88
- blueprintMetadataElement.innerHTML = `<h2>${blueprintName}</h2><p>${blueprintDescription}</p>`;
89
- blueprintTitleElement.textContent = blueprintName;
90
-
91
- // Update Dropdown Value
92
- blueprintDropdown.value = blueprint.id;
93
-
94
- // Hide the blueprint dialog
95
- if (blueprintDialogElement) {
96
- blueprintDialogElement.classList.add('hidden');
97
- }
98
-
99
- // Optionally, show the dropdown if in advanced mode
100
- // For simple chat mode, keep it hidden
101
- // blueprintDropdown.classList.remove('hidden'); // Uncomment if needed
102
-
103
- // Notify user about blueprint change only if it's user-initiated
104
- if (isUserInitiated) {
105
- appendRawMessage(
106
- 'assistant',
107
- {
108
- content: `Blueprint loaded: ${blueprintName}`,
109
- },
110
- 'Assistant'
111
- );
112
- }
113
-
114
- debugLog('Blueprint selected and UI updated.', blueprint);
115
- }
116
-
117
- /**
118
- * Initializes blueprint management by fetching metadata and populating the UI.
119
- */
120
- export async function initializeBlueprints() {
121
- debugLog('Initializing blueprint management.');
122
- try {
123
- const blueprints = await fetchMetadataAPI();
124
- if (blueprints.length === 0) throw new Error('No blueprints available.');
125
-
126
- // Populate blueprint dialog and dropdown
127
- populateBlueprintDialog(blueprints);
128
-
129
- // Extract blueprint ID from the current path
130
- const currentPath = window.location.pathname;
131
- const pathSegments = currentPath.split('/').filter(segment => segment.length > 0);
132
- const blueprintId = pathSegments.length > 0 ? pathSegments[pathSegments.length - 1] : null;
133
-
134
- debugLog('Current Path:', currentPath);
135
- debugLog('Extracted Blueprint ID:', blueprintId);
136
-
137
- // Find the blueprint with the extracted ID
138
- const matchedBlueprint = blueprints.find(bp => bp.id === blueprintId);
139
-
140
- if (matchedBlueprint) {
141
- debugLog('Matched Blueprint:', matchedBlueprint);
142
- selectBlueprint(matchedBlueprint, false); // Programmatic selection
143
- } else {
144
- debugLog('No matched blueprint found. Selecting default blueprint:', blueprints[0]);
145
- // If no matching blueprint, select the first blueprint as default
146
- const defaultBlueprint = blueprints[0];
147
- selectBlueprint(defaultBlueprint, false); // Programmatic selection
148
- }
149
- } catch (error) {
150
- debugLog('Error fetching blueprint metadata:', error);
151
- console.error('Error initializing blueprints:', error);
152
-
153
- appendRawMessage(
154
- 'assistant',
155
- {
156
- content:
157
- 'Could not retrieve blueprint metadata. Check out the troubleshooting guide at <a href="https://github.com/matthewhand/open-swarm/TROUBLESHOOTING.md">Troubleshooting Guide</a>.',
158
- },
159
- 'Assistant'
160
- );
161
- }
162
- }