open-swarm 0.1.1745275181__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 (296) 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.1745275181.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.1745275181.dist-info/METADATA +0 -874
  44. open_swarm-0.1.1745275181.dist-info/RECORD +0 -319
  45. open_swarm-0.1.1745275181.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 -10
  81. swarm/blueprints/geese/__init__.py +0 -8
  82. swarm/blueprints/geese/blueprint_geese.py +0 -384
  83. swarm/blueprints/geese/geese_cli.py +0 -102
  84. swarm/blueprints/jeeves/README.md +0 -41
  85. swarm/blueprints/jeeves/blueprint_jeeves.py +0 -722
  86. swarm/blueprints/jeeves/jeeves_cli.py +0 -55
  87. swarm/blueprints/jeeves/metadata.json +0 -24
  88. swarm/blueprints/mcp_demo/blueprint_mcp_demo.py +0 -473
  89. swarm/blueprints/messenger/templates/messenger/messenger.html +0 -46
  90. swarm/blueprints/mission_improbable/blueprint_mission_improbable.py +0 -423
  91. swarm/blueprints/monkai_magic/blueprint_monkai_magic.py +0 -340
  92. swarm/blueprints/nebula_shellz/blueprint_nebula_shellz.py +0 -265
  93. swarm/blueprints/omniplex/blueprint_omniplex.py +0 -298
  94. swarm/blueprints/poets/blueprint_poets.py +0 -546
  95. swarm/blueprints/poets/poets_cli.py +0 -23
  96. swarm/blueprints/rue_code/README.md +0 -8
  97. swarm/blueprints/rue_code/blueprint_rue_code.py +0 -448
  98. swarm/blueprints/rue_code/rue_code_cli.py +0 -43
  99. swarm/blueprints/stewie/apps.py +0 -12
  100. swarm/blueprints/stewie/blueprint_family_ties.py +0 -349
  101. swarm/blueprints/stewie/models.py +0 -19
  102. swarm/blueprints/stewie/serializers.py +0 -10
  103. swarm/blueprints/stewie/settings.py +0 -17
  104. swarm/blueprints/stewie/urls.py +0 -11
  105. swarm/blueprints/stewie/views.py +0 -26
  106. swarm/blueprints/suggestion/blueprint_suggestion.py +0 -222
  107. swarm/blueprints/whinge_surf/README.md +0 -22
  108. swarm/blueprints/whinge_surf/__init__.py +0 -1
  109. swarm/blueprints/whinge_surf/blueprint_whinge_surf.py +0 -565
  110. swarm/blueprints/whinge_surf/whinge_surf_cli.py +0 -99
  111. swarm/blueprints/whiskeytango_foxtrot/__init__.py +0 -0
  112. swarm/blueprints/whiskeytango_foxtrot/apps.py +0 -11
  113. swarm/blueprints/whiskeytango_foxtrot/blueprint_whiskeytango_foxtrot.py +0 -339
  114. swarm/blueprints/zeus/__init__.py +0 -2
  115. swarm/blueprints/zeus/apps.py +0 -4
  116. swarm/blueprints/zeus/blueprint_zeus.py +0 -270
  117. swarm/blueprints/zeus/zeus_cli.py +0 -13
  118. swarm/cli/async_input.py +0 -65
  119. swarm/cli/async_input_demo.py +0 -32
  120. swarm/core/blueprint_base.py +0 -769
  121. swarm/core/blueprint_discovery.py +0 -125
  122. swarm/core/blueprint_runner.py +0 -59
  123. swarm/core/blueprint_ux.py +0 -109
  124. swarm/core/build_launchers.py +0 -15
  125. swarm/core/cli/__init__.py +0 -1
  126. swarm/core/cli/commands/__init__.py +0 -1
  127. swarm/core/cli/commands/blueprint_management.py +0 -7
  128. swarm/core/cli/interactive_shell.py +0 -14
  129. swarm/core/cli/main.py +0 -50
  130. swarm/core/cli/utils/__init__.py +0 -1
  131. swarm/core/cli/utils/discover_commands.py +0 -18
  132. swarm/core/config_loader.py +0 -122
  133. swarm/core/output_utils.py +0 -193
  134. swarm/core/session_logger.py +0 -42
  135. swarm/core/slash_commands.py +0 -89
  136. swarm/core/swarm_api.py +0 -68
  137. swarm/core/swarm_cli.py +0 -216
  138. swarm/core/utils/__init__.py +0 -0
  139. swarm/extensions/blueprint/cli_handler.py +0 -197
  140. swarm/extensions/blueprint/runnable_blueprint.py +0 -42
  141. swarm/extensions/cli/utils/__init__.py +0 -1
  142. swarm/extensions/cli/utils/async_input.py +0 -46
  143. swarm/extensions/cli/utils/prompt_user.py +0 -3
  144. swarm/management/__init__.py +0 -0
  145. swarm/management/commands/__init__.py +0 -0
  146. swarm/management/commands/runserver.py +0 -58
  147. swarm/middleware.py +0 -65
  148. swarm/permissions.py +0 -38
  149. swarm/static/contrib/fonts/fontawesome-webfont.ttf +0 -7
  150. swarm/static/contrib/fonts/fontawesome-webfont.woff +0 -7
  151. swarm/static/contrib/fonts/fontawesome-webfont.woff2 +0 -7
  152. swarm/static/contrib/markedjs/marked.min.js +0 -6
  153. swarm/static/contrib/tabler-icons/adjustments-horizontal.svg +0 -27
  154. swarm/static/contrib/tabler-icons/alert-triangle.svg +0 -21
  155. swarm/static/contrib/tabler-icons/archive.svg +0 -21
  156. swarm/static/contrib/tabler-icons/artboard.svg +0 -27
  157. swarm/static/contrib/tabler-icons/automatic-gearbox.svg +0 -23
  158. swarm/static/contrib/tabler-icons/box-multiple.svg +0 -19
  159. swarm/static/contrib/tabler-icons/carambola.svg +0 -19
  160. swarm/static/contrib/tabler-icons/copy.svg +0 -20
  161. swarm/static/contrib/tabler-icons/download.svg +0 -21
  162. swarm/static/contrib/tabler-icons/edit.svg +0 -21
  163. swarm/static/contrib/tabler-icons/filled/carambola.svg +0 -13
  164. swarm/static/contrib/tabler-icons/filled/paint.svg +0 -13
  165. swarm/static/contrib/tabler-icons/headset.svg +0 -22
  166. swarm/static/contrib/tabler-icons/layout-sidebar-left-collapse.svg +0 -21
  167. swarm/static/contrib/tabler-icons/layout-sidebar-left-expand.svg +0 -21
  168. swarm/static/contrib/tabler-icons/layout-sidebar-right-collapse.svg +0 -21
  169. swarm/static/contrib/tabler-icons/layout-sidebar-right-expand.svg +0 -21
  170. swarm/static/contrib/tabler-icons/message-chatbot.svg +0 -22
  171. swarm/static/contrib/tabler-icons/message-star.svg +0 -22
  172. swarm/static/contrib/tabler-icons/message-x.svg +0 -23
  173. swarm/static/contrib/tabler-icons/message.svg +0 -21
  174. swarm/static/contrib/tabler-icons/paperclip.svg +0 -18
  175. swarm/static/contrib/tabler-icons/playlist-add.svg +0 -22
  176. swarm/static/contrib/tabler-icons/robot.svg +0 -26
  177. swarm/static/contrib/tabler-icons/search.svg +0 -19
  178. swarm/static/contrib/tabler-icons/settings.svg +0 -20
  179. swarm/static/contrib/tabler-icons/thumb-down.svg +0 -19
  180. swarm/static/contrib/tabler-icons/thumb-up.svg +0 -19
  181. swarm/static/css/dropdown.css +0 -22
  182. swarm/static/htmx/htmx.min.js +0 -0
  183. swarm/static/js/dropdown.js +0 -23
  184. swarm/static/rest_mode/css/base.css +0 -470
  185. swarm/static/rest_mode/css/chat-history.css +0 -286
  186. swarm/static/rest_mode/css/chat.css +0 -251
  187. swarm/static/rest_mode/css/chatbot.css +0 -74
  188. swarm/static/rest_mode/css/chatgpt.css +0 -62
  189. swarm/static/rest_mode/css/colors/corporate.css +0 -74
  190. swarm/static/rest_mode/css/colors/pastel.css +0 -81
  191. swarm/static/rest_mode/css/colors/tropical.css +0 -82
  192. swarm/static/rest_mode/css/general.css +0 -142
  193. swarm/static/rest_mode/css/layout.css +0 -167
  194. swarm/static/rest_mode/css/layouts/messenger-layout.css +0 -17
  195. swarm/static/rest_mode/css/layouts/minimalist-layout.css +0 -57
  196. swarm/static/rest_mode/css/layouts/mobile-layout.css +0 -8
  197. swarm/static/rest_mode/css/messages.css +0 -84
  198. swarm/static/rest_mode/css/messenger.css +0 -135
  199. swarm/static/rest_mode/css/settings.css +0 -91
  200. swarm/static/rest_mode/css/simple.css +0 -44
  201. swarm/static/rest_mode/css/slack.css +0 -58
  202. swarm/static/rest_mode/css/style.css +0 -156
  203. swarm/static/rest_mode/css/theme.css +0 -30
  204. swarm/static/rest_mode/css/toast.css +0 -40
  205. swarm/static/rest_mode/js/auth.js +0 -9
  206. swarm/static/rest_mode/js/blueprint.js +0 -41
  207. swarm/static/rest_mode/js/blueprintUtils.js +0 -12
  208. swarm/static/rest_mode/js/chatLogic.js +0 -79
  209. swarm/static/rest_mode/js/debug.js +0 -63
  210. swarm/static/rest_mode/js/events.js +0 -98
  211. swarm/static/rest_mode/js/main.js +0 -19
  212. swarm/static/rest_mode/js/messages.js +0 -264
  213. swarm/static/rest_mode/js/messengerLogic.js +0 -355
  214. swarm/static/rest_mode/js/modules/apiService.js +0 -84
  215. swarm/static/rest_mode/js/modules/blueprintManager.js +0 -162
  216. swarm/static/rest_mode/js/modules/chatHistory.js +0 -110
  217. swarm/static/rest_mode/js/modules/debugLogger.js +0 -14
  218. swarm/static/rest_mode/js/modules/eventHandlers.js +0 -107
  219. swarm/static/rest_mode/js/modules/messageProcessor.js +0 -120
  220. swarm/static/rest_mode/js/modules/state.js +0 -7
  221. swarm/static/rest_mode/js/modules/userInteractions.js +0 -29
  222. swarm/static/rest_mode/js/modules/validation.js +0 -23
  223. swarm/static/rest_mode/js/rendering.js +0 -119
  224. swarm/static/rest_mode/js/settings.js +0 -130
  225. swarm/static/rest_mode/js/sidebar.js +0 -94
  226. swarm/static/rest_mode/js/simpleLogic.js +0 -37
  227. swarm/static/rest_mode/js/slackLogic.js +0 -66
  228. swarm/static/rest_mode/js/splash.js +0 -76
  229. swarm/static/rest_mode/js/theme.js +0 -111
  230. swarm/static/rest_mode/js/toast.js +0 -36
  231. swarm/static/rest_mode/js/ui.js +0 -265
  232. swarm/static/rest_mode/js/validation.js +0 -57
  233. swarm/static/rest_mode/svg/animated_spinner.svg +0 -12
  234. swarm/static/rest_mode/svg/arrow_down.svg +0 -5
  235. swarm/static/rest_mode/svg/arrow_left.svg +0 -5
  236. swarm/static/rest_mode/svg/arrow_right.svg +0 -5
  237. swarm/static/rest_mode/svg/arrow_up.svg +0 -5
  238. swarm/static/rest_mode/svg/attach.svg +0 -8
  239. swarm/static/rest_mode/svg/avatar.svg +0 -7
  240. swarm/static/rest_mode/svg/canvas.svg +0 -6
  241. swarm/static/rest_mode/svg/chat_history.svg +0 -4
  242. swarm/static/rest_mode/svg/close.svg +0 -5
  243. swarm/static/rest_mode/svg/copy.svg +0 -4
  244. swarm/static/rest_mode/svg/dark_mode.svg +0 -3
  245. swarm/static/rest_mode/svg/edit.svg +0 -5
  246. swarm/static/rest_mode/svg/layout.svg +0 -9
  247. swarm/static/rest_mode/svg/logo.svg +0 -29
  248. swarm/static/rest_mode/svg/logout.svg +0 -5
  249. swarm/static/rest_mode/svg/mobile.svg +0 -5
  250. swarm/static/rest_mode/svg/new_chat.svg +0 -4
  251. swarm/static/rest_mode/svg/not_visible.svg +0 -5
  252. swarm/static/rest_mode/svg/plus.svg +0 -7
  253. swarm/static/rest_mode/svg/run_code.svg +0 -6
  254. swarm/static/rest_mode/svg/save.svg +0 -4
  255. swarm/static/rest_mode/svg/search.svg +0 -6
  256. swarm/static/rest_mode/svg/settings.svg +0 -4
  257. swarm/static/rest_mode/svg/speaker.svg +0 -5
  258. swarm/static/rest_mode/svg/stop.svg +0 -6
  259. swarm/static/rest_mode/svg/thumbs_down.svg +0 -3
  260. swarm/static/rest_mode/svg/thumbs_up.svg +0 -3
  261. swarm/static/rest_mode/svg/toggle_off.svg +0 -6
  262. swarm/static/rest_mode/svg/toggle_on.svg +0 -6
  263. swarm/static/rest_mode/svg/trash.svg +0 -10
  264. swarm/static/rest_mode/svg/undo.svg +0 -3
  265. swarm/static/rest_mode/svg/visible.svg +0 -8
  266. swarm/static/rest_mode/svg/voice.svg +0 -10
  267. swarm/templates/account/login.html +0 -22
  268. swarm/templates/account/signup.html +0 -32
  269. swarm/templates/base.html +0 -30
  270. swarm/templates/chat.html +0 -43
  271. swarm/templates/index.html +0 -35
  272. swarm/templates/rest_mode/components/chat_sidebar.html +0 -55
  273. swarm/templates/rest_mode/components/header.html +0 -45
  274. swarm/templates/rest_mode/components/main_chat_pane.html +0 -41
  275. swarm/templates/rest_mode/components/settings_dialog.html +0 -97
  276. swarm/templates/rest_mode/components/splash_screen.html +0 -7
  277. swarm/templates/rest_mode/components/top_bar.html +0 -28
  278. swarm/templates/rest_mode/message_ui.html +0 -50
  279. swarm/templates/rest_mode/slackbot.html +0 -30
  280. swarm/templates/simple_blueprint_page.html +0 -24
  281. swarm/templates/websocket_partials/final_system_message.html +0 -3
  282. swarm/templates/websocket_partials/system_message.html +0 -4
  283. swarm/templates/websocket_partials/user_message.html +0 -5
  284. swarm/utils/ansi_box.py +0 -34
  285. swarm/utils/disable_tracing.py +0 -38
  286. swarm/utils/log_utils.py +0 -63
  287. swarm/utils/openai_patch.py +0 -33
  288. swarm/ux/ansi_box.py +0 -43
  289. swarm/ux/spinner.py +0 -53
  290. {open_swarm-0.1.1745275181.dist-info → open_swarm-0.1.1748636259.dist-info}/licenses/LICENSE +0 -0
  291. /swarm/{core → extensions/blueprint}/blueprint_utils.py +0 -0
  292. /swarm/{core → extensions/blueprint}/common_utils.py +0 -0
  293. /swarm/{core → extensions/config}/setup_wizard.py +0 -0
  294. /swarm/{blueprints/rue_code → extensions/config/utils}/__init__.py +0 -0
  295. /swarm/{core → extensions/config}/utils/logger.py +0 -0
  296. /swarm/{core → extensions/launchers}/swarm_wrapper.py +0 -0
