open-swarm 0.1.1743449197__py3-none-any.whl → 0.1.1744936125__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {open_swarm-0.1.1743449197.dist-info → open_swarm-0.1.1744936125.dist-info}/METADATA +1 -1
- {open_swarm-0.1.1743449197.dist-info → open_swarm-0.1.1744936125.dist-info}/RECORD +6 -6
- swarm/blueprints/chatbot/blueprint_chatbot.py +64 -8
- {open_swarm-0.1.1743449197.dist-info → open_swarm-0.1.1744936125.dist-info}/WHEEL +0 -0
- {open_swarm-0.1.1743449197.dist-info → open_swarm-0.1.1744936125.dist-info}/entry_points.txt +0 -0
- {open_swarm-0.1.1743449197.dist-info → open_swarm-0.1.1744936125.dist-info}/licenses/LICENSE +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: open-swarm
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.1744936125
|
4
4
|
Summary: Open Swarm: Orchestrating AI Agent Swarms with Django
|
5
5
|
Project-URL: Homepage, https://github.com/yourusername/open-swarm
|
6
6
|
Project-URL: Documentation, https://github.com/yourusername/open-swarm/blob/main/README.md
|
@@ -15,7 +15,7 @@ swarm/wsgi.py,sha256=REM_u4HpMCkO0ddrOUXgtY-ITL-VTbRB1-WHvFJAtAU,408
|
|
15
15
|
swarm/agent/__init__.py,sha256=YESGu_UXEBxrlQwghodUMN0vmXZDwWMU7DclCUvoklA,104
|
16
16
|
swarm/blueprints/README.md,sha256=tsngbSB9N0tILcz_m1OGAjyKZQYlGTN-i5e5asq1GbE,8478
|
17
17
|
swarm/blueprints/burnt_noodles/blueprint_burnt_noodles.py,sha256=vopDlBjVUNeSq6WItdkmtWJfObgbtL6wNAy2njsskkY,19607
|
18
|
-
swarm/blueprints/chatbot/blueprint_chatbot.py,sha256=
|
18
|
+
swarm/blueprints/chatbot/blueprint_chatbot.py,sha256=a5-gIyDvRtNgbyfviD9Hua9r5NjOQh1lOafIG2a6kiI,7520
|
19
19
|
swarm/blueprints/chatbot/templates/chatbot/chatbot.html,sha256=REFnqNg0EHsXxAUfaCJe1YgOKiV_umBXuC6y8veF5CU,1568
|
20
20
|
swarm/blueprints/digitalbutlers/blueprint_digitalbutlers.py,sha256=JK_rmZgPMw4PdQFrMverrwgcjH0NRkuqkchYOJwXYuM,9809
|
21
21
|
swarm/blueprints/dilbot_universe/blueprint_dilbot_universe.py,sha256=w7i96KkRNmBOV2Kz9SJqQCirsRPEgENR-79iLOzpKaQ,16770
|
@@ -255,8 +255,8 @@ swarm/views/message_views.py,sha256=sDUnXyqKXC8WwIIMAlWf00s2_a2T9c75Na5FvYMJwBM,
|
|
255
255
|
swarm/views/model_views.py,sha256=aAbU4AZmrOTaPeKMWtoKK7FPYHdaN3Zbx55JfKzYTRY,2937
|
256
256
|
swarm/views/utils.py,sha256=geX3Z5ZDKFYyXYBMilc-4qgOSjhujK3AfRtvbXgFpXk,3643
|
257
257
|
swarm/views/web_views.py,sha256=ExQQeJpZ8CkLZQC_pXKOOmdnEy2qR3wEBP4LLp27DPU,7404
|
258
|
-
open_swarm-0.1.
|
259
|
-
open_swarm-0.1.
|
260
|
-
open_swarm-0.1.
|
261
|
-
open_swarm-0.1.
|
262
|
-
open_swarm-0.1.
|
258
|
+
open_swarm-0.1.1744936125.dist-info/METADATA,sha256=ddaFDVixx5XyE42kg6sn5ZIcFcy7rbfO-z-bl5QpIbI,13678
|
259
|
+
open_swarm-0.1.1744936125.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
260
|
+
open_swarm-0.1.1744936125.dist-info/entry_points.txt,sha256=z1UIVRRhri-V-hWxFkDEYu0SZPUIsVO4KpDaodgcFzU,125
|
261
|
+
open_swarm-0.1.1744936125.dist-info/licenses/LICENSE,sha256=BU9bwRlnOt_JDIb6OT55Q4leLZx9RArDLTFnlDIrBEI,1062
|
262
|
+
open_swarm-0.1.1744936125.dist-info/RECORD,,
|
@@ -3,11 +3,19 @@ import os
|
|
3
3
|
import sys
|
4
4
|
from typing import Dict, Any, List, ClassVar, Optional
|
5
5
|
|
6
|
+
# Set logging to WARNING by default unless SWARM_DEBUG=1
|
7
|
+
if not os.environ.get("SWARM_DEBUG"):
|
8
|
+
logging.basicConfig(level=logging.WARNING)
|
9
|
+
else:
|
10
|
+
logging.basicConfig(level=logging.DEBUG)
|
11
|
+
|
6
12
|
# Ensure src is in path for BlueprintBase import
|
7
13
|
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
|
8
14
|
src_path = os.path.join(project_root, 'src')
|
9
15
|
if src_path not in sys.path: sys.path.insert(0, src_path)
|
10
16
|
|
17
|
+
from typing import Optional
|
18
|
+
from pathlib import Path
|
11
19
|
try:
|
12
20
|
from agents import Agent, Tool, function_tool, Runner
|
13
21
|
from agents.mcp import MCPServer
|
@@ -24,6 +32,13 @@ logger = logging.getLogger(__name__)
|
|
24
32
|
|
25
33
|
# --- Define the Blueprint ---
|
26
34
|
class ChatbotBlueprint(BlueprintBase):
|
35
|
+
def __init__(self, blueprint_id: str, config_path: Optional[Path] = None, **kwargs):
|
36
|
+
super().__init__(blueprint_id, config_path=config_path, **kwargs)
|
37
|
+
|
38
|
+
# Remove redundant client instantiation; rely on framework-level default client
|
39
|
+
# (No need to re-instantiate AsyncOpenAI or set_default_openai_client)
|
40
|
+
# All blueprints now use the default client set at framework init
|
41
|
+
|
27
42
|
"""A simple conversational chatbot agent."""
|
28
43
|
metadata: ClassVar[Dict[str, Any]] = {
|
29
44
|
"name": "ChatbotBlueprint",
|
@@ -42,19 +57,21 @@ class ChatbotBlueprint(BlueprintBase):
|
|
42
57
|
|
43
58
|
# --- Model Instantiation Helper --- (Standard helper)
|
44
59
|
def _get_model_instance(self, profile_name: str) -> Model:
|
45
|
-
"""Retrieves or creates an LLM Model instance."""
|
46
|
-
# ... (Implementation is the same as previous refactors) ...
|
60
|
+
"""Retrieves or creates an LLM Model instance, respecting LITELLM_MODEL/DEFAULT_LLM if set."""
|
47
61
|
if profile_name in self._model_instance_cache:
|
48
62
|
logger.debug(f"Using cached Model instance for profile '{profile_name}'.")
|
49
63
|
return self._model_instance_cache[profile_name]
|
50
64
|
logger.debug(f"Creating new Model instance for profile '{profile_name}'.")
|
51
65
|
profile_data = self.get_llm_profile(profile_name)
|
52
|
-
|
53
|
-
|
54
|
-
model_name = profile_data.get("model")
|
66
|
+
# Patch: Respect LITELLM_MODEL/DEFAULT_LLM env vars
|
67
|
+
import os
|
68
|
+
model_name = os.getenv("LITELLM_MODEL") or os.getenv("DEFAULT_LLM") or profile_data.get("model")
|
69
|
+
profile_data["model"] = model_name
|
70
|
+
if profile_data.get("provider", "openai").lower() != "openai": raise ValueError(f"Unsupported provider: {profile_data.get('provider')}")
|
55
71
|
if not model_name: raise ValueError(f"Missing 'model' in profile '{profile_name}'.")
|
56
|
-
|
57
|
-
|
72
|
+
|
73
|
+
# REMOVE PATCH: env expansion is now handled globally in config loader
|
74
|
+
client_cache_key = f"{profile_data.get('provider', 'openai')}_{profile_data.get('base_url')}"
|
58
75
|
if client_cache_key not in self._openai_client_cache:
|
59
76
|
client_kwargs = { "api_key": profile_data.get("api_key"), "base_url": profile_data.get("base_url") }
|
60
77
|
filtered_kwargs = {k: v for k, v in client_kwargs.items() if v is not None}
|
@@ -93,6 +110,45 @@ class ChatbotBlueprint(BlueprintBase):
|
|
93
110
|
logger.debug("Chatbot agent created.")
|
94
111
|
return chatbot_agent
|
95
112
|
|
113
|
+
async def run(self, messages: List[Dict[str, Any]], **kwargs) -> Any:
|
114
|
+
"""Main execution entry point for the Chatbot blueprint."""
|
115
|
+
logger.info("ChatbotBlueprint run method called.")
|
116
|
+
instruction = messages[-1].get("content", "") if messages else ""
|
117
|
+
async for chunk in self._run_non_interactive(instruction, **kwargs):
|
118
|
+
yield chunk
|
119
|
+
logger.info("ChatbotBlueprint run method finished.")
|
120
|
+
|
121
|
+
async def _run_non_interactive(self, instruction: str, **kwargs) -> Any:
|
122
|
+
mcp_servers = kwargs.get("mcp_servers", [])
|
123
|
+
agent = self.create_starting_agent(mcp_servers=mcp_servers)
|
124
|
+
from agents import Runner
|
125
|
+
import os
|
126
|
+
model_name = os.getenv("LITELLM_MODEL") or os.getenv("DEFAULT_LLM") or "gpt-3.5-turbo"
|
127
|
+
try:
|
128
|
+
result = await Runner.run(agent, instruction)
|
129
|
+
yield {"messages": [{"role": "assistant", "content": getattr(result, 'final_output', str(result))}]}
|
130
|
+
except Exception as e:
|
131
|
+
logger.error(f"Error during non-interactive run: {e}", exc_info=True)
|
132
|
+
yield {"messages": [{"role": "assistant", "content": f"An error occurred: {e}"}]}
|
133
|
+
|
96
134
|
# Standard Python entry point
|
97
135
|
if __name__ == "__main__":
|
98
|
-
|
136
|
+
import sys
|
137
|
+
import asyncio
|
138
|
+
# --- AUTO-PYTHONPATH PATCH FOR AGENTS ---
|
139
|
+
import os
|
140
|
+
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../..'))
|
141
|
+
src_path = os.path.join(project_root, 'src')
|
142
|
+
if src_path not in sys.path:
|
143
|
+
sys.path.insert(0, src_path)
|
144
|
+
if '--instruction' in sys.argv:
|
145
|
+
instruction = sys.argv[sys.argv.index('--instruction') + 1]
|
146
|
+
blueprint = ChatbotBlueprint(blueprint_id="chatbot")
|
147
|
+
async def runner():
|
148
|
+
async for chunk in blueprint._run_non_interactive(instruction):
|
149
|
+
msg = chunk["messages"][0]["content"]
|
150
|
+
if not msg.startswith("An error occurred:"):
|
151
|
+
print(msg)
|
152
|
+
asyncio.run(runner())
|
153
|
+
else:
|
154
|
+
print("Interactive mode not supported in this script.")
|
File without changes
|
{open_swarm-0.1.1743449197.dist-info → open_swarm-0.1.1744936125.dist-info}/entry_points.txt
RENAMED
File without changes
|
{open_swarm-0.1.1743449197.dist-info → open_swarm-0.1.1744936125.dist-info}/licenses/LICENSE
RENAMED
File without changes
|