massgen 0.1.1__py3-none-any.whl → 0.1.3__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.
- massgen/__init__.py +1 -1
- massgen/agent_config.py +33 -7
- massgen/api_params_handler/_api_params_handler_base.py +3 -0
- massgen/api_params_handler/_chat_completions_api_params_handler.py +7 -1
- massgen/backend/azure_openai.py +9 -1
- massgen/backend/base.py +56 -0
- massgen/backend/base_with_custom_tool_and_mcp.py +4 -4
- massgen/backend/capabilities.py +6 -6
- massgen/backend/chat_completions.py +18 -11
- massgen/backend/claude_code.py +9 -1
- massgen/backend/gemini.py +71 -6
- massgen/backend/gemini_utils.py +30 -0
- massgen/backend/grok.py +39 -6
- massgen/backend/response.py +18 -11
- massgen/chat_agent.py +9 -3
- massgen/cli.py +319 -43
- massgen/config_builder.py +163 -18
- massgen/configs/README.md +78 -20
- massgen/configs/basic/multi/three_agents_default.yaml +2 -2
- massgen/configs/debug/restart_test_controlled.yaml +60 -0
- massgen/configs/debug/restart_test_controlled_filesystem.yaml +73 -0
- massgen/configs/tools/code-execution/docker_with_sudo.yaml +35 -0
- massgen/configs/tools/custom_tools/computer_use_browser_example.yaml +56 -0
- massgen/configs/tools/custom_tools/computer_use_docker_example.yaml +65 -0
- massgen/configs/tools/custom_tools/computer_use_example.yaml +50 -0
- massgen/configs/tools/custom_tools/crawl4ai_mcp_example.yaml +67 -0
- massgen/configs/tools/custom_tools/crawl4ai_multi_agent_example.yaml +68 -0
- massgen/configs/tools/custom_tools/multimodal_tools/playwright_with_img_understanding.yaml +98 -0
- massgen/configs/tools/custom_tools/multimodal_tools/understand_audio.yaml +33 -0
- massgen/configs/tools/custom_tools/multimodal_tools/understand_file.yaml +34 -0
- massgen/configs/tools/custom_tools/multimodal_tools/understand_image.yaml +33 -0
- massgen/configs/tools/custom_tools/multimodal_tools/understand_video.yaml +34 -0
- massgen/configs/tools/custom_tools/multimodal_tools/understand_video_example.yaml +54 -0
- massgen/configs/tools/custom_tools/multimodal_tools/youtube_video_analysis.yaml +59 -0
- massgen/configs/tools/memory/README.md +199 -0
- massgen/configs/tools/memory/gpt5mini_gemini_context_window_management.yaml +131 -0
- massgen/configs/tools/memory/gpt5mini_gemini_no_persistent_memory.yaml +133 -0
- massgen/configs/tools/memory/test_context_window_management.py +286 -0
- massgen/configs/tools/multimodal/gpt5mini_gpt5nano_documentation_evolution.yaml +97 -0
- massgen/configs/tools/planning/five_agents_discord_mcp_planning_mode.yaml +7 -29
- massgen/configs/tools/planning/five_agents_filesystem_mcp_planning_mode.yaml +5 -6
- massgen/configs/tools/planning/five_agents_notion_mcp_planning_mode.yaml +4 -4
- massgen/configs/tools/planning/five_agents_twitter_mcp_planning_mode.yaml +4 -4
- massgen/configs/tools/planning/gpt5_mini_case_study_mcp_planning_mode.yaml +2 -2
- massgen/docker/README.md +83 -0
- massgen/filesystem_manager/_code_execution_server.py +22 -7
- massgen/filesystem_manager/_docker_manager.py +21 -1
- massgen/filesystem_manager/_filesystem_manager.py +8 -0
- massgen/filesystem_manager/_workspace_tools_server.py +0 -997
- massgen/formatter/_gemini_formatter.py +73 -0
- massgen/frontend/coordination_ui.py +175 -257
- massgen/frontend/displays/base_display.py +29 -0
- massgen/frontend/displays/rich_terminal_display.py +155 -9
- massgen/frontend/displays/simple_display.py +21 -0
- massgen/frontend/displays/terminal_display.py +22 -2
- massgen/logger_config.py +50 -6
- massgen/message_templates.py +123 -3
- massgen/orchestrator.py +652 -44
- massgen/tests/test_code_execution.py +178 -0
- massgen/tests/test_intelligent_planning_mode.py +643 -0
- massgen/tests/test_orchestration_restart.py +204 -0
- massgen/token_manager/token_manager.py +13 -4
- massgen/tool/__init__.py +4 -0
- massgen/tool/_multimodal_tools/understand_audio.py +193 -0
- massgen/tool/_multimodal_tools/understand_file.py +550 -0
- massgen/tool/_multimodal_tools/understand_image.py +212 -0
- massgen/tool/_multimodal_tools/understand_video.py +313 -0
- massgen/tool/docs/multimodal_tools.md +779 -0
- massgen/tool/workflow_toolkits/__init__.py +26 -0
- massgen/tool/workflow_toolkits/post_evaluation.py +216 -0
- massgen/utils.py +1 -0
- {massgen-0.1.1.dist-info → massgen-0.1.3.dist-info}/METADATA +57 -52
- {massgen-0.1.1.dist-info → massgen-0.1.3.dist-info}/RECORD +77 -49
- {massgen-0.1.1.dist-info → massgen-0.1.3.dist-info}/WHEEL +0 -0
- {massgen-0.1.1.dist-info → massgen-0.1.3.dist-info}/entry_points.txt +0 -0
- {massgen-0.1.1.dist-info → massgen-0.1.3.dist-info}/licenses/LICENSE +0 -0
- {massgen-0.1.1.dist-info → massgen-0.1.3.dist-info}/top_level.txt +0 -0
massgen/backend/grok.py
CHANGED
|
@@ -18,6 +18,7 @@ TODO for future releases:
|
|
|
18
18
|
# -*- coding: utf-8 -*-
|
|
19
19
|
from __future__ import annotations
|
|
20
20
|
|
|
21
|
+
import logging
|
|
21
22
|
import os
|
|
22
23
|
from typing import Any, Dict, List, Optional
|
|
23
24
|
|
|
@@ -26,6 +27,8 @@ from openai import AsyncOpenAI
|
|
|
26
27
|
from ..logger_config import log_stream_chunk
|
|
27
28
|
from .chat_completions import ChatCompletionsBackend
|
|
28
29
|
|
|
30
|
+
logger = logging.getLogger(__name__)
|
|
31
|
+
|
|
29
32
|
|
|
30
33
|
class GrokBackend(ChatCompletionsBackend):
|
|
31
34
|
"""Grok backend using xAI's OpenAI-compatible API."""
|
|
@@ -41,12 +44,10 @@ class GrokBackend(ChatCompletionsBackend):
|
|
|
41
44
|
|
|
42
45
|
return openai.AsyncOpenAI(api_key=self.api_key, base_url=self.base_url)
|
|
43
46
|
|
|
44
|
-
def
|
|
45
|
-
"""
|
|
46
|
-
api_params = super()._build_base_api_params(messages, all_params)
|
|
47
|
-
|
|
48
|
-
# Add Live Search parameters if enabled (Grok-specific)
|
|
47
|
+
def _add_grok_search_params(self, api_params: Dict[str, Any], all_params: Dict[str, Any]) -> Dict[str, Any]:
|
|
48
|
+
"""Add Grok Live Search parameters to API params if web search is enabled."""
|
|
49
49
|
enable_web_search = all_params.get("enable_web_search", False)
|
|
50
|
+
|
|
50
51
|
if enable_web_search:
|
|
51
52
|
# Check for conflict with manually specified search_parameters
|
|
52
53
|
existing_extra = api_params.get("extra_body", {})
|
|
@@ -54,14 +55,46 @@ class GrokBackend(ChatCompletionsBackend):
|
|
|
54
55
|
error_message = "Conflict: Cannot use both 'enable_web_search: true' and manual 'extra_body.search_parameters'. Use one or the other."
|
|
55
56
|
log_stream_chunk("backend.grok", "error", error_message, self.agent_id)
|
|
56
57
|
raise ValueError(error_message)
|
|
58
|
+
|
|
57
59
|
# Merge search_parameters into existing extra_body
|
|
58
60
|
search_params = {"mode": "auto", "return_citations": True}
|
|
59
|
-
merged_extra = existing_extra.copy()
|
|
61
|
+
merged_extra = existing_extra.copy() if existing_extra else {}
|
|
60
62
|
merged_extra["search_parameters"] = search_params
|
|
61
63
|
api_params["extra_body"] = merged_extra
|
|
62
64
|
|
|
63
65
|
return api_params
|
|
64
66
|
|
|
67
|
+
async def _stream_with_custom_and_mcp_tools(
|
|
68
|
+
self,
|
|
69
|
+
current_messages: List[Dict[str, Any]],
|
|
70
|
+
tools: List[Dict[str, Any]],
|
|
71
|
+
client,
|
|
72
|
+
**kwargs,
|
|
73
|
+
):
|
|
74
|
+
"""Override to add Grok-specific search parameters before API call."""
|
|
75
|
+
# Build API params using parent method
|
|
76
|
+
all_params = {**self.config, **kwargs}
|
|
77
|
+
api_params = await self.api_params_handler.build_api_params(current_messages, tools, all_params)
|
|
78
|
+
|
|
79
|
+
# Add provider tools (web search, code interpreter) if enabled
|
|
80
|
+
# Note: For Grok, get_provider_tools() won't add web_search function tool
|
|
81
|
+
provider_tools = self.api_params_handler.get_provider_tools(all_params)
|
|
82
|
+
|
|
83
|
+
if provider_tools:
|
|
84
|
+
if "tools" not in api_params:
|
|
85
|
+
api_params["tools"] = []
|
|
86
|
+
api_params["tools"].extend(provider_tools)
|
|
87
|
+
|
|
88
|
+
# Add Grok-specific web search parameters via extra_body
|
|
89
|
+
api_params = self._add_grok_search_params(api_params, all_params)
|
|
90
|
+
|
|
91
|
+
# Start streaming
|
|
92
|
+
stream = await client.chat.completions.create(**api_params)
|
|
93
|
+
|
|
94
|
+
# Delegate to parent's stream processing
|
|
95
|
+
async for chunk in super()._process_stream(stream, all_params, self.agent_id):
|
|
96
|
+
yield chunk
|
|
97
|
+
|
|
65
98
|
def get_provider_name(self) -> str:
|
|
66
99
|
"""Get the name of this provider."""
|
|
67
100
|
return "Grok"
|
massgen/backend/response.py
CHANGED
|
@@ -356,18 +356,25 @@ class ResponseBackend(CustomToolAndMCPBackend):
|
|
|
356
356
|
# Execute MCP function calls
|
|
357
357
|
mcp_functions_executed = False
|
|
358
358
|
|
|
359
|
-
# Check if planning mode is enabled - block MCP tool execution during planning
|
|
359
|
+
# Check if planning mode is enabled - selectively block MCP tool execution during planning
|
|
360
360
|
if self.is_planning_mode_enabled():
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
361
|
+
blocked_tools = self.get_planning_mode_blocked_tools()
|
|
362
|
+
|
|
363
|
+
if not blocked_tools:
|
|
364
|
+
# Empty set means block ALL MCP tools (backward compatible)
|
|
365
|
+
logger.info("[Response] Planning mode enabled - blocking ALL MCP tool execution")
|
|
366
|
+
yield StreamChunk(
|
|
367
|
+
type="mcp_status",
|
|
368
|
+
status="planning_mode_blocked",
|
|
369
|
+
content="🚫 [MCP] Planning mode active - all MCP tools blocked during coordination",
|
|
370
|
+
source="planning_mode",
|
|
371
|
+
)
|
|
372
|
+
# Skip all MCP tool execution but still continue with workflow
|
|
373
|
+
yield StreamChunk(type="done")
|
|
374
|
+
return
|
|
375
|
+
else:
|
|
376
|
+
# Selective blocking - log but continue to check each tool individually
|
|
377
|
+
logger.info(f"[Response] Planning mode enabled - selective blocking of {len(blocked_tools)} tools")
|
|
371
378
|
|
|
372
379
|
# Ensure every captured function call gets a result to prevent hanging
|
|
373
380
|
for call in captured_function_calls:
|
massgen/chat_agent.py
CHANGED
|
@@ -365,10 +365,15 @@ class ConfigurableAgent(SingleAgent):
|
|
|
365
365
|
backend: LLM backend
|
|
366
366
|
session_id: Optional session identifier
|
|
367
367
|
"""
|
|
368
|
+
# Extract system message without triggering deprecation warning
|
|
369
|
+
system_message = None
|
|
370
|
+
if hasattr(config, "_custom_system_instruction"):
|
|
371
|
+
system_message = config._custom_system_instruction
|
|
372
|
+
|
|
368
373
|
super().__init__(
|
|
369
374
|
backend=backend,
|
|
370
375
|
agent_id=config.agent_id,
|
|
371
|
-
system_message=
|
|
376
|
+
system_message=system_message,
|
|
372
377
|
session_id=session_id,
|
|
373
378
|
)
|
|
374
379
|
self.config = config
|
|
@@ -411,8 +416,9 @@ class ConfigurableAgent(SingleAgent):
|
|
|
411
416
|
return backend_params["append_system_prompt"]
|
|
412
417
|
|
|
413
418
|
# Fall back to custom_system_instruction (deprecated but still supported)
|
|
414
|
-
|
|
415
|
-
|
|
419
|
+
# Access private attribute directly to avoid deprecation warning
|
|
420
|
+
if self.config and hasattr(self.config, "_custom_system_instruction") and self.config._custom_system_instruction:
|
|
421
|
+
return self.config._custom_system_instruction
|
|
416
422
|
|
|
417
423
|
# Finally fall back to parent class implementation
|
|
418
424
|
return super().get_configurable_system_message()
|