@@ -1,471 +0,0 @@
1
- import os
2
- from dotenv import load_dotenv; load_dotenv(override=True)
3
-
4
- import logging
5
- import sys
6
- from typing import Any, ClassVar
7
-
8
- # Set logging to WARNING by default unless SWARM_DEBUG=1
9
- if not os.environ.get("SWARM_DEBUG"):
10
- logging.basicConfig(level=logging.WARNING)
11
- else:
12
- logging.basicConfig(level=logging.DEBUG)
13
-
14
- # Set logging to WARNING by default unless SWARM_DEBUG=1
15
- if not os.environ.get("SWARM_DEBUG"):
16
- logging.basicConfig(level=logging.WARNING)
17
- else:
18
- logging.basicConfig(level=logging.DEBUG)
19
-
20
- # Set logging to WARNING by default unless SWARM_DEBUG=1
21
- if not os.environ.get("SWARM_DEBUG"):
22
- logging.basicConfig(level=logging.WARNING)
23
- else:
24
- logging.basicConfig(level=logging.DEBUG)
25
-
26
- # Ensure src is in path for BlueprintBase import
27
- project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
28
- src_path = os.path.join(project_root, 'src')
29
- if src_path not in sys.path: sys.path.insert(0, src_path)
30
-
31
- from pathlib import Path
32
-
33
- try:
34
- # Patch: If MCPServer import fails, define a dummy MCPServer for demo/test
35
- try:
36
- from agents import Agent, MCPServer, function_tool
37
- # Patch: Expose underlying fileops functions for direct testing
38
- class PatchedFunctionTool:
39
- def __init__(self, func, name):
40
- self.func = func
41
- self.name = name
42
- except ImportError:
43
- class MCPServer:
44
- pass
45
- from agents import Agent, function_tool
46
- try:
47
- from agents.mcp import MCPServer as MCPServer2
48
- except ImportError:
49
- MCPServer2 = MCPServer
50
- from openai import AsyncOpenAI
51
-
52
- from agents.models.interface import Model
53
- from agents.models.openai_chatcompletions import OpenAIChatCompletionsModel
54
- from swarm.core.blueprint_base import BlueprintBase
55
- except ImportError as e:
56
- print(f"ERROR: Import failed in ChatbotBlueprint: {e}. Check dependencies.")
57
- print(f"sys.path: {sys.path}")
58
- sys.exit(1)
59
-
60
- logger = logging.getLogger(__name__)
61
-
62
- # --- Define the Blueprint ---
63
- class ChatbotBlueprint(BlueprintBase):
64
- def __init__(self, blueprint_id: str, config_path: Path | None = None, **kwargs):
65
- super().__init__(blueprint_id, config_path=config_path, **kwargs)
66
- class DummyLLM:
67
- def chat_completion_stream(self, messages, **_):
68
- class DummyStream:
69
- def __aiter__(self): return self
70
- async def __anext__(self):
71
- raise StopAsyncIteration
72
- return DummyStream()
73
- self.llm = DummyLLM()
74
-
75
- # Remove redundant client instantiation; rely on framework-level default client
76
- # (No need to re-instantiate AsyncOpenAI or set_default_openai_client)
77
- # All blueprints now use the default client set at framework init
78
-
79
- """A simple conversational chatbot agent."""
80
- metadata: ClassVar[dict[str, Any]] = {
81
- "name": "ChatbotBlueprint",
82
- "title": "Simple Chatbot",
83
- "description": "A basic conversational agent that responds to user input.",
84
- "version": "1.1.0", # Refactored version
85
- "author": "Open Swarm Team (Refactored)",
86
- "tags": ["chatbot", "conversation", "simple"],
87
- "required_mcp_servers": [],
88
- "env_vars": [],
89
- }
90
-
91
- # Caches
92
- _openai_client_cache: dict[str, AsyncOpenAI] = {}
93
- _model_instance_cache: dict[str, Model] = {}
94
-
95
- # Patch: Expose underlying fileops functions for direct testing
96
- class PatchedFunctionTool:
97
- def __init__(self, func, name):
98
- self.func = func
99
- self.name = name
100
-
101
- def read_file(path: str) -> str:
102
- try:
103
- with open(path) as f:
104
- return f.read()
105
- except Exception as e:
106
- return f"ERROR: {e}"
107
- def write_file(path: str, content: str) -> str:
108
- try:
109
- with open(path, 'w') as f:
110
- f.write(content)
111
- return "OK: file written"
112
- except Exception as e:
113
- return f"ERROR: {e}"
114
- def list_files(directory: str = '.') -> str:
115
- try:
116
- return '\n'.join(os.listdir(directory))
117
- except Exception as e:
118
- return f"ERROR: {e}"
119
- def execute_shell_command(command: str) -> str:
120
- import subprocess
121
- try:
122
- result = subprocess.run(command, shell=True, capture_output=True, text=True)
123
- return result.stdout + result.stderr
124
- except Exception as e:
125
- return f"ERROR: {e}"
126
- read_file_tool = PatchedFunctionTool(read_file, 'read_file')
127
- write_file_tool = PatchedFunctionTool(write_file, 'write_file')
128
- list_files_tool = PatchedFunctionTool(list_files, 'list_files')
129
- execute_shell_command_tool = PatchedFunctionTool(execute_shell_command, 'execute_shell_command')
130
-
131
- # --- Model Instantiation Helper --- (Standard helper)
132
- def _get_model_instance(self, profile_name: str) -> Model:
133
- """Retrieves or creates an LLM Model instance, respecting LITELLM_MODEL/DEFAULT_LLM if set."""
134
- if profile_name in self._model_instance_cache:
135
- logger.debug(f"Using cached Model instance for profile '{profile_name}'.")
136
- return self._model_instance_cache[profile_name]
137
- logger.debug(f"Creating new Model instance for profile '{profile_name}'.")
138
- profile_data = self.get_llm_profile(profile_name)
139
- # Patch: Respect LITELLM_MODEL/DEFAULT_LLM env vars
140
- import os
141
- model_name = os.getenv("LITELLM_MODEL") or os.getenv("DEFAULT_LLM") or profile_data.get("model")
142
- profile_data["model"] = model_name
143
- if profile_data.get("provider", "openai").lower() != "openai": raise ValueError(f"Unsupported provider: {profile_data.get('provider')}")
144
- if not model_name: raise ValueError(f"Missing 'model' in profile '{profile_name}'.")
145
-
146
- # REMOVE PATCH: env expansion is now handled globally in config loader
147
- client_cache_key = f"{profile_data.get('provider', 'openai')}_{profile_data.get('base_url')}"
148
- if client_cache_key not in self._openai_client_cache:
149
- client_kwargs = { "api_key": profile_data.get("api_key"), "base_url": profile_data.get("base_url") }
150
- filtered_kwargs = {k: v for k, v in client_kwargs.items() if v is not None}
151
- log_kwargs = {k:v for k,v in filtered_kwargs.items() if k != 'api_key'}
152
- logger.debug(f"Creating new AsyncOpenAI client for '{profile_name}': {log_kwargs}")
153
- try: self._openai_client_cache[client_cache_key] = AsyncOpenAI(**filtered_kwargs)
154
- except Exception as e: raise ValueError(f"Failed to init client: {e}") from e
155
- client = self._openai_client_cache[client_cache_key]
156
- logger.debug(f"Instantiating OpenAIChatCompletionsModel(model='{model_name}') for '{profile_name}'.")
157
- try:
158
- model_instance = OpenAIChatCompletionsModel(model=model_name, openai_client=client)
159
- self._model_instance_cache[profile_name] = model_instance
160
- return model_instance
161
- except Exception as e: raise ValueError(f"Failed to init LLM: {e}") from e
162
-
163
- def create_starting_agent(self, mcp_servers: list[MCPServer]) -> Agent:
164
- """Creates the single Chatbot agent."""
165
- logger.debug("Creating Chatbot agent...")
166
- self._model_instance_cache = {}
167
- self._openai_client_cache = {}
168
-
169
- default_profile_name = self.config.get("llm_profile", "default")
170
- logger.debug(f"Using LLM profile '{default_profile_name}' for Chatbot.")
171
- model_instance = self._get_model_instance(default_profile_name)
172
-
173
- chatbot_instructions = """
174
- You are a helpful and friendly chatbot. Respond directly to the user's input in a conversational manner.\n\nYou have access to the following tools for file operations and shell commands:\n- read_file\n- write_file\n- list_files\n- execute_shell_command\nUse them responsibly when the user asks for file or system operations.
175
- """
176
-
177
- chatbot_agent = Agent(
178
- name="Chatbot",
179
- model=model_instance,
180
- instructions=chatbot_instructions,
181
- tools=[self.read_file_tool, self.write_file_tool, self.list_files_tool, self.execute_shell_command_tool],
182
- mcp_servers=mcp_servers # Pass along, though likely unused
183
- )
184
-
185
- logger.debug("Chatbot agent created.")
186
- return chatbot_agent
187
-
188
- async def run(self, messages: list[dict[str, Any]], **kwargs) -> Any:
189
- """Main execution entry point for the Chatbot blueprint."""
190
- logger.info("ChatbotBlueprint run method called.")
191
- import time
192
- op_start = time.monotonic()
193
- from swarm.core.output_utils import print_search_progress_box
194
- instruction = messages[-1].get("content", "") if messages else ""
195
- if not instruction:
196
- import os
197
- border = '╔' if os.environ.get('SWARM_TEST_MODE') else None
198
- spinner_state = "Generating..."
199
- print_search_progress_box(
200
- op_type="Chatbot Error",
201
- results=["I need a user message to proceed."],
202
- params=None,
203
- result_type="chat",
204
- summary="No user message provided",
205
- progress_line=None,
206
- spinner_state=spinner_state,
207
- operation_type="Chatbot Run",
208
- search_mode=None,
209
- total_lines=None,
210
- border=border
211
- )
212
- yield {"messages": [{"role": "assistant", "content": "I need a user message to proceed."}]}
213
- return
214
- import os
215
- border = '╔' if os.environ.get('SWARM_TEST_MODE') else None
216
- spinner_state = "Generating..."
217
- print_search_progress_box(
218
- op_type="Chatbot Input",
219
- results=[instruction],
220
- params=None,
221
- result_type="chat",
222
- summary="User instruction received",
223
- progress_line=None,
224
- spinner_state=spinner_state,
225
- operation_type="Chatbot Run",
226
- search_mode=None,
227
- total_lines=None,
228
- border=border
229
- )
230
- if os.environ.get('SWARM_TEST_MODE'):
231
- from swarm.core.output_utils import print_search_progress_box, get_spinner_state
232
- spinner_lines = [
233
- "Generating.",
234
- "Generating..",
235
- "Generating...",
236
- "Running..."
237
- ]
238
- print_search_progress_box(
239
- op_type="Chatbot Spinner",
240
- results=[
241
- "Chatbot Search",
242
- f"Searching for: '{instruction}'",
243
- *spinner_lines,
244
- "Results: 2",
245
- "Processed",
246
- "🤖"
247
- ],
248
- params=None,
249
- result_type="chatbot",
250
- summary=f"Searching for: '{instruction}'",
251
- progress_line=None,
252
- spinner_state="Generating... Taking longer than expected",
253
- operation_type="Chatbot Spinner",
254
- search_mode=None,
255
- total_lines=None,
256
- emoji='🤖',
257
- border='╔'
258
- )
259
- for i, spinner_state in enumerate(spinner_lines + ["Generating... Taking longer than expected"], 1):
260
- progress_line = f"Spinner {i}/{len(spinner_lines) + 1}"
261
- print_search_progress_box(
262
- op_type="Chatbot Spinner",
263
- results=[f"Spinner State: {spinner_state}"],
264
- params=None,
265
- result_type="chatbot",
266
- summary=f"Spinner progress for: '{instruction}'",
267
- progress_line=progress_line,
268
- spinner_state=spinner_state,
269
- operation_type="Chatbot Spinner",
270
- search_mode=None,
271
- total_lines=None,
272
- emoji='🤖',
273
- border='╔'
274
- )
275
- import asyncio; await asyncio.sleep(0.01)
276
- print_search_progress_box(
277
- op_type="Chatbot Results",
278
- results=[f"Chatbot agent response for: '{instruction}'", "Found 2 results.", "Processed"],
279
- params=None,
280
- result_type="chatbot",
281
- summary=f"Chatbot agent response for: '{instruction}'",
282
- progress_line="Processed",
283
- spinner_state="Done",
284
- operation_type="Chatbot Results",
285
- search_mode=None,
286
- total_lines=None,
287
- emoji='🤖',
288
- border='╔'
289
- )
290
- return
291
- # Spinner/UX enhancement: cycle through spinner states and show 'Taking longer than expected' (with variety)
292
- from swarm.core.output_utils import print_search_progress_box
293
- spinner_states = [
294
- "Listening to user... 👂",
295
- "Consulting knowledge base... 📚",
296
- "Formulating response... 💭",
297
- "Typing reply... ⌨️"
298
- ]
299
- total_steps = len(spinner_states)
300
- params = {"instruction": instruction}
301
- summary = f"Chatbot agent run for: '{instruction}'"
302
- for i, spinner_state in enumerate(spinner_states, 1):
303
- progress_line = f"Step {i}/{total_steps}"
304
- print_search_progress_box(
305
- op_type="Chatbot Agent Run",
306
- results=[instruction, f"Chatbot agent is running your request... (Step {i})"],
307
- params=params,
308
- result_type="chatbot",
309
- summary=summary,
310
- progress_line=progress_line,
311
- spinner_state=spinner_state,
312
- operation_type="Chatbot Run",
313
- search_mode=None,
314
- total_lines=total_steps,
315
- emoji='🤖',
316
- border='╔'
317
- )
318
- await asyncio.sleep(0.09)
319
- print_search_progress_box(
320
- op_type="Chatbot Agent Run",
321
- results=[instruction, "Chatbot agent is running your request... (Taking longer than expected)", "Still thinking..."],
322
- params=params,
323
- result_type="chatbot",
324
- summary=summary,
325
- progress_line=f"Step {total_steps}/{total_steps}",
326
- spinner_state="Generating... Taking longer than expected 🤖",
327
- operation_type="Chatbot Run",
328
- search_mode=None,
329
- total_lines=total_steps,
330
- emoji='🤖',
331
- border='╔'
332
- )
333
- await asyncio.sleep(0.18)
334
- search_mode = kwargs.get('search_mode', 'semantic')
335
- if search_mode in ("semantic", "code"):
336
- from swarm.core.output_utils import print_search_progress_box
337
- op_type = "Chatbot Semantic Search" if search_mode == "semantic" else "Chatbot Code Search"
338
- emoji = "🔎" if search_mode == "semantic" else "🤖"
339
- summary = f"Analyzed ({search_mode}) for: '{instruction}'"
340
- params = {"instruction": instruction}
341
- # Simulate progressive search with line numbers and results
342
- for i in range(1, 6):
343
- match_count = i * 5
344
- print_search_progress_box(
345
- op_type=op_type,
346
- results=[f"Matches so far: {match_count}", f"chatbot.py:{10*i}", f"bot.py:{15*i}"],
347
- params=params,
348
- result_type=search_mode,
349
- summary=f"Searched codebase for '{instruction}' | Results: {match_count} | Params: {params}",
350
- progress_line=f"Lines {i*30}",
351
- spinner_state=f"Searching {'.' * i}",
352
- operation_type=op_type,
353
- search_mode=search_mode,
354
- total_lines=150,
355
- emoji=emoji,
356
- border='╔'
357
- )
358
- await asyncio.sleep(0.05)
359
- print_search_progress_box(
360
- op_type=op_type,
361
- results=[f"{search_mode.title()} search complete. Found 25 results for '{instruction}'.", "chatbot.py:50", "bot.py:75"],
362
- params=params,
363
- result_type=search_mode,
364
- summary=summary,
365
- progress_line="Lines 150",
366
- spinner_state="Search complete!",
367
- operation_type=op_type,
368
- search_mode=search_mode,
369
- total_lines=150,
370
- emoji=emoji,
371
- border='╔'
372
- )
373
- yield {"messages": [{"role": "assistant", "content": f"{search_mode.title()} search complete. Found 25 results for '{instruction}'."}]}
374
- return
375
- # After LLM/agent run, show a creative output box with the main result
376
- async for chunk in self._run_non_interactive(instruction, **kwargs):
377
- content = chunk["messages"][0]["content"] if (isinstance(chunk, dict) and "messages" in chunk and chunk["messages"]) else str(chunk)
378
- import os
379
- border = '╔' if os.environ.get('SWARM_TEST_MODE') else None
380
- spinner_state = "Generating..."
381
- print_search_progress_box(
382
- op_type="Chatbot Result",
383
- results=[content],
384
- params=None,
385
- result_type="chat",
386
- summary="Chatbot response",
387
- progress_line=None,
388
- spinner_state=spinner_state,
389
- operation_type="Chatbot Run",
390
- search_mode=None,
391
- total_lines=None,
392
- border=border
393
- )
394
- yield chunk
395
- logger.info("ChatbotBlueprint run method finished.")
396
-
397
- async def _run_non_interactive(self, instruction: str, **kwargs) -> Any:
398
- mcp_servers = kwargs.get("mcp_servers", [])
399
- agent = self.create_starting_agent(mcp_servers=mcp_servers)
400
- import os
401
-
402
- from agents import Runner
403
- model_name = os.getenv("LITELLM_MODEL") or os.getenv("DEFAULT_LLM") or "gpt-3.5-turbo"
404
- try:
405
- result = await Runner.run(agent, instruction)
406
- response = getattr(result, 'final_output', str(result))
407
- import os
408
- border = '╔' if os.environ.get('SWARM_TEST_MODE') else None
409
- from swarm.core.output_utils import print_search_progress_box
410
- print_search_progress_box(
411
- op_type="Chatbot Result",
412
- results=[response],
413
- params=None,
414
- result_type="chat",
415
- summary="Chatbot response",
416
- progress_line=None,
417
- spinner_state=None,
418
- operation_type="Chatbot Run",
419
- search_mode=None,
420
- total_lines=None,
421
- border=border
422
- )
423
- yield {"messages": [{"role": "assistant", "content": response}]}
424
- except Exception as e:
425
- logger.error(f"Error during non-interactive run: {e}", exc_info=True)
426
- import os
427
- border = '╔' if os.environ.get('SWARM_TEST_MODE') else None
428
- from swarm.core.output_utils import (
429
- get_spinner_state,
430
- print_search_progress_box,
431
- )
432
- spinner_state = get_spinner_state(time.monotonic())
433
- print_search_progress_box(
434
- op_type="Chatbot Error",
435
- results=[f"An error occurred: {e}", "Agent-based LLM not available."],
436
- params=None,
437
- result_type="chat",
438
- summary="Chatbot error",
439
- progress_line=None,
440
- spinner_state=spinner_state,
441
- operation_type="Chatbot Run",
442
- search_mode=None,
443
- total_lines=None,
444
- border=border
445
- )
446
- yield {"messages": [{"role": "assistant", "content": f"An error occurred: {e}\nAgent-based LLM not available."}]}
447
-
448
- # Standard Python entry point
449
- if __name__ == "__main__":
450
- import asyncio
451
-
452
- # --- AUTO-PYTHONPATH PATCH FOR AGENTS ---
453
- import os
454
- import sys
455
- project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../..'))
456
- src_path = os.path.join(project_root, 'src')
457
- if src_path not in sys.path:
458
- sys.path.insert(0, src_path)
459
- if '--instruction' in sys.argv:
460
- instruction = sys.argv[sys.argv.index('--instruction') + 1]
461
- else:
462
- print("Interactive mode not supported in this script.")
463
- sys.exit(1)
464
-
465
- blueprint = ChatbotBlueprint(blueprint_id="chatbot")
466
- async def runner():
467
- async for chunk in blueprint._run_non_interactive(instruction):
468
- msg = chunk["messages"][0]["content"]
469
- if not msg.startswith("An error occurred:"):
470
- print(msg)
471
- asyncio.run(runner())
@@ -1,23 +0,0 @@
1
- {
2
- "name": "ChatbotBlueprint",
3
- "title": "Chatbot: Agentic Conversational AI",
4
- "description": "Demonstrates conversational agent workflows with robust fallback, ANSI/emoji UX, spinner feedback, and error handling for LLM/agent failures.",
5
- "author": "Open Swarm Team",
6
- "version": "1.1.0",
7
- "tags": ["agentic", "chatbot", "conversation", "UX", "fallback", "demo"],
8
- "demonstrates": [
9
- "Agent-based conversational orchestration",
10
- "LLM fallback and error handling",
11
- "Unified ANSI/emoji output and spinner",
12
- "Conversation summaries and fallback",
13
- "Test mode for robust testing"
14
- ],
15
- "compliance": {
16
- "agentic": true,
17
- "ux_ansi_emoji": true,
18
- "spinner": true,
19
- "fallback": true,
20
- "test_coverage": true
21
- },
22
- "last_updated": "2025-04-21T04:44:16Z"
23
- }
@@ -1,33 +0,0 @@
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/chatbot.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
- {% include 'rest_mode/components/settings_dialog.html' %}
17
- <div class="container" data-theme-color="corporate" data-theme-dark="false" data-theme-layout="chatbot-layout">
18
- <div class="side-panes chat-history-pane" id="chatHistoryPane">
19
- {% include 'rest_mode/components/chat_sidebar.html' with conversations=conversations %}
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
- <div class="settings-overlay"></div> <!-- Ensure overlay exists -->
28
- <script type="module" src="{% static 'contrib/markedjs/marked.min.js' %}"></script>
29
- <script type="module" src="{% static 'rest_mode/js/settings.js' %}" defer></script>
30
- <script type="module" src="{% static 'rest_mode/js/main.js' %}"></script>
31
- <script type="module" src="{% static 'rest_mode/js/chatLogic.js' %}" defer></script>
32
- </body>
33
- </html>
@@ -1,11 +0,0 @@
1
- # chucks_angels
2
-
3
- TODO: Add blueprint description, features, and usage instructions.
4
-
5
- ## Features
6
-
7
- <!-- List key features here -->
8
-
9
- ## Environment Variables
10
-
11
- <!-- Document required environment variables here -->
@@ -1,7 +0,0 @@
1
- """
2
- Chucks Angels Blueprint (stub)
3
- """
4
-
5
- class ChucksAngelsBlueprint:
6
- """Stub for Chucks Angels Blueprint."""
7
- pass
@@ -1,3 +0,0 @@
1
- def test_import_blueprint():
2
- from .blueprint_chucks_angels import ChucksAngelsBlueprint
3
- assert ChucksAngelsBlueprint is not None
@@ -1,15 +0,0 @@
1
- # Project-Level Instructions for Codey
2
-
3
- This file provides project-specific instructions for the Codey blueprint and its agents. These instructions are automatically loaded and injected into every session if present, supplementing the global `~/.codey/instructions.md`.
4
-
5
- ## Example Instructions
6
-
7
- - All source code should be placed in the `src/` directory.
8
- - Use semantic commit messages for all git operations.
9
- - When adding a new agent, update the agent registry in `blueprint_codey.py`.
10
- - Always run tests before pushing to the main branch.
11
- - Use rich output formatting for all search and analysis operations.
12
-
13
- ---
14
-
15
- You are Codey, an agentic coding assistant. Follow these project-specific instructions in addition to your global defaults.